From: Ji-hoon Lee Date: Wed, 24 Oct 2018 05:21:25 +0000 (+0900) Subject: Fix defects detected by static analysis tool X-Git-Tag: accepted/tizen/unified/20191001.062542~2^2~103 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=66ebf39a32481f369be62e36b53d54492f363e80;p=platform%2Fcore%2Fuifw%2Fmulti-assistant-service.git Fix defects detected by static analysis tool Change-Id: I6dedfa1d0379a38fc0027de22d2845195c58bc0d --- diff --git a/src/multi_assistant_config.c b/src/multi_assistant_config.c index fa47d3f..6225f9b 100644 --- a/src/multi_assistant_config.c +++ b/src/multi_assistant_config.c @@ -177,7 +177,7 @@ int mas_config_get_assistant_info(mas_config_assistant_info_cb callback, void* u if (d) { while (NULL != (dir = readdir(d))) { - if (suffix && dir->d_name && strlen(suffix) <= strlen(dir->d_name)) { + if (suffix && strlen(suffix) <= strlen(dir->d_name)) { if (0 == strcmp(dir->d_name + strlen(dir->d_name) - strlen(suffix), suffix)) { char fullpath[_POSIX_PATH_MAX]; snprintf(fullpath, _POSIX_PATH_MAX - 1, "%s/%s", MA_ASSISTANT_INFO, dir->d_name); diff --git a/src/multi_assistant_service.c b/src/multi_assistant_service.c index 071f8e6..944923a 100644 --- a/src/multi_assistant_service.c +++ b/src/multi_assistant_service.c @@ -69,8 +69,13 @@ int ma_client_get_temp_speech_data_requested() return g_temp_speech_data_requested; } -int ma_client_create(ma_client_s info) +int ma_client_create(ma_client_s *info) { + if (NULL == info) { + MAS_LOGE("Input parameter is NULL"); //LCOV_EXCL_LINE + return -1; + } + ma_client_s* data = NULL; data = (ma_client_s*)calloc(1, sizeof(ma_client_s)); @@ -79,7 +84,7 @@ int ma_client_create(ma_client_s info) return -1;// MA_ERROR_OUT_OF_MEMORY; } - *data = info; + *data = *info; g_client_list = g_slist_append(g_client_list, data); @@ -179,7 +184,7 @@ int mas_client_initialize(int pid) new_client.pid = pid; strncpy(new_client.appid, appid, MAX_APPID_LEN); new_client.appid[MAX_APPID_LEN - 1] = '\0'; - ma_client_create(new_client); + ma_client_create(&new_client); const char *current_maclient_appid = NULL; if (g_current_maclient_info >= 0 && g_current_maclient_info < MAX_MACLIENT_INFO_NUM) { @@ -313,9 +318,14 @@ int mas_ui_client_change_assistant(const char* appid) { MAS_LOGD("[Enter]"); + if (NULL == appid) { + MAS_LOGE("NULL parameter"); + return -1; + } + /* We are going to terminate existing clients for testing purpose */ int pid = mas_get_current_client_pid(); - if (pid != -1 && appid) { + if (pid != -1) { ma_client_s *client = ma_client_find_by_pid(pid); if (client && strncmp(appid, client->appid, MAX_APPID_LEN) != 0) { int ret = aul_terminate_pid(pid); diff --git a/src/multi_assistant_service_plugin.c b/src/multi_assistant_service_plugin.c index 1e4a7f7..7a75552 100644 --- a/src/multi_assistant_service_plugin.c +++ b/src/multi_assistant_service_plugin.c @@ -202,13 +202,13 @@ static void __speech_streaming_cb(wakeup_service_speech_streaming_event_e event, int first = 1; size_t size; while (size = fread(content, 1, 640, fp)) { - wakeup_service_speech_streaming_event_e event; + wakeup_service_speech_streaming_event_e new_event; if (size == 640) { - event = (first ? WAKEUP_SPEECH_STREAMING_EVENT_START : WAKEUP_SPEECH_STREAMING_EVENT_CONTINUE); + new_event = (first ? WAKEUP_SPEECH_STREAMING_EVENT_START : WAKEUP_SPEECH_STREAMING_EVENT_CONTINUE); } else { - event = WAKEUP_SPEECH_STREAMING_EVENT_FINISH; + new_event = WAKEUP_SPEECH_STREAMING_EVENT_FINISH; } - int ret = masc_dbus_send_speech_data(pid, event, content, size); + int ret = masc_dbus_send_speech_data(pid, new_event, content, size); if (0 != ret) { MAS_LOGE("[ERROR] Fail to send speech data, ret(%d)", ret); }