From 0fc0d9383c238708591d9861baea3b937563a71f Mon Sep 17 00:00:00 2001 From: Atul Rai Date: Fri, 21 Jul 2017 16:01:18 +0530 Subject: [PATCH] Fix static analysis tool warnings Change-Id: I1b1dcc4a27366352fadd7370bb8a14f173e37938 Signed-off-by: Atul Rai --- bt-api/bt-event-handler.c | 12 ++++++------ bt-httpproxy/bt-httpproxy.c | 23 +++++++++++------------ 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/bt-api/bt-event-handler.c b/bt-api/bt-event-handler.c index 8f6cc2b..c0f8016 100644 --- a/bt-api/bt-event-handler.c +++ b/bt-api/bt-event-handler.c @@ -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) { diff --git a/bt-httpproxy/bt-httpproxy.c b/bt-httpproxy/bt-httpproxy.c index fa3647a..dbea6cc 100644 --- a/bt-httpproxy/bt-httpproxy.c +++ b/bt-httpproxy/bt-httpproxy.c @@ -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); } } -- 2.7.4