Fix static analysis tool warnings 16/140016/2 submit/tizen/20170724.081454 submit/tizen/20170725.090318
authorAtul Rai <a.rai@samsung.com>
Fri, 21 Jul 2017 10:31:18 +0000 (16:01 +0530)
committerPyun DoHyun <dh79.pyun@samsung.com>
Mon, 24 Jul 2017 07:33:36 +0000 (07:33 +0000)
Change-Id: I1b1dcc4a27366352fadd7370bb8a14f173e37938
Signed-off-by: Atul Rai <a.rai@samsung.com>
bt-api/bt-event-handler.c
bt-httpproxy/bt-httpproxy.c

index 8f6cc2b..c0f8016 100644 (file)
@@ -2045,7 +2045,7 @@ void __bt_map_client_event_filter(GDBusConnection *connection,
                g_variant_get(folder_list_var, "(aa{sv})", &iter);
 
                folders_struct.size = g_variant_iter_n_children(iter);
-               folders_struct.names = (char**) malloc(folders_struct.size * sizeof(*(folders_struct.names)));
+               folders_struct.names = (char**) g_malloc0(folders_struct.size * sizeof(*(folders_struct.names)));
                BT_DBG("g_variant_iter_n_children: %d", folders_struct.size);
                GVariantIter* res = NULL;
                int i = 0;
@@ -2071,7 +2071,7 @@ void __bt_map_client_event_filter(GDBusConnection *connection,
                        free(folders_struct.names[i]);
                        folders_struct.names[i] = NULL;
                }
-               free(folders_struct.names);
+               g_free(folders_struct.names);
 
                g_variant_unref(folder_list_var);
 
@@ -2096,7 +2096,7 @@ void __bt_map_client_event_filter(GDBusConnection *connection,
                        fields_info.size  = g_variant_iter_n_children(iter);
                        char* field = NULL;
 
-                       fields_info.fields = malloc(fields_info.size * sizeof(char*));
+                       fields_info.fields = g_malloc0(fields_info.size * sizeof(char*));
                        while (g_variant_iter_loop(iter, "s", &field)) {
                                fields_info.fields[i] = strdup(field);
                                i++;
@@ -2111,7 +2111,7 @@ void __bt_map_client_event_filter(GDBusConnection *connection,
                        free(fields_info.fields[i]);
                        fields_info.fields[i] = NULL;
                }
-               free(fields_info.fields);
+               g_free(fields_info.fields);
 
                __bt_remove_push_request_id(request_id);
                g_variant_unref(value);
@@ -2130,7 +2130,7 @@ void __bt_map_client_event_filter(GDBusConnection *connection,
                g_variant_get(messages_list_var, "(a{oa{sv}})", &iter);
                messages_struct.size = g_variant_iter_n_children(iter);
                messages_struct.message_items = (bt_map_client_message_item_t*)
-                       malloc(messages_struct.size * sizeof(*(messages_struct.message_items)));
+                       g_malloc(messages_struct.size * sizeof(*(messages_struct.message_items)));
                BT_DBG("g_variant_iter_n_children: %d", messages_struct.size);
 
                char *object = NULL;
@@ -2253,7 +2253,7 @@ void __bt_map_client_event_filter(GDBusConnection *connection,
                        free(messages_struct.message_items[i].type);
                        free(messages_struct.message_items[i].status);
                }
-               free(messages_struct.message_items);
+               g_free(messages_struct.message_items);
 
                g_variant_unref(messages_list_var);
        } else if (strcasecmp(signal_name, BT_MAP_GET_MESSAGE_COMPLETE) == 0) {
index fa3647a..dbea6cc 100644 (file)
@@ -363,7 +363,7 @@ static void _bt_hps_set_notify_read_status(const char *obj_path,
                                notify_read_info->offset_status = offset_status;
                                notify_read_info->https_status = https_status;
                                hps_notify_read_list = g_slist_insert_sorted(hps_notify_read_list,
-                                                               notify_read_info, notify_info_cmp);
+                                               notify_read_info, notify_info_cmp);
                                return;
                        }
                }
@@ -380,17 +380,16 @@ static void _bt_hps_set_notify_read_status(const char *obj_path,
                        hps_notify_read_list = g_slist_append(hps_notify_read_list, notify_read_info);
                }
                return;
-       } else {
-               /* Store Notification information */
-               notify_read_info = g_new0(struct hps_notify_read_info, 1);
-               if (notify_read_info) {
-                       notify_read_info->char_path = g_strdup(obj_path);
-                       notify_read_info->read_status = read_status;
-                       notify_read_info->offset_status = offset_status;
-                       notify_read_info->https_status = https_status;
-                       hps_notify_read_list = g_slist_append(hps_notify_read_list, notify_read_info);
-               }
-               return;
+       }
+
+       /* Store Notification information */
+       notify_read_info = g_new0(struct hps_notify_read_info, 1);
+       if (notify_read_info) {
+               notify_read_info->char_path = g_strdup(obj_path);
+               notify_read_info->read_status = read_status;
+               notify_read_info->offset_status = offset_status;
+               notify_read_info->https_status = https_status;
+               hps_notify_read_list = g_slist_append(hps_notify_read_list, notify_read_info);
        }
 }