Fix incorrect memory validation for g_malloc*() 68/100468/2
authorSyam <s.syam@samsung.com>
Mon, 28 Nov 2016 08:32:47 +0000 (17:32 +0900)
committerInjun Yang <injun.yang@samsung.com>
Mon, 28 Nov 2016 10:13:19 +0000 (19:13 +0900)
g_malloc*() will always return a valid memory address. If the
device is in out of memory case, g_malloc*() will assert.
Hence no need to validate the return value against NULL.

g_malloc*() will always return a memory address which is of type void *.
It doesn't make any sense to typecast this return address to another
pointer address. Ex: char *p = (char *)g_malloc0(..);

Change-Id: I84e772ea2879f2e00a9232922638e19075fd1c7f
Signed-off-by: Injun Yang <injun.yang@samsung.com>
17 files changed:
bt-api/bt-audio.c
bt-api/bt-event-handler.c
bt-api/bt-gatt-client.c
bt-api/bt-hid-device.c
bt-service-emul/bt-service-event-manager.c
bt-service-emul/bt-service-util.c
bt-service/bt-service-adapter-le.c
bt-service/bt-service-agent.c
bt-service/bt-service-audio.c
bt-service/bt-service-device.c
bt-service/bt-service-event-receiver.c
bt-service/bt-service-gap-agent.c
bt-service/bt-service-hid.c
bt-service/bt-service-network.c
bt-service/bt-service-opp-client.c
bt-service/bt-service-util.c [changed mode: 0755->0644]
test/gatt-test/bluetooth-gatt-test.c [changed mode: 0755->0644]

index 7cb2a5a..33a0df2 100644 (file)
@@ -515,9 +515,6 @@ static int __bt_hf_agent_read_call_list(GVariant *reply,
        BT_DBG("Call count = %d", call_count);
 
        *call_list = g_malloc0(sizeof(bt_hf_call_list_s));
-       /* Fix : NULL_RETURNS */
-       retv_if(*call_list == NULL, BLUETOOTH_ERROR_MEMORY_ALLOCATION);
-
        (*call_list)->count = call_count;
 
        g_variant_iter_init(&iter, var_temp);
@@ -525,9 +522,6 @@ static int __bt_hf_agent_read_call_list(GVariant *reply,
                bt_hf_call_status_info_t *call_info;
 
                call_info = g_malloc0(sizeof(bt_hf_call_status_info_t));
-               /* Fix : NULL_RETURNS */
-               retv_if(call_info == NULL, BLUETOOTH_ERROR_MEMORY_ALLOCATION);
-
                call_info->number = g_strdup(num);
                call_info->direction = dir;
                call_info->status = status;
index 7b87a32..7bda552 100644 (file)
@@ -229,9 +229,6 @@ static int __bt_call_list_add(bt_hf_call_list_s *list, char * number,
        }
        handle = (bt_hf_call_list_s *)list;
        call_status = g_malloc0(sizeof(bt_hf_call_status_info_t));
-       /* Fix : NULL_RETURNS */
-       retv_if(call_status == NULL, BLUETOOTH_ERROR_MEMORY_ALLOCATION);
-
        call_status->number = g_strdup(number);
        call_status->direction = dir;
        call_status->status = status;
@@ -276,12 +273,6 @@ static bluetooth_device_info_t *__bt_get_device_info_in_message(GVariant *parame
                manufacturer_data = (char *)g_variant_get_data(manufacturer_var);
 
        dev_info = g_malloc0(sizeof(bluetooth_device_info_t));
-       /* Fix : NULL_RETURNS */
-       if (dev_info == NULL) {
-               result = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
-               goto done;
-       }
-
        dev_info->rssi = rssi;
        dev_info->paired = paired;
        dev_info->connected = connected;
@@ -306,7 +297,6 @@ static bluetooth_device_info_t *__bt_get_device_info_in_message(GVariant *parame
        if (manufacturer_data)
                for (i = 0; i < manufacturer_data_len; i++)
                        dev_info->manufacturer_data.data[i] = manufacturer_data[i];
-done:
        *ret = result;
        g_free(uuids);
        g_variant_unref(string_var);
@@ -342,11 +332,6 @@ static bluetooth_le_device_info_t *__bt_get_le_device_info_in_message(GVariant *
                scan_data = (char *)g_variant_get_data(scan_var);
 
        le_dev_info = g_malloc0(sizeof(bluetooth_le_device_info_t));
-       /* Fix : NULL_RETURNS */
-       if (le_dev_info == NULL) {
-               result = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
-               goto done;
-       }
        _bt_convert_addr_string_to_type(le_dev_info->device_address.addr, address);
        le_dev_info->addr_type = addr_type;
        le_dev_info->rssi = rssi;
@@ -362,9 +347,7 @@ static bluetooth_le_device_info_t *__bt_get_le_device_info_in_message(GVariant *
                if (scan_data)
                        le_dev_info->scan_resp_data.data.data[i] = scan_data[i];
 
-done:
        *ret = result;
-
        g_variant_unref(adv_var);
        g_variant_unref(scan_var);
        return le_dev_info;
@@ -853,13 +836,6 @@ void __bt_device_event_filter(GDBusConnection *connection,
                /* Fix : FORWARD_NULL : g_variant_get_data can return NULL */
                if (char_val.val_len > 0 && value != NULL) {
                        char_val.char_value = (unsigned char*) g_malloc0(char_val.val_len);
-                       /* Fix : NULL_RETURNS */
-                       if (char_val.char_value == NULL) {
-                               BT_ERR("BLUETOOTH_ERROR_OUT_OF_MEMORY");
-                               g_free(char_val.char_handle);
-                               g_variant_unref(char_value_var);
-                               return;
-                       }
                        memcpy(char_val.char_value, value, len);
                        _bt_common_event_cb(BLUETOOTH_EVENT_GATT_CHAR_VAL_CHANGED,
                                        result, &char_val,
index 108d119..5e27343 100644 (file)
@@ -94,10 +94,6 @@ static char **__get_string_array_from_gptr_array(GPtrArray *gp)
 
        path = g_malloc0((gp->len + 1) * sizeof(char *));
 
-       /* Fix : NULL_RETURNS */
-       if (path == NULL)
-               return NULL;
-
        for (i = 0; i < gp->len; i++) {
                gp_path = g_ptr_array_index(gp, i);
                path[i] = g_strdup(gp_path);
@@ -1229,13 +1225,9 @@ static int __bluetooth_gatt_descriptor_iter(const char *char_handle,
                                g_variant_get(value, "ay", &desc_value_iter);
                                len = g_variant_get_size((GVariant *)desc_value_iter);
 
-                               if (len > 0) {
+                               if (len > 0)
                                        characteristic->description = (char *)g_malloc0(len + 1);
-                                       if (!characteristic->description) {
-                                               ret = BLUETOOTH_ERROR_OUT_OF_MEMORY;
-                                               goto done;
-                                       }
-                               }
+
                                for (i = 0; i < len; i++) {
                                        g_variant_iter_loop(desc_value_iter, "y",
                                                &characteristic->description[i]);
@@ -1255,7 +1247,6 @@ static int __bluetooth_gatt_descriptor_iter(const char *char_handle,
                }
        }
 
-done:
        g_variant_iter_free(property_iter);
        g_variant_unref(result);
        g_object_unref(properties_proxy);
index e61a908..4aa02f1 100644 (file)
@@ -510,10 +510,6 @@ int new_hid_connection(const char *path, int fd, bluetooth_device_address_t *add
        if (dev_info == NULL) {
                dev_info = (hid_connected_device_info_t *)
                        g_malloc0(sizeof(hid_connected_device_info_t));
-               if (dev_info == NULL) {
-                       BT_ERR("Fail to allocation memory");
-                       return -1;
-               }
 
                dev_info->intr_fd = -1;
                dev_info->ctrl_fd = -1;
@@ -855,9 +851,7 @@ BT_EXPORT_API int bluetooth_hid_device_send_custom_event(const char *remote_addr
        else
                socket_fd = info->ctrl_fd;
 
-       send_event = (char*)g_malloc0(data_len + 2);
-       if (send_event == NULL)
-               return BLUETOOTH_ERROR_OUT_OF_MEMORY;
+       send_event = g_malloc0(data_len + 2);
 
        send_event[0] = (char)btcode;
        send_event[1] = (char)report_id;
index e82f3f5..5462b20 100644 (file)
@@ -117,8 +117,6 @@ void _bt_create_event_timer(int event_id, int interval, void *event_cb, void *us
        BT_DBG("+");
 
        event_info = g_malloc0(sizeof(bt_timer_info_t));
-       /* Fix : NULL_RETURNS */
-       ret_if(event_info == NULL);
 
        _bt_delete_event_timer(event_id);
 
@@ -192,7 +190,6 @@ bt_remote_dev_info_t *_bt_get_sample_device(int index)
        bt_remote_dev_info_t *dev_info;
 
        dev_info = g_malloc0(sizeof(bt_remote_dev_info_t));
-       retv_if(dev_info == NULL, NULL);
 
        dev_info->rssi = sample_devices[index].rssi;
        dev_info->class = sample_devices[index].class;
@@ -220,9 +217,8 @@ bt_remote_dev_info_t *_bt_get_sample_device(int index)
 
        if (dev_info->manufacturer_data_len > 0) {
                dev_info->manufacturer_data = g_malloc0(dev_info->manufacturer_data_len);
-               if (dev_info->manufacturer_data)
-                       memcpy(dev_info->manufacturer_data, sample_devices[index].manufacturer_data,
-                                       dev_info->manufacturer_data_len);
+               memcpy(dev_info->manufacturer_data, sample_devices[index].manufacturer_data,
+                               dev_info->manufacturer_data_len);
        }
 
        return dev_info;
index 681d35c..a8f9729 100644 (file)
@@ -86,8 +86,6 @@ int _bt_insert_request_list(int req_id, int service_function,
        request_info_t *info;
 
        info = g_malloc0(sizeof(request_info_t));
-       /* Fix : NULL_RETURNS */
-       retv_if(info == NULL, BLUETOOTH_ERROR_MEMORY_ALLOCATION);
 
        info->req_id = req_id;
        info->service_function = service_function;
index 02a97db..b97ddfb 100644 (file)
@@ -897,10 +897,6 @@ int __bt_get_available_scan_filter_slot_id(void)
                return -1;
        }
        slot_check_list = g_malloc0(sizeof(gboolean) * le_feature_info.max_filter);
-       if (slot_check_list == NULL) {
-               BT_ERR("Fail to allocate memory");
-               return -1;
-       }
 
        for (l = scanner_list; l != NULL; l = g_slist_next(l)) {
                scanner = l->data;
@@ -1249,20 +1245,16 @@ int _bt_register_scan_filter(const char *sender, bluetooth_le_scan_filter_t *fil
        scanner = __bt_find_scanner_from_list(sender);
        if (scanner == NULL) {
                scanner = g_malloc0(sizeof(bt_adapter_le_scanner_t));
-               if (scanner) {
-                       scanner->sender = strdup(sender);
-                       scanner_list = g_slist_append(scanner_list, scanner);
-               }
+               scanner->sender = strdup(sender);
+               scanner_list = g_slist_append(scanner_list, scanner);
        }
 
        filter_data = g_malloc0(sizeof(bluetooth_le_scan_filter_t));
-       if (filter_data) {
-               memcpy(filter_data, filter, sizeof(bluetooth_le_scan_filter_t));
-               filter_data->slot_id = *slot_id;
+       memcpy(filter_data, filter, sizeof(bluetooth_le_scan_filter_t));
+       filter_data->slot_id = *slot_id;
 
-               if (scanner)
-                       scanner->filter_list = g_slist_append(scanner->filter_list, filter_data);
-       }
+       if (scanner)
+               scanner->filter_list = g_slist_append(scanner->filter_list, filter_data);
 
        if (ret)
                g_variant_unref(ret);
@@ -1366,8 +1358,6 @@ int _bt_start_le_scan(const char *sender)
 
        if (scanner == NULL) {
                scanner = g_malloc0(sizeof(bt_adapter_le_scanner_t));
-               retv_if(scanner == NULL, BLUETOOTH_ERROR_INTERNAL);
-
                scanner->sender = strdup(sender);
                scanner_list = g_slist_append(scanner_list, scanner);
        }
index 92a36ab..1eb20a5 100644 (file)
@@ -961,12 +961,6 @@ static gboolean __bt_agent_is_device_blacklist(const char *address,
        rewind(fp);
 
        buffer = g_malloc0(sizeof(char) * size);
-       /* Fix : NULL_RETURNS */
-       if (buffer == NULL) {
-               BT_ERR("Fail to allocate memory");
-               fclose(fp);
-               return FALSE;
-       }
        result = fread((char *)buffer, 1, size, fp);
        fclose(fp);
        if (result != size) {
index 3b32b20..8030bb4 100644 (file)
@@ -513,12 +513,6 @@ void _bt_add_headset_to_list(int type, int status, const char *address)
        }
 
        connected_device = g_malloc0(sizeof(bt_connected_headset_data_t));
-       /* Fix : NULL_RETURNS */
-       if (connected_device == NULL) {
-               BT_ERR("No memory allocated");
-               return;
-       }
-
        connected_device->device_state = status;
        if ((status == BT_STATE_CONNECTED) || (status == BT_STATE_CONNECTING))
                connected_device->type |= type;
@@ -697,12 +691,6 @@ int _bt_audio_connect(int request_id, int type,
        _bt_convert_addr_type_to_string(address, device_address->addr);
 
        func_data = g_malloc0(sizeof(bt_audio_function_data_t));
-       /* Fix : NULL_RETURNS */
-       if (func_data == NULL) {
-               result = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
-               goto fail;
-       }
-
        func_data->address = g_strdup(address);
        func_data->req_id = request_id;
        func_data->type = type;
@@ -842,12 +830,6 @@ int _bt_audio_disconnect(int request_id, int type,
        _bt_convert_addr_type_to_string(address, device_address->addr);
 
        func_data = g_malloc0(sizeof(bt_audio_function_data_t));
-       /* Fix : NULL_RETURNS */
-       if (func_data == NULL) {
-               BT_ERR("Memory allocation error");
-               result = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
-               goto fail;
-       }
        func_data->address = g_strdup(address);
        func_data->req_id = request_id;
        func_data->pending = BT_PENDING_NONE;
@@ -988,12 +970,6 @@ int _bt_hf_connect(int request_id,
        }
 
        func_data = g_malloc0(sizeof(bt_function_data_t));
-       /* Fix : NULL_RETURNS */
-       if (func_data == NULL) {
-               result = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
-               goto fail;
-       }
-
        func_data->address = g_strdup(address);
        func_data->req_id = request_id;
        uuid = g_strdup(HFP_AG_UUID);
@@ -1053,12 +1029,6 @@ int _bt_hf_disconnect(int request_id,
        }
 
        func_data = g_malloc0(sizeof(bt_function_data_t));
-       /* Fix : NULL_RETURNS */
-       if (func_data == NULL) {
-               result = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
-               goto fail;
-       }
-
        func_data->address = g_strdup(address);
        func_data->req_id = request_id;
        uuid = g_strdup(HFP_AG_UUID);
index a69b949..b3ec8b5 100644 (file)
@@ -559,12 +559,6 @@ static gboolean __ignore_auto_pairing_request(const char *address)
        }
 
        buffer = g_malloc0(sizeof(char) * size);
-       /* Fix : NULL_RETURNS */
-       if (buffer == NULL) {
-               BT_ERR("Memory allocation error\n");
-               fclose(fp);
-               return FALSE;
-       }
        result = fread((char *)buffer, 1, size, fp);
        fclose(fp);
        if (result != size) {
@@ -1142,12 +1136,6 @@ int _bt_unbond_device(int request_id,
 
        /* allocate user data so that it can be retrieved in callback */
        unbonding_info = g_malloc0(sizeof(bt_funcion_data_t));
-       /* Fix : NULL_RETURNS */
-       if (unbonding_info == NULL) {
-               BT_ERR("Memory not allocated !");
-               return BLUETOOTH_ERROR_MEMORY_ALLOCATION;
-       }
-
        unbonding_info->addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
        unbonding_info->req_id = request_id;
 
@@ -1923,12 +1911,6 @@ static int __bt_connect_le_device_internal(int req_id, const bluetooth_device_ad
        retv_if(device_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        func_data = g_malloc0(sizeof(bt_function_data_t));
-       if (func_data == NULL) {
-               BT_ERR("Unable to allocate memory for address");
-               ret = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
-               goto fail;
-       }
-
        func_data->address = g_strdup(device_address);
        if (func_data->address == NULL) {
                BT_ERR("Unable to allocate memory for address");
@@ -2041,12 +2023,6 @@ int _bt_disconnect_le_device(int req_id,
        retv_if(device_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        func_data = g_malloc0(sizeof(bt_function_data_t));
-       if (func_data == NULL) {
-               BT_ERR("Unable to allocate memory for address");
-               ret = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
-               goto fail;
-       }
-
        func_data->address = g_strdup(device_address);
        if (func_data->address == NULL) {
                BT_ERR("Unable to allocate memory for address");
index de64d20..a60e917 100644 (file)
@@ -485,8 +485,6 @@ void _bt_handle_adapter_event(GVariant *msg, const char *member)
 
                /* Bonding from remote device */
                address = g_malloc0(BT_ADDRESS_STRING_SIZE);
-               if (address == NULL)
-                       return;
 
                g_variant_get(msg, "(&o)", &object_path);
 
@@ -1718,7 +1716,6 @@ void _bt_handle_device_event(GVariant *msg, const char *member, const char *path
                        gboolean connected = FALSE;
                        char *address;
                        address = g_malloc0(BT_ADDRESS_STRING_SIZE);
-                       ret_if(address == NULL);
 
                        _bt_convert_device_path_to_address(path, address);
                        g_variant_get(msg, "(b)", &connected);
@@ -1751,7 +1748,6 @@ void _bt_handle_device_event(GVariant *msg, const char *member, const char *path
                        }
 
                        address = g_malloc0(BT_ADDRESS_STRING_SIZE);
-                       ret_if(address == NULL);
 
                        _bt_convert_device_path_to_address(path, address);
 
@@ -1802,7 +1798,6 @@ void _bt_handle_device_event(GVariant *msg, const char *member, const char *path
                        ret_if(_bt_is_device_creating() == TRUE);
 
                        address = g_malloc0(BT_ADDRESS_STRING_SIZE);
-                       ret_if(address == NULL);
 
                        _bt_convert_device_path_to_address(path, address);
 
@@ -1852,7 +1847,6 @@ void _bt_handle_device_event(GVariant *msg, const char *member, const char *path
                g_variant_get(msg, "(y)", &addr_type);
 
                address = g_malloc0(BT_ADDRESS_STRING_SIZE);
-               ret_if(address == NULL);
 
                _bt_convert_device_path_to_address(path, address);
                dev_name = _bt_get_bonded_device_name(address);
@@ -1881,7 +1875,6 @@ void _bt_handle_device_event(GVariant *msg, const char *member, const char *path
                result = disc_reason;
 
                address = g_malloc0(BT_ADDRESS_STRING_SIZE);
-               ret_if(address == NULL);
 
                _bt_convert_device_path_to_address(path, address);
 
@@ -1947,7 +1940,6 @@ void _bt_handle_device_event(GVariant *msg, const char *member, const char *path
                g_variant_get(msg, "(si)", &profile_uuid, &state);
 
                address = g_malloc0(BT_ADDRESS_STRING_SIZE);
-               ret_if(address == NULL);
 
                _bt_convert_device_path_to_address(path, address);
                _bt_convert_addr_string_to_type(bd_addr.addr, address);
@@ -2162,8 +2154,6 @@ void _bt_handle_device_event(GVariant *msg, const char *member, const char *path
                ret_if(_bt_is_le_scanning() == FALSE);
 
                le_dev_info = g_malloc0(sizeof(bt_remote_le_dev_info_t));
-               if (le_dev_info == NULL)
-                       return;
 
                g_variant_get(msg, "(syyii@ay)", &le_dev_info->address,
                                                &le_dev_info->addr_type,
@@ -2194,21 +2184,12 @@ void _bt_handle_device_event(GVariant *msg, const char *member, const char *path
 
                if (le_dev_info->adv_type != BT_LE_ADV_SCAN_RSP) {       /* ADV_IND */
                        adv_info = g_malloc0(sizeof(bt_le_adv_info_t));
-                       if (adv_info == NULL) {
-                               _bt_free_le_device_info(le_dev_info);
-                               g_variant_unref(value);
-                               return;
-                       }
 
                        adv_info->addr = g_strdup(le_dev_info->address);
                        adv_info->addr_type = le_dev_info->addr_type;
                        adv_info->rssi = le_dev_info->rssi;
                        adv_info->data_len = le_dev_info->adv_data_len;
                        adv_info->data = g_malloc0(le_dev_info->adv_data_len);
-                       if (adv_info->data) {
-                               memcpy(adv_info->data, le_dev_info->adv_data,
-                                               le_dev_info->adv_data_len);
-                       }
 
                        if (__bt_add_adv_ind_info(adv_info) == 0) {
                                adv_info->timer_id = g_timeout_add(1000,
@@ -2328,8 +2309,6 @@ void _bt_handle_headset_event(GVariant *msg, const char *path)
                g_variant_get(value, "b", &property_flag);
 
                address = g_malloc0(BT_ADDRESS_STRING_SIZE);
-               if (address == NULL)
-                       return;
 
                _bt_convert_device_path_to_address(path, address);
                _bt_convert_addr_string_to_type(bd_addr.addr, address);
@@ -2691,13 +2670,8 @@ static  void __bt_manager_event_filter(GDBusConnection *connection,
                                                _bt_is_le_scanning() == FALSE);
 
                                cache_info = g_malloc0(sizeof(bt_cache_info_t));
-                               ret_if(cache_info == NULL);
 
                                dev_info = g_malloc0(sizeof(bt_remote_dev_info_t));
-                               if (dev_info == NULL) {
-                                       __bt_free_cache_info(cache_info);
-                                       return;
-                               }
 
                                cache_info->dev_info = dev_info;
 
index 150a1f0..a747ad5 100644 (file)
@@ -112,8 +112,6 @@ gboolean _gap_agent_register_osp_server(GapAgentPrivate *agent,
                return FALSE;
 
        server = g_malloc0(sizeof(bt_agent_osp_server_t));
-       retv_if(server == NULL, FALSE);
-
        server->type = type;
        if (type == BT_RFCOMM_SERVER) {
                server->uuid = g_strdup(uuid);
index b691f5a..ee5949a 100644 (file)
@@ -179,9 +179,6 @@ int _bt_hid_connect(int request_id,
        _bt_convert_addr_type_to_string(address, device_address->addr);
 
        func_data = g_malloc0(sizeof(bt_function_data_t));
-       /* Fix : NULL_RETURNS */
-       retv_if(func_data == NULL, BLUETOOTH_ERROR_MEMORY_ALLOCATION);
-
        func_data->address = g_strdup(address);
        func_data->req_id = request_id;
        uuid = HID_UUID;
@@ -218,9 +215,6 @@ int _bt_hid_disconnect(int request_id,
        _bt_convert_addr_type_to_string(address, device_address->addr);
 
        func_data = g_malloc0(sizeof(bt_function_data_t));
-       /* Fix : NULL_RETURNS */
-       retv_if(func_data == NULL, BLUETOOTH_ERROR_MEMORY_ALLOCATION);
-
        func_data->address = g_strdup(address);
        func_data->req_id = request_id;
 
index 3e643b7..18875c7 100644 (file)
@@ -416,8 +416,6 @@ int _bt_network_connect(int request_id, int role,
        g_variant_unref(result);
        retv_if(profile_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
        func_data = g_malloc0(sizeof(bt_function_data_t));
-       retv_if(func_data == NULL, BLUETOOTH_ERROR_MEMORY_ALLOCATION);
-
        func_data->address = g_strdup(address);
        func_data->req_id = request_id;
 
@@ -481,8 +479,6 @@ int _bt_network_disconnect(int request_id,
        g_variant_unref(result);
        retv_if(profile_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
        func_data = g_malloc0(sizeof(bt_function_data_t));
-       retv_if(func_data == NULL, BLUETOOTH_ERROR_MEMORY_ALLOCATION);
-
        func_data->address = g_strdup(address);
        func_data->req_id = request_id;
 
index 3e83f72..a8d159b 100644 (file)
@@ -812,9 +812,6 @@ int _bt_opp_client_push_files(int request_id, GDBusMethodInvocation *context,
        } else {
                /* Insert data in the queue */
                data = g_malloc0(sizeof(bt_sending_data_t));
-               if (data == NULL)
-                       return BLUETOOTH_ERROR_MEMORY_ALLOCATION;
-
                data->file_path = g_new0(char *, file_count + 1);
                data->address = g_strdup(address);
                data->file_count = file_count;
old mode 100755 (executable)
new mode 100644 (file)
index 681d35c..5fb2214
@@ -86,9 +86,6 @@ int _bt_insert_request_list(int req_id, int service_function,
        request_info_t *info;
 
        info = g_malloc0(sizeof(request_info_t));
-       /* Fix : NULL_RETURNS */
-       retv_if(info == NULL, BLUETOOTH_ERROR_MEMORY_ALLOCATION);
-
        info->req_id = req_id;
        info->service_function = service_function;
        info->context = context;
old mode 100755 (executable)
new mode 100644 (file)
index 10faa97..2719594
@@ -112,11 +112,6 @@ char * get_bd_from_file(char *filename)
        }
 
        buf = g_malloc0(20);
-       /* Fix : NULL_RETURNS */
-       if (buf == NULL) {
-               close(fd);
-               return NULL;
-       }
 
        if (read(fd, buf, 17) < 17) {
                perror("Can't load firmware");