From: Syam Sidhardhan Date: Fri, 2 Jun 2017 17:29:03 +0000 (+0530) Subject: Fix unwanted check before g_free() X-Git-Tag: submit/tizen_3.0/20171207.001107~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4d18331b13017c80c58d96bbfe09462e4b3e885e;p=platform%2Fcore%2Fapi%2Fbluetooth.git Fix unwanted check before g_free() g_free() internally validate the pointer Change-Id: I4309c581eeb1ec2b289c834f7a952348d73f287a --- diff --git a/src/bluetooth-adapter.c b/src/bluetooth-adapter.c index 35c2f1c..de7e196 100644 --- a/src/bluetooth-adapter.c +++ b/src/bluetooth-adapter.c @@ -3303,8 +3303,7 @@ int bt_adapter_le_free_ibeacon_report(bt_adapter_ibeacon_scan_result_info_s *ibe BT_CHECK_INIT_STATUS(); BT_CHECK_INPUT_PARAMETER(ibeacon_info); /* LCOV_EXCL_START */ - if (ibeacon_info->uuid) - g_free(ibeacon_info->uuid); + g_free(ibeacon_info->uuid); g_free(ibeacon_info); diff --git a/src/bluetooth-audio.c b/src/bluetooth-audio.c index f3d0e35..b11d6f2 100644 --- a/src/bluetooth-audio.c +++ b/src/bluetooth-audio.c @@ -816,8 +816,7 @@ int bt_call_list_reset(bt_call_list_h list) break; handle->list = g_list_remove(handle->list, call_status); - if (NULL != call_status->phone_number) - g_free(call_status->phone_number); + g_free(call_status->phone_number); g_free(call_status); } while (1); diff --git a/src/bluetooth-tds.c b/src/bluetooth-tds.c index 5a9a7e6..6cec83c 100644 --- a/src/bluetooth-tds.c +++ b/src/bluetooth-tds.c @@ -478,10 +478,8 @@ void _bt_tds_control_point_indication_response_update(const char *address, bluet if ((seeker_s)->control_point_act_cb) ((bt_tds_control_point_activation_indication_cb)((seeker_s)->control_point_act_cb))(result, address, info->tds_data.data, info->tds_data.length, (seeker_s)->control_point_act_user_data); - if (seeker_s->activation_data) { - g_free(seeker_s->activation_data); - seeker_s->activation_data = NULL; - } + g_free(seeker_s->activation_data); + seeker_s->activation_data = NULL; } } } @@ -505,10 +503,8 @@ void _bt_tds_control_point_activation_result_update(int result, const char *remo if ((seeker_s)->control_point_act_cb) ((bt_tds_control_point_activation_indication_cb)((seeker_s)->control_point_act_cb))(BT_ERROR_OPERATION_FAILED, remote_address, NULL, 0, (seeker_s)->control_point_act_user_data); - if (seeker_s->activation_data) { g_free(seeker_s->activation_data); seeker_s->activation_data = NULL; - } return; } else BT_DBG("TDS Activation request successfully accepted by Provider, wait for Indication"); @@ -540,10 +536,8 @@ void _bt_tds_control_point_enabled_update(int result, const char *remote_address ((bt_tds_control_point_activation_indication_cb)((seeker_s)->control_point_act_cb))(BT_ERROR_OPERATION_FAILED, remote_address, NULL, 0, (seeker_s)->control_point_act_user_data); - if (seeker_s->activation_data) { - g_free(seeker_s->activation_data); - seeker_s->activation_data = NULL; - } + g_free(seeker_s->activation_data); + seeker_s->activation_data = NULL; return; } else { BT_DBG("TDS Control Point enabled successfully!!"); @@ -648,35 +642,23 @@ int _bt_tds_parse_transport_blocks(bt_tds_transport_block_list_s **info, static void __bt_tds_reset_seeker_data(bt_tds_seeker_s *seeker) { - if ((seeker)->remote_address) { - g_free((seeker)->remote_address); - (seeker)->remote_address = NULL; - } + g_free((seeker)->remote_address); + (seeker)->remote_address = NULL; - if ((seeker)->tds_control_point) { - g_free((seeker)->tds_control_point); - (seeker)->tds_control_point = NULL; - } + g_free((seeker)->tds_control_point); + (seeker)->tds_control_point = NULL; - if ((seeker)->tds_control_point_cccd) { - g_free((seeker)->tds_control_point_cccd); - (seeker)->tds_control_point_cccd = NULL; - } + g_free((seeker)->tds_control_point_cccd); + (seeker)->tds_control_point_cccd = NULL; - if ((seeker)->tds_user_data_desciptor) { - g_free((seeker)->tds_user_data_desciptor); - (seeker)->tds_user_data_desciptor = NULL; - } + g_free((seeker)->tds_user_data_desciptor); + (seeker)->tds_user_data_desciptor = NULL; - if ((seeker)->tds_service_handle) { - g_free((seeker)->tds_service_handle); - (seeker)->tds_service_handle = NULL; - } + g_free((seeker)->tds_service_handle); + (seeker)->tds_service_handle = NULL; - if ((seeker)->activation_data) { - g_free((seeker)->activation_data); - (seeker)->activation_data = NULL; - } + g_free((seeker)->activation_data); + (seeker)->activation_data = NULL; /* Reset CCCD */ (seeker)->cccd_enabled = false; @@ -828,12 +810,10 @@ static int __bt_update_tds_transport_data(bluetooth_device_address_t *address, b bluetooth_gatt_free_desc_property(&desc_property); goto fail; } - if ((seeker_s)->tds_control_point) - g_free((seeker_s)->tds_control_point); + g_free((seeker_s)->tds_control_point); (seeker_s)->tds_control_point = g_strdup(characteristic.handle); - if ((seeker_s)->tds_control_point_cccd) - g_free((seeker_s)->tds_control_point_cccd); + g_free((seeker_s)->tds_control_point_cccd); (seeker_s)->tds_control_point_cccd = g_strdup(desc_property.handle); BT_DBG("TDS Control point handle [%s]", (seeker_s)->tds_control_point); @@ -866,8 +846,7 @@ static int __bt_update_tds_transport_data(bluetooth_device_address_t *address, b if (g_strstr_len(desc_property.uuid, -1, BT_TDS_USER_DATA_DESCRIPTOR)) { BT_DBG("User data descriptor handle discovered"); - if ((seeker_s)->tds_user_data_desciptor) - g_free((seeker_s)->tds_user_data_desciptor); + g_free((seeker_s)->tds_user_data_desciptor); (seeker_s)->tds_user_data_desciptor = g_strdup(desc_property.handle); } @@ -881,8 +860,7 @@ static int __bt_update_tds_transport_data(bluetooth_device_address_t *address, b bluetooth_gatt_free_char_property(&characteristic); } /* Next Charatceristic */ - if ((seeker_s)->tds_service_handle) - g_free((seeker_s)->tds_service_handle); + g_free((seeker_s)->tds_service_handle); (seeker_s)->tds_service_handle = g_strdup(service.handle); bluetooth_gatt_free_service_property(&service); diff --git a/test/bt_unit_test.c b/test/bt_unit_test.c index 0110e11..c992710 100644 --- a/test/bt_unit_test.c +++ b/test/bt_unit_test.c @@ -2670,8 +2670,7 @@ void __tds_activation_req_cb(char *rem_bd_addr, for (i = 0; i < len; i++) TC_PRT("Act req data[%d] : %.2x", i, buf[i]); - if (tds_act_address) - g_free(tds_act_address); + g_free(tds_act_address); tds_act_address = g_strdup(rem_bd_addr); }