Fix defects detected by static analysis tool
authorJi-hoon Lee <dalton.lee@samsung.com>
Wed, 24 Oct 2018 05:21:25 +0000 (14:21 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Wed, 24 Oct 2018 05:43:31 +0000 (14:43 +0900)
Change-Id: I6dedfa1d0379a38fc0027de22d2845195c58bc0d

src/multi_assistant_config.c
src/multi_assistant_service.c
src/multi_assistant_service_plugin.c

index fa47d3f..6225f9b 100644 (file)
@@ -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);
index 071f8e6..944923a 100644 (file)
@@ -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);
index 1e4a7f7..7a75552 100644 (file)
@@ -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);
                                                }