Fix svace issue(40981)
[platform/core/connectivity/bluetooth-frwk.git] / bt-oal / bluez_hal / src / bt-hal-gatt-client.c
index cc5b5b8..6f3daca 100644 (file)
@@ -248,11 +248,6 @@ static hal_gatt_client_app *__hal_gattc_add_client_app(bt_uuid_t *app_uuid)
 
        //add client app
        gattc_app = g_malloc0(sizeof(hal_gatt_client_app));
-       if (gattc_app == NULL) {
-               DBG("Failed to allocate memory");
-               return NULL;
-       }
-
        gattc_app->client_if = __hal_generate_client_id();
        memcpy(&gattc_app->app_uuid, app_uuid, sizeof(bt_uuid_t));
 
@@ -276,11 +271,6 @@ static bt_status_t __hal_gattc_register_client_app(bt_uuid_t *app_uuid)
 
        /*send event */
        client_app_info = g_malloc0(sizeof(hal_gatt_client_app));
-       if (NULL == client_app_info) {
-               ERR("Failed to allocate memory");
-               return BT_STATUS_FAIL;
-       }
-
        client_app_info->client_if = gattc_app->client_if;
        memcpy(&client_app_info->app_uuid, app_uuid, sizeof(bt_uuid_t));
        g_idle_add(__bt_hal_register_client_cb, (gpointer)client_app_info);
@@ -476,12 +466,6 @@ bt_status_t _hal_gattc_disconnect(int client_if, const bt_bdaddr_t *bd_addr,
        }
 
        gattc_data = g_malloc0(sizeof(hal_gattc_client_info_t));
-       if (NULL == gattc_data) {
-               ERR("Unable to allocate memory");
-               ret = BT_STATUS_FAIL;
-               goto fail;
-       }
-
        memcpy(gattc_data->bd_addr.address, bd_addr->address,
                        BT_HAL_ADDRESS_LENGTH_MAX);
        gattc_data->client_if = client_if;
@@ -1498,11 +1482,6 @@ static bt_status_t _hal_read_characteristic_value(int conn_id, btgatt_srvc_id_t
        }
 
        resp_data = g_malloc0(sizeof(hal_gatt_resp_data_t));
-       if (NULL == resp_data) {
-               ERR("failed to get the memory");
-               return BT_STATUS_FAIL;
-       }
-
        resp_data->conn_id = conn_id;
        memcpy(&resp_data->srvc_id, srvc_id, sizeof(btgatt_srvc_id_t));
        memcpy(&resp_data->char_id, char_id, sizeof(btgatt_gatt_id_t));
@@ -1779,11 +1758,6 @@ static bt_status_t _hal_write_characteristic_value(int conn_id, btgatt_srvc_id_t
        }
 
        resp_data = g_malloc0(sizeof(hal_gatt_resp_data_t));
-       if (NULL == resp_data) {
-               ERR("failed to get the memory");
-               return BT_STATUS_FAIL;
-       }
-
        resp_data->conn_id = conn_id;
        memcpy(&resp_data->srvc_id, srvc_id, sizeof(btgatt_srvc_id_t));
        memcpy(&resp_data->char_id, char_id, sizeof(btgatt_gatt_id_t));
@@ -2104,11 +2078,6 @@ static bt_status_t _hal_read_descriptor_value(int conn_id, btgatt_srvc_id_t *srv
        }
 
        resp_data = g_malloc0(sizeof(hal_gatt_resp_data_t));
-       if (NULL == resp_data) {
-               ERR("failed to get the memory");
-               return BT_STATUS_FAIL;
-       }
-
        resp_data->conn_id = conn_id;
        memcpy(&resp_data->srvc_id, srvc_id, sizeof(btgatt_srvc_id_t));
        memcpy(&resp_data->char_id, char_id, sizeof(btgatt_gatt_id_t));
@@ -2289,11 +2258,6 @@ static bt_status_t _hal_write_descriptor_value(int conn_id, btgatt_srvc_id_t *sr
        }
 
        resp_data = g_malloc0(sizeof(hal_gatt_resp_data_t));
-       if (NULL == resp_data) {
-               ERR("failed to get the memory");
-               return BT_STATUS_FAIL;
-       }
-
        resp_data->conn_id = conn_id;
        memcpy(&resp_data->srvc_id, srvc_id, sizeof(btgatt_srvc_id_t));
        memcpy(&resp_data->char_id, char_id, sizeof(btgatt_gatt_id_t));
@@ -2448,11 +2412,7 @@ static bt_status_t _hal_register_for_notification(int client_if,
                return BT_STATUS_FAIL;
        }
 
-       resp_data = malloc(sizeof(hal_gatt_resp_data_t));
-       if (NULL == resp_data) {
-               ERR("failed to get the memory");
-               return BT_STATUS_FAIL;
-       }
+       resp_data = g_malloc0(sizeof(hal_gatt_resp_data_t));
 
        DBG("#StartNotify");
        g_dbus_connection_call_sync(g_conn,
@@ -2613,11 +2573,7 @@ static bt_status_t _hal_deregister_for_notification(int client_if,
                return BT_STATUS_FAIL;
        }
 
-       resp_data = malloc(sizeof(hal_gatt_resp_data_t));
-       if (NULL == resp_data) {
-               ERR("failed to get the memory");
-               return BT_STATUS_FAIL;
-       }
+       resp_data = g_malloc0(sizeof(hal_gatt_resp_data_t));
 
        DBG("#StartNotify");
        g_dbus_connection_call_sync(g_conn,
@@ -3021,11 +2977,6 @@ static bt_status_t __bt_connect_le_device_internal(int client_if, const bt_bdadd
        }
 
        gattc_data = g_malloc0(sizeof(hal_gattc_client_info_t));
-       if (gattc_data == NULL) {
-               ERR("Unable to allocate memory");
-               ret = BT_STATUS_NOMEM;
-               goto fail;
-       }
        memcpy(gattc_data->bd_addr.address, bd_addr->address,
                                        BT_HAL_ADDRESS_LENGTH_MAX);
 
@@ -3159,11 +3110,6 @@ static void __le_connection_req_cb(GDBusProxy *proxy, GAsyncResult *res,
 
        /*add gatt server connection info*/
        gatt_conn_info = g_malloc0(sizeof(hal_gattc_server_info_t));
-       if (gatt_conn_info == NULL) {
-               ERR("Failed to allocate memory");
-               goto fail;
-       }
-
        memcpy(gatt_conn_info->bd_addr.address, gattc_data->bd_addr.address, BT_HAL_ADDRESS_LENGTH_MAX);
        gatt_conn_info->inst_id = gattc_data->inst_id;
        hal_gattc_server_info_list = g_slist_append(hal_gattc_server_info_list, gatt_conn_info);