Fix Coverity issues 40/173640/2 accepted/tizen/unified/20180326.075227 submit/tizen/20180323.043859
authorhj kim <backto.kim@samsung.com>
Fri, 23 Mar 2018 01:16:23 +0000 (10:16 +0900)
committerhj kim <backto.kim@samsung.com>
Fri, 23 Mar 2018 02:52:29 +0000 (11:52 +0900)
Change-Id: Icb277dcd4d500d76a24fdd43dc07d545ca74213c

lib/media-util-cynara.c
src/common/media-common-db-svc.c
src/scanner-v2/media-scanner-extract-v2.c
src/scanner-v2/media-scanner-scan-v2.c
src/scanner/media-scanner-scan.c

index e53c6d0..882e1ad 100755 (executable)
@@ -146,7 +146,7 @@ int ms_cynara_receive_untrusted_message(int sockfd, ms_comm_msg_s *recv_msg, ms_
 int ms_cynara_receive_untrusted_message_thumb(int sockfd, thumbMsg *recv_msg, ms_peer_credentials *credentials)
 {
        int ret = 0;
-       int header_size = 0;
+       unsigned int header_size = 0;
        int recv_msg_size = 0;
        unsigned char *buf = NULL;
 
index 20c4220..cbbea37 100755 (executable)
@@ -320,8 +320,8 @@ void ms_unload_functions(void)
 
 int ms_connect_db(void ***handle, uid_t uid)
 {
-       int lib_index;
-       int ret;
+       int lib_index = 0;
+       int ret = MS_MEDIA_ERR_NONE;
        char * err_msg = NULL;
 
        /*Lock mutex for openning db*/
index 617ca2d..08521a8 100755 (executable)
@@ -354,6 +354,7 @@ gboolean msc_storage_extract_thread(void *data)
        uid_t uid = MEDIA_DEFAULT_UID;
        int disc_state = 0;
        int end_flag = NORMAL_EVENT;
+       int tem_ret = MS_MEDIA_ERR_NONE;
 
        while (1) {
                __msc_set_storage_extract_status(MS_STORAGE_SCAN_DONE);
@@ -424,7 +425,7 @@ gboolean msc_storage_extract_thread(void *data)
                __msc_pause_extract();
                MS_DBG_WARN("extract RESUME");
 
-               int tem_ret = __msc_check_extract_stop_status(extract_data->msg_type, update_path, extract_data->pid, end_flag);
+               tem_ret = __msc_check_extract_stop_status(extract_data->msg_type, update_path, extract_data->pid, end_flag);
                if (tem_ret == MS_MEDIA_ERR_SCANNER_FORCE_STOP) {
                        ms_set_storage_scan_status(handle, extract_data->storage_id, MEDIA_EXTRACT_STOP, uid);
                        __msc_set_storage_extract_status(MS_STORAGE_SCAN_META_STOP);
@@ -529,6 +530,9 @@ void msc_insert_exactor_request(int message_type, bool ins_status, const char *s
 
 int msc_remove_extract_request(const ms_comm_msg_s *recv_msg)
 {
+       int i = 0;
+       int j = 0;
+
        if (recv_msg == NULL) {
                MS_DBG_ERR("recv_msg is null");
                return MS_MEDIA_ERR_INVALID_PARAMETER;
@@ -547,8 +551,8 @@ int msc_remove_extract_request(const ms_comm_msg_s *recv_msg)
        }
 
        temp_queue = g_async_queue_new();
-       int i = 0;
-       for (; i < len; i++) {
+
+       for (i = 0; i < len; i++) {
                /*create new queue to compare request*/
                msg = g_async_queue_pop(storage_extract_queue);
                if ((strcmp(msg->storage_id, storageid) == 0)) {
@@ -563,8 +567,8 @@ int msc_remove_extract_request(const ms_comm_msg_s *recv_msg)
                }
        }
        len = g_async_queue_length(temp_queue);
-       int j = 0;
-       for (; j < len; j++) {
+
+       for (j = 0; j < len; j++) {
                msg = g_async_queue_pop(temp_queue);
                if (msg)
                        g_async_queue_push(storage_extract_queue, GINT_TO_POINTER(msg));
index 43cbd9d..ab50665 100755 (executable)
@@ -1702,6 +1702,7 @@ gboolean msc_register_thread(void *data)
        int pid = 0;
        ms_msg_type_e current_msg = MS_MSG_MAX;
        uid_t uid = MEDIA_DEFAULT_UID;
+       ms_comm_msg_s *msg_data = NULL;
 
        /*create array for processing overlay data*/
        register_array = g_array_new(FALSE, FALSE, sizeof(ms_comm_msg_s *));
@@ -1772,10 +1773,9 @@ _POWEROFF:
        MS_SAFE_FREE(register_data);
        if (register_array) {
                while (register_array->len != 0) {
-                       ms_comm_msg_s *data = NULL;
-                       data = g_array_index(register_array , ms_comm_msg_s*, 0);
+                       msg_data = g_array_index(register_array , ms_comm_msg_s*, 0);
                        g_array_remove_index(register_array, 0);
-                       MS_SAFE_FREE(data);
+                       MS_SAFE_FREE(msg_data);
                }
                g_array_free(register_array, FALSE);
                register_array = NULL;
index 9d32e6b..65515e1 100755 (executable)
@@ -659,6 +659,7 @@ gboolean msc_register_thread(void *data)
        int ret = MS_MEDIA_ERR_NONE;
        int pid = 0;
        ms_msg_type_e current_msg = MS_MSG_MAX;
+       ms_comm_msg_s *msg_data = NULL;
 
        /*create array for processing overlay data*/
        register_array = g_array_new(FALSE, FALSE, sizeof(ms_comm_msg_s *));
@@ -727,10 +728,9 @@ _POWEROFF:
        MS_SAFE_FREE(register_data);
        if (register_array) {
                while (register_array->len != 0) {
-                       ms_comm_msg_s *data = NULL;
-                       data = g_array_index(register_array , ms_comm_msg_s*, 0);
+                       msg_data = g_array_index(register_array , ms_comm_msg_s*, 0);
                        g_array_remove_index(register_array, 0);
-                       MS_SAFE_FREE(data);
+                       MS_SAFE_FREE(msg_data);
                }
                g_array_free(register_array, FALSE);
                register_array = NULL;