Enhance debug message
[platform/core/connectivity/bluetooth-frwk.git] / bt-service / bt-service-audio.c
index 52856c4..7dd091c 100644 (file)
@@ -406,7 +406,7 @@ static int __bt_is_headset_connected(int type, int req_id,
                return BLUETOOTH_ERROR_NOT_CONNECTED;
 #endif
 
-       /* Convert BD adress from string type */
+       /* Convert BD address from string type */
        _bt_convert_addr_string_to_type(device_address.addr, connected_address);
        int value = BLUETOOTH_ERROR_NONE;
        value = _bt_audio_disconnect(0, connected_device->type & type, &device_address, NULL);
@@ -463,9 +463,9 @@ int __bt_is_headset_disconnecting(int type)
        node = g_list_first(g_connected_list);
        while (node != NULL) {
                connected_device = node->data;
-               if (connected_device->device_state == BT_STATE_DISCONNECTING) {
+               if (connected_device->device_state == BT_STATE_DISCONNECTING)
                        return BLUETOOTH_ERROR_CONNECTION_BUSY;
-               }
+
                node = g_list_next(node);
        }
 
@@ -513,11 +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))
@@ -608,7 +603,7 @@ static gboolean __bt_device_support_uuid(char *remote_address,
        int size;
        int i;
        int j;
-       bluetooth_device_info_t info;
+       bluetooth_device_info_t *info;
        char bond_address[BT_ADDRESS_STRING_SIZE] = { 0 };
        gboolean ret = FALSE;
 
@@ -620,23 +615,23 @@ static gboolean __bt_device_support_uuid(char *remote_address,
        size = (dev_list->len) / sizeof(bluetooth_device_info_t);
 
        for (i = 0; i < size; i++) {
-               info = g_array_index(dev_list, bluetooth_device_info_t, i);
+               info = &g_array_index(dev_list, bluetooth_device_info_t, i);
                _bt_convert_addr_type_to_string(bond_address,
-                               info.device_address.addr);
+                               info->device_address.addr);
                if (strcmp(bond_address, remote_address) != 0)
                        continue;
 
                BT_INFO("Device address Matched");
                j = 0;
-               while (j != info.service_index) {
+               while (j != info->service_index) {
                        if (type == BT_AUDIO_HSP) {
-                               if (strcmp(info.uuids[j], HFP_HS_UUID) == 0) {
+                               if (strcmp(info->uuids[j], HFP_HS_UUID) == 0) {
                                        BT_INFO("HFP HS UUID exists");
                                        ret = TRUE;
                                        goto end;
                                }
                        } else if (type == BT_AUDIO_A2DP) {
-                               if (strcmp(info.uuids[j], A2DP_SINK_UUID) == 0) {
+                               if (strcmp(info->uuids[j], A2DP_SINK_UUID) == 0) {
                                        BT_INFO("A2DP SINK UUID exists");
                                        ret = TRUE;
                                        goto end;
@@ -697,11 +692,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;
@@ -842,12 +832,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 +972,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 +1031,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);
@@ -1194,7 +1166,7 @@ static int __bt_auto_connect_alarm_cb(alarm_id_t alarm_id, void* user_param)
        BT_DBG("result [%d]", result);
 
        if (auto_connect_timer.retry_count <= 0) {
-               BT_INFO("Stopping Auto connect retry");
+               BT_INFO(" ### Stopping Auto connect retry");
                auto_connect_timer.alarm_id = 0;
        } else {
                result = _bt_service_set_alarm(BT_AUTO_CONNECT_TIMEOUT_AFTER_LINKLOSS,
@@ -1238,16 +1210,16 @@ int _bt_audio_start_auto_connect(gboolean linkloss_flag)
                                                BT_AUTO_CONNECT_TIMEOUT_AFTER_LINKLOSS;
 
        if (linkloss_flag) {
-               BT_INFO("Start auto connection after linkloss");
+               BT_INFO(" ### Start auto connection after linkloss");
                result = _bt_service_set_alarm(BT_AUTO_CONNECT_TIMEOUT_AFTER_LINKLOSS,
                                                __bt_auto_connect_alarm_cb, NULL, &alarm_id);
-               if (result != BLUETOOTH_ERROR_NONE) {
+               if (result != BLUETOOTH_ERROR_NONE)
                        g_timeout_add(500, (GSourceFunc)__bt_audio_alarm_retry_cb, NULL);
-               } else {
+               else
                        auto_connect_timer.alarm_id = alarm_id;
-               }
+
        } else {
-               BT_INFO("Start auto connection after BT activated");
+               BT_INFO(" ### Start auto connection after BT activated");
                result = _bt_service_set_alarm(BT_AUTO_CONNECT_TIMEOUT_AFTER_BT_ACTIVATED,
                                                __bt_auto_connect_alarm_cb, NULL, &alarm_id);
                if (result == BLUETOOTH_ERROR_NONE)