Code optimize
[platform/core/connectivity/bluetooth-frwk.git] / bt-service / bt-service-event-receiver.c
index 0e65149..53af13b 100644 (file)
@@ -2161,8 +2161,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,
@@ -2170,6 +2168,11 @@ void _bt_handle_device_event(GVariant *msg, const char *member, const char *path
                                                &le_dev_info->rssi,
                                                &le_dev_info->adv_data_len,
                                                &value);
+               if (value == NULL) {
+                       _bt_free_le_device_info(le_dev_info);
+                       return;
+               }
+
                _bt_convert_device_path_to_address(path, le_dev_info->address);
 
                buffer_len = g_variant_get_size(value);
@@ -2193,21 +2196,13 @@ 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);
-                       }
+                       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,