Fix SAM tool violations (GlobalVariable)
[platform/core/connectivity/bluetooth-frwk.git] / bt-oal / oal-hfp.c
index 7e1dee8..941643c 100644 (file)
@@ -136,7 +136,7 @@ oal_status_t hfp_connect(bt_address_t *device_address)
        CHECK_OAL_HF_ENABLED();
        OAL_CHECK_PARAMETER(device_address, return);
 
-       BT_INFO("BT HF Address: %s", bdt_bd2str(device_address, &bdstr));
+       BT_INFO("BT HF Address: %s", bdt_bd2str(device_address, &bdstr) + 12);
        /* Call connect function of Bluedroid*/
        status = blued_hfp_interface->connect((bt_bdaddr_t *)device_address);
        if ((status != BT_STATUS_SUCCESS) && (status != BT_STATUS_DONE)) {
@@ -156,7 +156,7 @@ oal_status_t hfp_disconnect(bt_address_t *device_address)
        CHECK_OAL_HF_ENABLED();
        OAL_CHECK_PARAMETER(device_address, return);
 
-       BT_INFO("BT HF Address: %s", bdt_bd2str(device_address, &bdstr));
+       BT_INFO("BT HF Address: %s", bdt_bd2str(device_address, &bdstr) + 12);
        /* call Disconnect function of Bluedroid */
        status = blued_hfp_interface->disconnect((bt_bdaddr_t *)device_address);
        if ((status != BT_STATUS_SUCCESS) && (status != BT_STATUS_DONE)) {
@@ -176,7 +176,7 @@ oal_status_t hfp_connect_audio(bt_address_t *device_address)
        CHECK_OAL_HF_ENABLED();
        OAL_CHECK_PARAMETER(device_address, return);
 
-       BT_INFO("BT HF Address: %s", bdt_bd2str(device_address, &bdstr));
+       BT_INFO("BT HF Address: %s", bdt_bd2str(device_address, &bdstr) + 12);
        status = blued_hfp_interface->connect_audio((bt_bdaddr_t *)device_address);
 
        if (status != BT_STATUS_SUCCESS) {
@@ -197,7 +197,7 @@ oal_status_t hfp_disconnect_audio(bt_address_t *device_address)
 
        OAL_CHECK_PARAMETER(device_address, return);
 
-       BT_INFO("BT HF Address: %s", bdt_bd2str(device_address, &bdstr));
+       BT_INFO("BT HF Address: %s", bdt_bd2str(device_address, &bdstr) + 12);
        status = blued_hfp_interface->disconnect_audio((bt_bdaddr_t *)device_address);
 
        if (status != BT_STATUS_SUCCESS) {
@@ -212,17 +212,20 @@ static void cb_hfp_connection_state(bthf_connection_state_t state, bt_bdaddr_t *
        int event_type;
        bdstr_t bdstr;
        bt_address_t * event_data = NULL;
-       event_data = g_new0(bt_address_t, 1);
-       memcpy(event_data->addr, bd_addr->address, BT_ADDRESS_BYTES_NUM);
 
        if (bd_addr == NULL) {
                BT_ERR("Address is NULL");
-               if (event_data)
-                       g_free(event_data);
                return;
        }
 
-       BT_INFO("HFP Profile state = [%d],  BT Address = [%s]", state, bdt_bd2str((bt_address_t*)bd_addr, &bdstr));
+       event_data = g_new0(bt_address_t, 1);
+       if (event_data == NULL) {
+               BT_ERR("failed to allocate event_data");
+               return;
+       }
+       memcpy(event_data->addr, bd_addr->address, BT_ADDRESS_BYTES_NUM);
+
+       BT_INFO("HFP Profile state = [%d],  BT Address = [%s]", state, bdt_bd2str((bt_address_t*)bd_addr, &bdstr) + 12);
        switch (state) {
        case BTHF_CONNECTION_STATE_DISCONNECTED: {
                 event_type = OAL_EVENT_HFP_DISCONNECTED;
@@ -242,8 +245,7 @@ static void cb_hfp_connection_state(bthf_connection_state_t state, bt_bdaddr_t *
        }
        default: {
                BT_INFO("Invalid state");
-               if (event_data)
-                       g_free(event_data);
+               g_free(event_data);
                return;
        }
        }
@@ -255,16 +257,20 @@ static void cb_hfp_audio_connection_state(bthf_audio_state_t state, bt_bdaddr_t
        int event_type;
        bdstr_t bdstr;
        bt_address_t * event_data = NULL;
-       event_data = g_new0(bt_address_t, 1);
-       memcpy(event_data->addr, bd_addr->address, BT_ADDRESS_BYTES_NUM);
 
        if (bd_addr == NULL) {
                BT_ERR("Address is NULL");
-               if (event_data)
-                       g_free(event_data);
                return;
        }
-       BT_INFO("HFP Audio state = [%d],  BT Address = [%s]", state, bdt_bd2str((bt_address_t*)bd_addr, &bdstr));
+
+       event_data = g_new0(bt_address_t, 1);
+       if (event_data == NULL) {
+               BT_ERR("failed to allocate event_data");
+               return;
+       }
+       memcpy(event_data->addr, bd_addr->address, BT_ADDRESS_BYTES_NUM);
+
+       BT_INFO("HFP Audio state = [%d],  BT Address = [%s]", state, bdt_bd2str((bt_address_t*)bd_addr, &bdstr) + 12);
 
        switch (state) {
        case BTHF_AUDIO_STATE_DISCONNECTED: {
@@ -289,8 +295,7 @@ static void cb_hfp_audio_connection_state(bthf_audio_state_t state, bt_bdaddr_t
        }
        default: {
                BT_INFO("Invalid state");
-               if (event_data)
-                       g_free(event_data);
+               g_free(event_data);
                return;
        }
        }