components/bt: Fix warning when disable debug logs or in release mode and improve the code structure

This commit is contained in:
baohongde 2019-03-26 14:59:58 +08:00
parent 286202caa3
commit bbdb236ab7
15 changed files with 54 additions and 26 deletions

View file

@ -1268,7 +1268,7 @@ BOOLEAN bta_av_hdl_event(BT_HDR *p_msg)
** Returns char *
**
*******************************************************************************/
static char *bta_av_st_code(UINT8 state)
UNUSED_ATTR static char *bta_av_st_code(UINT8 state)
{
switch (state) {
case BTA_AV_INIT_ST: return "INIT";

View file

@ -28,6 +28,7 @@
#include <string.h>
#include "bta/bta_av_co.h"
#include "bta_av_int.h"
#include "osi/osi.h"
/*****************************************************************************
** Constants and types
@ -564,7 +565,7 @@ void bta_av_set_scb_sst_incoming (tBTA_AV_SCB *p_scb)
** Returns char *
**
*******************************************************************************/
static char *bta_av_sst_code(UINT8 state)
UNUSED_ATTR static char *bta_av_sst_code(UINT8 state)
{
switch (state) {
case BTA_AV_INIT_SST: return "INIT";

View file

@ -5777,6 +5777,8 @@ void bta_dm_proc_open_evt(tBTA_GATTC_OPEN *p_data)
((p2[0]) << 24) + ((p2[1]) << 16) + ((p2[2]) << 8) + (p2[3]),
((p2[4]) << 8) + p2[5]);
UNUSED(p1);
UNUSED(p2);
APPL_TRACE_DEBUG("BTA_GATTC_OPEN_EVT conn_id = %d client_if=%d status = %d" ,
p_data->conn_id,
p_data->client_if,

View file

@ -1159,6 +1159,7 @@ static char *bta_hf_client_skip_unknown(char *buffer)
buffer = tmp + 2;
APPL_TRACE_DEBUG("%s %.*s", __FUNCTION__, buffer - start - 2, start);
UNUSED(start);
return buffer;
}

View file

@ -308,6 +308,7 @@ static void bta_hf_client_sco_disc_cback(UINT16 sco_idx)
#if (BTM_SCO_HCI_INCLUDED == TRUE )
tBTM_STATUS status = BTM_ConfigScoPath(BTM_SCO_ROUTE_PCM, NULL, NULL, TRUE);
APPL_TRACE_DEBUG("%s close config status = %d", __FUNCTION__, status);
UNUSED(status);
/* SCO clean up here */
bta_hf_client_sco_co_close();
#endif

View file

@ -26,6 +26,7 @@
#include <stdlib.h>
#include "osi/allocator.h"
#include "osi/osi.h"
#include "stack/bt_types.h"
#include "bta/utl.h"
#include "bta/bta_sys.h"
@ -137,7 +138,7 @@ UINT8 bta_jv_alloc_sec_id(void)
return ret;
}
static int get_sec_id_used(void)
UNUSED_ATTR static int get_sec_id_used(void)
{
int i;
int used = 0;
@ -146,12 +147,13 @@ static int get_sec_id_used(void)
used++;
}
}
if (used == BTA_JV_NUM_SERVICE_ID)
if (used == BTA_JV_NUM_SERVICE_ID) {
APPL_TRACE_ERROR("get_sec_id_used, sec id exceeds the limit:%d",
BTA_JV_NUM_SERVICE_ID);
}
return used;
}
static int get_rfc_cb_used(void)
UNUSED_ATTR static int get_rfc_cb_used(void)
{
int i;
int used = 0;
@ -160,9 +162,10 @@ static int get_rfc_cb_used(void)
used++;
}
}
if (used == BTA_JV_MAX_RFC_CONN)
if (used == BTA_JV_MAX_RFC_CONN) {
APPL_TRACE_ERROR("get_sec_id_used, rfc ctrl block exceeds the limit:%d",
BTA_JV_MAX_RFC_CONN);
}
return used;
}
@ -474,19 +477,21 @@ static tBTA_JV_STATUS bta_jv_free_set_pm_profile_cb(UINT32 jv_handle)
< BTA_JV_MAX_RFC_SR_SESSION && bta_jv_cb.rfc_cb[hi].rfc_hdl[si]) {
tBTA_JV_PCB *p_pcb = bta_jv_rfc_port_to_pcb(bta_jv_cb.rfc_cb[hi].rfc_hdl[si]);
if (p_pcb) {
if (NULL == p_pcb->p_pm_cb)
if (NULL == p_pcb->p_pm_cb) {
APPL_TRACE_WARNING("%s(jv_handle:"
" 0x%x):port_handle: 0x%x, p_pm_cb: %d: no link to "
"pm_cb?", __func__, jv_handle, p_pcb->port_handle, i);
}
p_cb = &p_pcb->p_pm_cb;
}
}
} else {
if (jv_handle < BTA_JV_MAX_L2C_CONN) {
tBTA_JV_L2C_CB *p_l2c_cb = &bta_jv_cb.l2c_cb[jv_handle];
if (NULL == p_l2c_cb->p_pm_cb)
if (NULL == p_l2c_cb->p_pm_cb) {
APPL_TRACE_WARNING("%s(jv_handle: "
"0x%x): p_pm_cb: %d: no link to pm_cb?", __func__, jv_handle, i);
}
p_cb = &p_l2c_cb->p_pm_cb;
}
}
@ -998,6 +1003,9 @@ static bool create_base_record(const uint32_t sdp_handle, const char *name, cons
APPL_TRACE_DEBUG("create_base_record: successfully created base service "
"record, handle: 0x%08x, scn: %d, name: %s, with_obex: %d",
sdp_handle, channel, name, with_obex);
UNUSED(stage);
return TRUE;
}
@ -1031,6 +1039,8 @@ static int add_spp_sdp(const char *name, const int channel) {
APPL_TRACE_DEBUG("add_spp_sdp: service registered successfully, "
"service_name: %s, handle 0x%08x)", name, handle);
UNUSED(stage);
return handle;
}
@ -1523,6 +1533,7 @@ static int bta_jv_port_data_co_cback(UINT16 port_handle, UINT8 *buf, UINT16 len,
tBTA_JV_PCB *p_pcb = bta_jv_rfc_port_to_pcb(port_handle);
int ret = 0;
APPL_TRACE_DEBUG("%s, p_cb:%p, p_pcb:%p, len:%d, type:%d", __func__, p_cb, p_pcb, len, type);
UNUSED(p_cb);
if (p_pcb != NULL) {
switch (type) {
case DATA_CO_CALLBACK_TYPE_INCOMING:

View file

@ -615,6 +615,7 @@ static void btc_a2dp_sink_handle_decoder_reset(tBTC_MEDIA_SINK_CFG_UPDATE *p_msg
int frames_to_process = ((freq_multiple) / (num_blocks * num_subbands)) + 1;
APPL_TRACE_EVENT(" Frames to be processed in 20 ms %d\n", frames_to_process);
UNUSED(frames_to_process);
}
/*******************************************************************************

View file

@ -495,10 +495,11 @@ static UINT64 time_now_us()
static void log_tstamps_us(char *comment)
{
static UINT64 prev_us = 0;
const UINT64 now_us = time_now_us();
UINT64 now_us = time_now_us();
APPL_TRACE_DEBUG("[%s] ts %08llu, diff : %08llu, queue sz %d", comment, now_us, now_us - prev_us,
fixed_queue_length(btc_aa_src_cb.TxAaQ));
prev_us = now_us;
UNUSED(prev_us);
}
/* when true media task discards any tx frames */

View file

@ -1199,10 +1199,13 @@ static void bte_av_media_callback(tBTA_AV_EVT event, tBTA_AV_MEDIA *p_data)
BTC_TRACE_ERROR("ERROR dump_codec_info A2D_ParsSbcInfo fail:%d\n", a2d_status);
}
}
UNUSED(que_len);
}
#else
static void bte_av_media_callback(tBTA_AV_EVT event, tBTA_AV_MEDIA *p_data)
{
UNUSED(event);
UNUSED(p_data);
BTC_TRACE_WARNING("%s : event %u\n", __func__, event);
}
#endif

View file

@ -335,6 +335,8 @@ static void handle_rc_passthrough_rsp ( tBTA_AV_REMOTE_RSP *p_remote_rsp)
} else {
BTC_TRACE_ERROR("%s DUT does not support AVRCP controller role", __FUNCTION__);
}
UNUSED(status);
#else
BTC_TRACE_ERROR("%s AVRCP controller role is not enabled", __FUNCTION__);
#endif

View file

@ -713,14 +713,14 @@ static void process_ind_evt(tBTA_HF_CLIENT_IND *ind)
{
esp_hf_client_cb_param_t param;
memset(&param, 0, sizeof(esp_hf_client_cb_param_t));
switch (ind->type)
{
case BTA_HF_CLIENT_IND_CALL:
param.call.status = ind->value;
btc_hf_client_cb_to_app(ESP_HF_CLIENT_CIND_CALL_EVT, &param);
break;
case BTA_HF_CLIENT_IND_CALLSETUP:
param.call_setup.status = ind->value;
btc_hf_client_cb_to_app(ESP_HF_CLIENT_CIND_CALL_SETUP_EVT, &param);
@ -787,6 +787,7 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
{
BTC_TRACE_WARNING("%s: HF CLient open failed, but another device connected. status=%d state=%d connected device=%s",
__FUNCTION__, p_data->open.status, btc_hf_client_cb.state, bdaddr_to_string(&btc_hf_client_cb.connected_bda, bdstr, sizeof(bdstr)));
UNUSED(bdstr);
break;
}
@ -795,13 +796,13 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
param.conn_stat.state = btc_hf_client_cb.state;
param.conn_stat.peer_feat = 0;
param.conn_stat.chld_feat = 0;
memcpy(param.conn_stat.remote_bda, &btc_hf_client_cb.connected_bda,
sizeof(esp_bd_addr_t));
btc_hf_client_cb_to_app(ESP_HF_CLIENT_CONNECTION_STATE_EVT, &param);
} while (0);
if (btc_hf_client_cb.state == ESP_HF_CLIENT_CONNECTION_STATE_DISCONNECTED)
bdsetany(btc_hf_client_cb.connected_bda.address);
@ -820,13 +821,13 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
param.conn_stat.state = btc_hf_client_cb.state;
param.conn_stat.peer_feat = btc_hf_client_cb.peer_feat;
param.conn_stat.chld_feat = btc_hf_client_cb.chld_feat;
memcpy(param.conn_stat.remote_bda, &btc_hf_client_cb.connected_bda,
sizeof(esp_bd_addr_t));
btc_hf_client_cb_to_app(ESP_HF_CLIENT_CONNECTION_STATE_EVT, &param);
} while (0);
/* Inform the application about in-band ringtone */
if (btc_hf_client_cb.peer_feat & BTA_HF_CLIENT_PEER_INBAND)
{
@ -839,7 +840,7 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
btc_queue_advance();
break;
case BTA_HF_CLIENT_CLOSE_EVT:
btc_hf_client_cb.state = ESP_HF_CLIENT_CONNECTION_STATE_DISCONNECTED;
do {
@ -847,7 +848,7 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
param.conn_stat.state = ESP_HF_CLIENT_CONNECTION_STATE_DISCONNECTED;
param.conn_stat.peer_feat = 0;
param.conn_stat.chld_feat = 0;
memcpy(param.conn_stat.remote_bda, &btc_hf_client_cb.connected_bda,
sizeof(esp_bd_addr_t));
@ -980,7 +981,7 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
memset(&param, 0, sizeof(esp_hf_client_cb_param_t));
param.audio_stat.state = ESP_HF_CLIENT_AUDIO_STATE_CONNECTED;
memcpy(param.audio_stat.remote_bda, &btc_hf_client_cb.connected_bda,
sizeof(esp_bd_addr_t));
sizeof(esp_bd_addr_t));
btc_hf_client_cb_to_app(ESP_HF_CLIENT_AUDIO_STATE_EVT, &param);
} while (0);
break;
@ -989,7 +990,7 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
memset(&param, 0, sizeof(esp_hf_client_cb_param_t));
param.audio_stat.state = ESP_HF_CLIENT_AUDIO_STATE_CONNECTED_MSBC;
memcpy(param.audio_stat.remote_bda, &btc_hf_client_cb.connected_bda,
sizeof(esp_bd_addr_t));
sizeof(esp_bd_addr_t));
btc_hf_client_cb_to_app(ESP_HF_CLIENT_AUDIO_STATE_EVT, &param);
} while (0);
break;

View file

@ -345,8 +345,10 @@ UINT8 *avdt_scb_hdl_report(tAVDT_SCB *p_scb, UINT8 *p, UINT16 len)
p += 2;
BE_STREAM_TO_UINT32(ssrc, p);
UNUSED(ssrc);
UNUSED(o_p);
UNUSED(o_v);
UNUSED(o_cc);
switch (pt) {
case AVDT_RTCP_PT_SR: /* the packet type - SR (Sender Report) */

View file

@ -120,10 +120,11 @@ BOOLEAN avrc_is_valid_player_attrib_value(UINT8 attrib, UINT8 value)
result = TRUE;
}
if (!result)
if (!result) {
AVRC_TRACE_ERROR(
"avrc_is_valid_player_attrib_value() found not matching attrib(x%x)-value(x%x) pair!",
attrib, value);
}
return result;
}

View file

@ -94,7 +94,7 @@ void gatt_free_pending_ind(tGATT_TCB *p_tcb)
if (p_tcb->pending_ind_q == NULL) {
return;
}
/* release all queued indications */
while (!fixed_queue_is_empty(p_tcb->pending_ind_q)) {
osi_free(fixed_queue_try_dequeue(p_tcb->pending_ind_q));
@ -118,7 +118,7 @@ void gatt_free_pending_enc_queue(tGATT_TCB *p_tcb)
if (p_tcb->pending_enc_clcb == NULL) {
return;
}
/* release all queued indications */
while (!fixed_queue_is_empty(p_tcb->pending_enc_clcb)) {
osi_free(fixed_queue_try_dequeue(p_tcb->pending_enc_clcb));
@ -387,7 +387,7 @@ tGATT_HDL_LIST_ELEM *gatt_find_hdl_buffer_by_attr_handle(UINT16 attr_handle)
p_list = p_list_info->p_first;
while (p_list != NULL) {
if (p_list->in_use && (p_list->asgn_range.s_handle <= attr_handle)
if (p_list->in_use && (p_list->asgn_range.s_handle <= attr_handle)
&& (p_list->asgn_range.e_handle >= attr_handle)) {
return (p_list);
}
@ -2192,9 +2192,10 @@ void gatt_end_operation(tGATT_CLCB *p_clcb, tGATT_STATUS status, void *p_data)
(*p_disc_cmpl_cb)(conn_id, disc_type, status);
} else if (p_cmpl_cb && op) {
(*p_cmpl_cb)(conn_id, op, status, &cb_data);
} else
} else {
GATT_TRACE_WARNING ("gatt_end_operation not sent out op=%d p_disc_cmpl_cb:%p p_cmpl_cb:%p",
operation, p_disc_cmpl_cb, p_cmpl_cb);
}
}
/*******************************************************************************

View file

@ -395,7 +395,6 @@ static void process_l2cap_cmd (tL2C_LCB *p_lcb, UINT8 *p, UINT16 pkt_len)
STREAM_TO_UINT16 (rej_mtu, p);
/* What to do with the MTU reject ? We have negotiated an MTU. For now */
/* we will ignore it and let a higher protocol timeout take care of it */
L2CAP_TRACE_WARNING ("L2CAP - MTU rej Handle: %d MTU: %d", p_lcb->handle, rej_mtu);
}
if (rej_reason == L2CAP_CMD_REJ_INVALID_CID) {
@ -758,6 +757,7 @@ static void process_l2cap_cmd (tL2C_LCB *p_lcb, UINT8 *p, UINT16 pkt_len)
}
}
UNUSED(rej_mtu);
}
#endif ///CLASSIC_BT_INCLUDED == TRUE
@ -880,7 +880,7 @@ void l2c_free(void)
l2cb.rcv_pending_q = NULL;
#if L2C_DYNAMIC_MEMORY
FREE_AND_RESET(l2c_cb_ptr);
#endif
#endif
}
/*******************************************************************************