From: Suyeon Hwang Date: Wed, 2 Aug 2023 06:46:20 +0000 (+0900) Subject: Add parameter checking code X-Git-Tag: accepted/tizen/unified/20230803.174807^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=659954e55d318bdd694300fdfc6d4250b90a7ec4;p=platform%2Fcore%2Fuifw%2Fstt.git Add parameter checking code - 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 --- diff --git a/client/stt.c b/client/stt.c index 854f3b6..8966adb 100644 --- a/client/stt.c +++ b/client/stt.c @@ -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");