Add parameter checking code 15/296615/1 accepted/tizen/unified/20230803.174807
authorSuyeon Hwang <stom.hwang@samsung.com>
Wed, 2 Aug 2023 06:46:20 +0000 (15:46 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Wed, 2 Aug 2023 06:46:20 +0000 (15:46 +0900)
- Issue:
Some functions do not have code for parameter checking even though their
description says they can return invalid parameter error.

- Solution:
This patch adds parameter checking code. Through this patch, the
functions can check the parameter validation and returns the error
properly.

Change-Id: Ie7ffe4ab2ebb7df19b63b09bb17315208af064a2
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
client/stt.c

index 854f3b6..8966adb 100644 (file)
@@ -1492,6 +1492,8 @@ int stt_start_audio_streaming(stt_h stt, const char* language, const char* type)
        stt_client_s* client = NULL;
        RETV_IF(false == is_stt_feature_enabled(), STT_ERROR_NOT_SUPPORTED);
        RETV_IF(STT_ERROR_NONE != __stt_check_handle(stt, &client), STT_ERROR_INVALID_PARAMETER);
+       RETVM_IF(NULL == type, STT_ERROR_INVALID_PARAMETER, "[ERROR] type is NULL");
+
        RETVM_IF(STT_STATE_READY != client->current_state, STT_ERROR_INVALID_STATE, "[ERROR] Current state(%d) is not READY", client->current_state);
 
        RETVM_IF(STT_INTERNAL_STATE_NONE != client->internal_state, STT_ERROR_IN_PROGRESS_TO_RECORDING, "[ERROR] Invalid State : Internal state is NOT none : %d", client->current_state);
@@ -1532,6 +1534,9 @@ int stt_send_audio_streaming(stt_h stt, const char* data, size_t data_size)
        stt_client_s* client = NULL;
        RETV_IF(false == is_stt_feature_enabled(), STT_ERROR_NOT_SUPPORTED);
        RETV_IF(STT_ERROR_NONE != __stt_check_handle(stt, &client), STT_ERROR_INVALID_PARAMETER);
+       RETVM_IF(NULL == data, STT_ERROR_INVALID_PARAMETER, "[ERROR] data is NULL");
+       RETVM_IF(0 == data_size, STT_ERROR_INVALID_PARAMETER, "[ERROR] data size is 0");
+
        RETVM_IF(STT_STATE_RECORDING != client->current_state, STT_ERROR_INVALID_STATE, "[ERROR] Current state(%d) is not RECORDING", client->current_state);
 
        SLOG(LOG_INFO, TAG_STTC, "===== STT SEND AUDIO STREAMING");