From cab5fc179730ce6910989307680b275195876c4d Mon Sep 17 00:00:00 2001 From: Arman Uguray Date: Tue, 2 Jun 2015 14:56:45 -0700 Subject: [PATCH] gn-build: Remove all -Wno-unused-* flags from build files This CL removes the -Wno-unused-variable, -Wno-unused-value, and -Wno-unused-function flags from all GN build and Android.mk files (except in test/ & tools/, which are not built using GN yet). Compile warnings, caused by the newly enabled flags, have been fixed throughout the code base. Bug: 21570302 Change-Id: I1c128b62256faa17668124798341005bcd0f7315 --- Android.mk | 1 - audio_a2dp_hw/BUILD.gn | 5 --- audio_a2dp_hw/audio_a2dp_hw.c | 16 +++------- bta/BUILD.gn | 3 -- bta/av/bta_av_main.c | 19 ------------ bta/dm/bta_dm_act.c | 3 -- bta/dm/bta_dm_pm.c | 1 - bta/hl/bta_hl_sdp.c | 2 +- bta/hl/bta_hl_utils.c | 2 -- bta/jv/bta_jv_act.c | 54 --------------------------------- bta/sdp/bta_sdp_act.c | 8 ----- btif/BUILD.gn | 3 -- btif/co/bta_hh_co.c | 2 -- btif/src/btif_hl.c | 22 ++------------ btif/src/btif_sdp.c | 1 - btif/src/btif_sdp_server.c | 1 - btif/src/btif_sock_l2cap.c | 25 --------------- btif/src/btif_storage.c | 1 - hci/BUILD.gn | 4 --- main/BUILD.gn | 3 -- stack/BUILD.gn | 3 -- stack/a2dp/a2d_sbc.c | 5 +-- stack/btm/btm_ble.c | 57 ----------------------------------- stack/btm/btm_ble_gap.c | 6 ++-- stack/btm/btm_dev.c | 1 - stack/btm/btm_devctl.c | 3 -- stack/btm/btm_sec.c | 34 --------------------- stack/gap/gap_conn.c | 6 ++-- stack/gatt/gatt_attr.c | 1 - stack/hid/hidh_conn.c | 1 - stack/include/l2c_api.h | 4 +-- stack/l2cap/l2c_ble.c | 8 +++-- 32 files changed, 22 insertions(+), 283 deletions(-) diff --git a/Android.mk b/Android.mk index f2d2334e..36b58072 100644 --- a/Android.mk +++ b/Android.mk @@ -22,7 +22,6 @@ bdroid_CFLAGS += -DEXPORT_SYMBOL="__attribute__((visibility(\"default\")))" bdroid_CFLAGS += \ -fvisibility=hidden \ -Wall \ - -Wno-unused-parameter \ -Wunused-but-set-variable \ -UNDEBUG \ -DLOG_NDEBUG=1 diff --git a/audio_a2dp_hw/BUILD.gn b/audio_a2dp_hw/BUILD.gn index b94ce40d..2c5024a4 100644 --- a/audio_a2dp_hw/BUILD.gn +++ b/audio_a2dp_hw/BUILD.gn @@ -24,9 +24,4 @@ shared_library("audio.a2dp.default") { "//", "//utils/include", ] - - # TODO(armansito): Fix the warnings and remove the flag below. - cflags = [ - "-Wno-unused-variable", - ] } diff --git a/audio_a2dp_hw/audio_a2dp_hw.c b/audio_a2dp_hw/audio_a2dp_hw.c index 0d621165..f15ec995 100644 --- a/audio_a2dp_hw/audio_a2dp_hw.c +++ b/audio_a2dp_hw/audio_a2dp_hw.c @@ -199,7 +199,6 @@ static int skt_connect(char *path, size_t buffer_sz) { int ret; int skt_fd; - struct sockaddr_un remote; int len; INFO("connect to %s (sz %zu)", path, buffer_sz); @@ -235,8 +234,6 @@ static int skt_connect(char *path, size_t buffer_sz) static int skt_read(int fd, void *p, size_t len) { int read; - struct pollfd pfd; - struct timespec ts; FNLOG(); @@ -366,7 +363,6 @@ static int check_a2dp_ready(struct a2dp_stream_common *common) static int a2dp_read_audio_config(struct a2dp_stream_common *common) { - char cmd = A2DP_CTRL_GET_AUDIO_CONFIG; uint32_t sample_rate; uint8_t channel_count; @@ -648,8 +644,8 @@ static audio_format_t out_get_format(const struct audio_stream *stream) static int out_set_format(struct audio_stream *stream, audio_format_t format) { + UNUSED(stream); UNUSED(format); - struct a2dp_stream_out *out = (struct a2dp_stream_out *)stream; DEBUG("setting format not yet supported (0x%x)", format); return -ENOSYS; } @@ -674,8 +670,8 @@ static int out_standby(struct audio_stream *stream) static int out_dump(const struct audio_stream *stream, int fd) { + UNUSED(stream); UNUSED(fd); - struct a2dp_stream_out *out = (struct a2dp_stream_out *)stream; FNLOG(); return 0; } @@ -736,9 +732,8 @@ static int out_set_parameters(struct audio_stream *stream, const char *kvpairs) static char * out_get_parameters(const struct audio_stream *stream, const char *keys) { + UNUSED(stream); UNUSED(keys); - struct a2dp_stream_out *out = (struct a2dp_stream_out *)stream; - FNLOG(); /* add populating param here */ @@ -1009,7 +1004,6 @@ static int adev_open_output_stream(struct audio_hw_device *dev, struct a2dp_audio_device *a2dp_dev = (struct a2dp_audio_device *)dev; struct a2dp_stream_out *out; int ret = 0; - int i; UNUSED(address); UNUSED(handle); UNUSED(devices); @@ -1130,8 +1124,7 @@ static char * adev_get_parameters(const struct audio_hw_device *dev, static int adev_init_check(const struct audio_hw_device *dev) { - struct a2dp_audio_device *a2dp_dev = (struct a2dp_audio_device*)dev; - + UNUSED(dev); FNLOG(); return 0; @@ -1312,7 +1305,6 @@ static int adev_open(const hw_module_t* module, const char* name, hw_device_t** device) { struct a2dp_audio_device *adev; - int ret; INFO(" adev_open in A2dp_hw module"); FNLOG(); diff --git a/bta/BUILD.gn b/bta/BUILD.gn index 89a70f74..c4eee0ec 100644 --- a/bta/BUILD.gn +++ b/bta/BUILD.gn @@ -115,9 +115,6 @@ static_library("bta") { # TODO(armansito): Remove all of the flags below, since we want to enable all # warnings. cflags = [ - "-Wno-unused-variable", - "-Wno-unused-value", - "-Wno-unused-function", "-Wno-int-to-pointer-cast", ] diff --git a/bta/av/bta_av_main.c b/bta/av/bta_av_main.c index 9a409292..3552911f 100644 --- a/bta/av/bta_av_main.c +++ b/bta/av/bta_av_main.c @@ -396,25 +396,6 @@ static tBTA_AV_SCB * bta_av_alloc_scb(tBTA_AV_CHNL chnl) return p_ret; } -/******************************************************************************* -** -** Function bta_av_free_scb -** -** Description free stream control block, -** -** -** Returns void -** -*******************************************************************************/ -static void bta_av_free_scb(tBTA_AV_SCB *p_scb) -{ - // NOTE(google) This free currently is not called - assert(p_scb != NULL); - - list_free(p_scb->a2d_list); - GKI_freebuf(p_scb); -} - /******************************************************************************* *******************************************************************************/ void bta_av_conn_cback(UINT8 handle, BD_ADDR bd_addr, UINT8 event, tAVDT_CTRL *p_data) diff --git a/bta/dm/bta_dm_act.c b/bta/dm/bta_dm_act.c index 2b32a4da..0ec5426d 100644 --- a/bta/dm/bta_dm_act.c +++ b/bta/dm/bta_dm_act.c @@ -2077,7 +2077,6 @@ static void bta_dm_find_services ( BD_ADDR bd_addr) { tSDP_UUID uuid; - UINT16 num_attrs = 1; tBTA_DM_MSG *p_msg; memset (&uuid, 0, sizeof(tSDP_UUID)); @@ -4366,8 +4365,6 @@ static UINT8 bta_dm_ble_smp_cback (tBTM_LE_EVT event, BD_ADDR bda, tBTM_LE_EVT_D tBTM_STATUS status = BTM_SUCCESS; tBTA_DM_SEC sec_event; char *p_name = NULL; - UINT8 i; - tBT_DEVICE_TYPE dev_type; if (!bta_dm_cb.p_sec_cback) return BTM_NOT_AUTHORIZED; diff --git a/bta/dm/bta_dm_pm.c b/bta/dm/bta_dm_pm.c index 43c9a5ac..d0615bca 100644 --- a/bta/dm/bta_dm_pm.c +++ b/bta/dm/bta_dm_pm.c @@ -154,7 +154,6 @@ static void bta_dm_pm_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app_id, { UINT8 i,j; - UINT16 policy_setting; UINT8 *p = NULL; #if (BTM_SSR_INCLUDED == TRUE) int index = BTA_DM_PM_SSR0; diff --git a/bta/hl/bta_hl_sdp.c b/bta/hl/bta_hl_sdp.c index f5b3fd1f..f6cb9097 100644 --- a/bta/hl/bta_hl_sdp.c +++ b/bta/hl/bta_hl_sdp.c @@ -50,7 +50,7 @@ BOOLEAN bta_hl_fill_sup_feature_list( const tSDP_DISC_ATTR *p_attr, { return(FALSE); } - SDP_DISC_ATTR_LEN(p_attr->attr_len_type); + item_cnt=0; for (p_sattr = p_attr->attr_value.v.p_sub_attr; p_sattr && (item_cnt < 4) ; p_sattr = p_sattr->p_next_attr) diff --git a/bta/hl/bta_hl_utils.c b/bta/hl/bta_hl_utils.c index 0a0f3267..3fa142b9 100644 --- a/bta/hl/bta_hl_utils.c +++ b/bta/hl/bta_hl_utils.c @@ -1170,8 +1170,6 @@ BOOLEAN bta_hl_find_mcl_idx(UINT8 app_idx, BD_ADDR p_bd_addr, UINT8 *p_mcl_idx) for (i=0; i < BTA_HL_NUM_MCLS ; i ++) { - BTA_HL_GET_MCL_CB_PTR(app_idx, i); - if (bta_hl_cb.acb[app_idx].mcb[i].in_use && (!memcmp (bta_hl_cb.acb[app_idx].mcb[i].bd_addr, p_bd_addr, BD_ADDR_LEN))) { diff --git a/bta/jv/bta_jv_act.c b/bta/jv/bta_jv_act.c index b7ea7516..d79c9726 100644 --- a/bta/jv/bta_jv_act.c +++ b/bta/jv/bta_jv_act.c @@ -75,22 +75,6 @@ struct fc_channel { static struct fc_client *fc_clients; static struct fc_channel *fc_channels; static uint32_t fc_next_id; -static pthread_once_t fc_init_once = PTHREAD_ONCE_INIT; - - -static void fc_init_work(void) -{ - fc_clients = NULL; - fc_channels = NULL; - fc_next_id = 0; - - //more init here if needed... -} - -static void fc_init(void) -{ - pthread_once(&fc_init_once, fc_init_work); -} static void fcchan_conn_chng_cbk(UINT16 chan, BD_ADDR bd_addr, BOOLEAN connected, @@ -543,8 +527,6 @@ static tBTA_JV_PM_CB *bta_jv_alloc_set_pm_profile_cb(UINT32 jv_handle, tBTA_JV_P /* rfc handle bd addr retrieval requires core stack handle */ if (bRfcHandle) { - UINT32 hi = ((jv_handle & BTA_JV_RFC_HDL_MASK) & ~BTA_JV_RFCOMM_MASK) - 1; - UINT32 si = BTA_JV_RFC_HDL_TO_SIDX(jv_handle); for (j = 0; j < BTA_JV_MAX_RFC_CONN; j++) { if (jv_handle == bta_jv_cb.port_cb[j].handle) @@ -869,7 +851,6 @@ static inline tBT_UUID shorten_sdp_uuid(const tBT_UUID* u) static void bta_jv_start_discovery_cback(UINT16 result, void * user_data) { tBTA_JV_STATUS status; - UINT8 old_sdp_act = bta_jv_cb.sdp_active; APPL_TRACE_DEBUG("bta_jv_start_discovery_cback res: 0x%x", result); @@ -1229,7 +1210,6 @@ void bta_jv_l2cap_start_server(tBTA_JV_MSG *p_data) tL2CAP_CFG_INFO cfg; tBTA_JV_L2CAP_START evt_data; tBTA_JV_API_L2CAP_SERVER *ls = &(p_data->l2cap_server); - INT32 use_etm = FALSE; UINT8 chan_mode_mask = GAP_FCR_CHAN_OPT_BASIC; tL2CAP_ERTM_INFO *ertm_info = NULL; @@ -1703,38 +1683,6 @@ void bta_jv_rfcomm_close(tBTA_JV_MSG *p_data) get_sec_id_used(), get_rfc_cb_used()); } -/******************************************************************************* -** -** Function bta_jv_get_num_rfc_listen -** -** Description when a RFCOMM connection goes down, make sure that there's only -** one port stays listening on this scn. -** -** Returns -** -*******************************************************************************/ -static UINT8 bta_jv_get_num_rfc_listen(tBTA_JV_RFC_CB *p_cb) -{ - UINT8 listen=1; - - if (p_cb->max_sess > 1) - { - listen = 0; - for (UINT8 i=0; imax_sess; i++) - { - if (p_cb->rfc_hdl[i] != 0) - { - const tBTA_JV_PCB *p_pcb = &bta_jv_cb.port_cb[p_cb->rfc_hdl[i] - 1]; - if (BTA_JV_ST_SR_LISTEN == p_pcb->state) - { - listen++; - } - } - } - } - return listen; -} - /******************************************************************************* ** ** Function bta_jv_port_mgmt_sr_cback @@ -2555,7 +2503,6 @@ static void fcchan_conn_chng_cbk(UINT16 chan, BD_ADDR bd_addr, BOOLEAN connected static void fcchan_data_cbk(UINT16 chan, BD_ADDR bd_addr, BT_HDR *p_buf) { tBTA_JV evt_data; - tBTA_JV evt_open; struct fc_channel *tc; struct fc_client *t = NULL; tBTA_JV_L2CAP_CBACK *sock_cback = NULL; @@ -2686,7 +2633,6 @@ void bta_jv_l2cap_start_server_le(tBTA_JV_MSG *p_data) tBTA_JV_API_L2CAP_SERVER *ss = &(p_data->l2cap_server); tBTA_JV_L2CAP_START evt_data; struct fc_client *t; - uint16_t handle; evt_data.handle = GAP_INVALID_HANDLE; evt_data.status = BTA_JV_FAILURE; diff --git a/bta/sdp/bta_sdp_act.c b/bta/sdp/bta_sdp_act.c index 63fb5937..ed758296 100644 --- a/bta/sdp/bta_sdp_act.c +++ b/bta/sdp/bta_sdp_act.c @@ -93,11 +93,9 @@ static inline tBT_UUID shorten_sdp_uuid(const tBT_UUID* u) static void bta_create_mns_sdp_record(bluetooth_sdp_record *record, tSDP_DISC_REC *p_rec) { - tSDP_DISCOVERY_DB *db = p_bta_sdp_cfg->p_sdp_db; tSDP_DISC_ATTR *p_attr; tSDP_PROTOCOL_ELEM pe; UINT16 pversion = 0; - UINT8 offset = 0; record->mns.hdr.type = SDP_TYPE_MAP_MNS; record->mns.hdr.service_name_length = 0; record->mns.hdr.service_name = NULL; @@ -140,7 +138,6 @@ static void bta_create_mns_sdp_record(bluetooth_sdp_record *record, tSDP_DISC_RE static void bta_create_mas_sdp_record(bluetooth_sdp_record *record, tSDP_DISC_REC *p_rec) { - tSDP_DISCOVERY_DB *db = p_bta_sdp_cfg->p_sdp_db; tSDP_DISC_ATTR *p_attr; tSDP_PROTOCOL_ELEM pe; UINT16 pversion = -1; @@ -202,7 +199,6 @@ static void bta_create_mas_sdp_record(bluetooth_sdp_record *record, tSDP_DISC_RE static void bta_create_pse_sdp_record(bluetooth_sdp_record *record, tSDP_DISC_REC *p_rec) { - tSDP_DISCOVERY_DB *db = p_bta_sdp_cfg->p_sdp_db; tSDP_DISC_ATTR *p_attr; UINT16 pversion; tSDP_PROTOCOL_ELEM pe; @@ -256,7 +252,6 @@ static void bta_create_pse_sdp_record(bluetooth_sdp_record *record, tSDP_DISC_RE static void bta_create_ops_sdp_record(bluetooth_sdp_record *record, tSDP_DISC_REC *p_rec) { - tSDP_DISCOVERY_DB *db = p_bta_sdp_cfg->p_sdp_db; tSDP_DISC_ATTR *p_attr, *p_sattr; tSDP_PROTOCOL_ELEM pe; UINT16 pversion = -1; @@ -346,9 +341,7 @@ static void bta_create_ops_sdp_record(bluetooth_sdp_record *record, tSDP_DISC_RE static void bta_create_raw_sdp_record(bluetooth_sdp_record *record, tSDP_DISC_REC *p_rec) { - tSDP_DISCOVERY_DB *db = p_bta_sdp_cfg->p_sdp_db; tSDP_DISC_ATTR *p_attr; - UINT16 pversion; tSDP_PROTOCOL_ELEM pe; record->hdr.type = SDP_TYPE_RAW; @@ -391,7 +384,6 @@ static void bta_sdp_search_cback(UINT16 result, void * user_data) tSDP_DISC_REC *p_rec = NULL; tBTA_SDP_SEARCH_COMP evt_data = {0}; // We need to zero-initialize tBTA_SDP_STATUS status = BTA_SDP_FAILURE; - UINT16 uuid16 = 0; int count = 0; tBT_UUID su; APPL_TRACE_DEBUG("bta_sdp_search_cback res: 0x%x", result); diff --git a/btif/BUILD.gn b/btif/BUILD.gn index e544031c..fca504bb 100644 --- a/btif/BUILD.gn +++ b/btif/BUILD.gn @@ -90,9 +90,6 @@ static_library("btif") { # TODO(armansito): Remove all of these flags below. We want to enable all # warnings that we can. cflags = [ - "-Wno-unused-variable", - "-Wno-unused-value", - "-Wno-unused-function", "-Wno-int-to-pointer-cast", ] diff --git a/btif/co/bta_hh_co.c b/btif/co/bta_hh_co.c index b5c845a9..bc4db01a 100644 --- a/btif/co/bta_hh_co.c +++ b/btif/co/bta_hh_co.c @@ -518,8 +518,6 @@ tBTA_HH_RPT_CACHE_ENTRY * bta_hh_le_co_cache_load (BD_ADDR remote_bda, { UNUSED(app_id); - unsigned idx = 0; - bdstr_t bdstr; sprintf(bdstr, "%02x:%02x:%02x:%02x:%02x:%02x", remote_bda[0], remote_bda[1], remote_bda[2], diff --git a/btif/src/btif_hl.c b/btif/src/btif_hl.c index 9d0c0d73..5f320d42 100644 --- a/btif/src/btif_hl.c +++ b/btif/src/btif_hl.c @@ -1214,10 +1214,9 @@ static BOOLEAN btif_hl_find_peer_mdep_id(UINT8 app_id, BD_ADDR bd_addr, if (btif_hl_find_app_idx(app_id, &app_idx) ) { - BTIF_HL_GET_APP_CB_PTR(app_idx); if (btif_hl_find_mcl_idx(app_idx, bd_addr, &mcl_idx)) { - p_mcb =BTIF_HL_GET_MCL_CB_PTR(app_idx, mcl_idx); + p_mcb = BTIF_HL_GET_MCL_CB_PTR(app_idx, mcl_idx); BTIF_TRACE_DEBUG("app_idx=%d mcl_idx=%d",app_idx, mcl_idx); BTIF_TRACE_DEBUG("valid_spd_idx=%d sdp_idx=%d",p_mcb->valid_sdp_idx, p_mcb->sdp_idx); @@ -1227,7 +1226,7 @@ static BOOLEAN btif_hl_find_peer_mdep_id(UINT8 app_id, BD_ADDR bd_addr, num_mdeps = p_rec->num_mdeps; BTIF_TRACE_DEBUG("num_mdeps=%d", num_mdeps); - for (i=0; i< num_mdeps; i++) + for (i = 0; i < num_mdeps; i++) { BTIF_TRACE_DEBUG("p_rec->mdep_cfg[%d].mdep_role=%d",i, p_rec->mdep_cfg[i].mdep_role); BTIF_TRACE_DEBUG("p_rec->mdep_cfg[%d].data_type =%d",i, p_rec->mdep_cfg[i].data_type ); @@ -2592,8 +2591,6 @@ static BOOLEAN btif_hl_proc_cch_open_cfm(tBTA_HL *p_data) BTIF_TRACE_DEBUG("app_idx=%d", app_idx); if (btif_hl_find_mcl_idx(app_idx, p_data->cch_open_cfm.bd_addr, &mcl_idx)) { - BTIF_HL_GET_APP_CB_PTR(app_idx); - p_mcb = BTIF_HL_GET_MCL_CB_PTR(app_idx, mcl_idx); BTIF_TRACE_DEBUG("mcl_idx=%d, mcl_handle=%d", mcl_idx,p_data->cch_open_cfm.mcl_handle); p_mcb->mcl_handle = p_data->cch_open_cfm.mcl_handle; @@ -2779,9 +2776,6 @@ static void btif_hl_proc_dch_open_ind(tBTA_HL *p_data) if (btif_hl_find_mcl_idx_using_app_idx(p_data->dch_open_ind.mcl_handle, orig_app_idx, &mcl_idx )) { - BTIF_HL_GET_APP_CB_PTR(orig_app_idx); - BTIF_HL_GET_MCL_CB_PTR(orig_app_idx, mcl_idx); - if (btif_hl_find_avail_mdl_idx(orig_app_idx, mcl_idx, &mdl_idx)) { p_dcb = BTIF_HL_GET_MDL_CB_PTR(orig_app_idx, mcl_idx, mdl_idx); @@ -2858,8 +2852,6 @@ static BOOLEAN btif_hl_proc_dch_open_cfm(tBTA_HL *p_data) if (btif_hl_find_mcl_idx_using_app_idx(p_data->dch_open_cfm.mcl_handle, app_idx, &mcl_idx )) { - BTIF_HL_GET_APP_CB_PTR(app_idx); - BTIF_HL_GET_MCL_CB_PTR(app_idx, mcl_idx); p_pcb = BTIF_HL_GET_PCB_PTR(app_idx, mcl_idx); if (btif_hl_find_avail_mdl_idx(app_idx, mcl_idx, &mdl_idx)) @@ -2932,8 +2924,6 @@ static BOOLEAN btif_hl_proc_dch_reconnect_cfm(tBTA_HL *p_data) if (btif_hl_find_mcl_idx_using_app_idx(p_data->dch_reconnect_cfm.mcl_handle, app_idx, &mcl_idx )) { - BTIF_HL_GET_APP_CB_PTR(app_idx); - BTIF_HL_GET_MCL_CB_PTR(app_idx, mcl_idx); p_pcb = BTIF_HL_GET_PCB_PTR(app_idx, mcl_idx); if (btif_hl_find_avail_mdl_idx(app_idx, mcl_idx, &mdl_idx)) @@ -3011,7 +3001,6 @@ static void btif_hl_proc_dch_reconnect_ind(tBTA_HL *p_data) p_acb = BTIF_HL_GET_APP_CB_PTR(app_idx); BTIF_TRACE_DEBUG("btif_hl_proc_dch_reconnect_ind: app_idx = %d, mcl_idx = %d", app_idx, mcl_idx); - BTIF_HL_GET_MCL_CB_PTR(app_idx, mcl_idx); if (btif_hl_find_avail_mdl_idx(app_idx, mcl_idx, &mdl_idx)) { @@ -3280,9 +3269,6 @@ static void btif_hl_proc_cb_evt(UINT16 event, char* p_param){ BOOLEAN send_chan_cb=TRUE; tBTA_HL_REG_PARAM reg_param; btif_hl_app_cb_t *p_acb; - bthl_app_reg_state_t reg_state = BTHL_APP_REG_STATE_REG_FAILED; - UINT8 preg_idx; - bt_status_t bt_status; BTIF_TRACE_DEBUG("%s event %d", __FUNCTION__, event); btif_hl_display_calling_process_name(); @@ -4163,7 +4149,6 @@ static bt_status_t unregister_application(int app_id){ if (btif_hl_find_app_idx(((UINT8)app_id), &app_idx)) { evt_param.unreg.app_idx = app_idx; - BTIF_HL_GET_APP_CB_PTR(app_idx); reg_counter --; len = sizeof(btif_hl_unreg_t); status = btif_transfer_context (btif_hl_proc_cb_evt, BTIF_HL_UNREG_APP, @@ -4393,9 +4378,6 @@ BOOLEAN btif_hl_delete_mdl_cfg(UINT8 mdep_id, UINT8 item_idx){ if(btif_hl_find_app_idx_using_mdepId(mdep_id,&app_idx)) { - - BTIF_HL_GET_APP_CB_PTR(app_idx); - p_mdl = BTIF_HL_GET_MDL_CFG_PTR(app_idx, item_idx); if (p_mdl) { diff --git a/btif/src/btif_sdp.c b/btif/src/btif_sdp.c index f7286054..94c11725 100644 --- a/btif/src/btif_sdp.c +++ b/btif/src/btif_sdp.c @@ -147,7 +147,6 @@ static bt_status_t deinit() static bt_status_t search(bt_bdaddr_t *bd_addr, const uint8_t *uuid) { - bdstr_t bdstr; tSDP_UUID sdp_uuid; sdp_uuid.len = 16; memcpy(sdp_uuid.uu.uuid128, uuid, sizeof(sdp_uuid.uu.uuid128)); diff --git a/btif/src/btif_sdp_server.c b/btif/src/btif_sdp_server.c index 567a4c09..d8f45a8c 100644 --- a/btif/src/btif_sdp_server.c +++ b/btif/src/btif_sdp_server.c @@ -185,7 +185,6 @@ void copy_sdp_records(bluetooth_sdp_record* in_records, * user2_ptr. */ static int alloc_sdp_slot(bluetooth_sdp_record* in_record) { int i; - char* tmp_ptr = NULL; int record_size = get_sdp_records_size(in_record, 1); bluetooth_sdp_record* record = osi_malloc(record_size); diff --git a/btif/src/btif_sock_l2cap.c b/btif/src/btif_sock_l2cap.c index d66fea69..7689015a 100644 --- a/btif/src/btif_sock_l2cap.c +++ b/btif/src/btif_sock_l2cap.c @@ -53,9 +53,6 @@ #define asrt(s) if (!(s)) APPL_TRACE_ERROR("## %s assert %s failed at line:%d ##",__FUNCTION__, \ #s, __LINE__) -static pthread_mutex_t slot_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; - - struct packet { struct packet *next, *prev; uint32_t len; @@ -290,13 +287,6 @@ static void btsock_l2cap_free_l(l2cap_socket *sock) osi_free(sock); } -static void btsock_l2cap_free(l2cap_socket *sock) -{ - pthread_mutex_lock(&state_lock); - btsock_l2cap_free_l(sock); - pthread_mutex_unlock(&state_lock); -} - static l2cap_socket *btsock_l2cap_alloc_l(const char *name, const bt_bdaddr_t *addr, char is_server, int flags) { @@ -365,18 +355,6 @@ static l2cap_socket *btsock_l2cap_alloc_l(const char *name, const bt_bdaddr_t *a return NULL; } -static l2cap_socket *btsock_l2cap_alloc(const char *name, const bt_bdaddr_t *addr, - char is_server, int flags) -{ - l2cap_socket *ret; - - pthread_mutex_lock(&state_lock); - ret = btsock_l2cap_alloc_l(name, addr, is_server, flags); - pthread_mutex_unlock(&state_lock); - - return ret; -} - bt_status_t btsock_l2cap_init(int handle) { APPL_TRACE_DEBUG("btsock_l2cap_init..."); @@ -716,7 +694,6 @@ static void on_l2cap_data_ind(tBTA_JV *evt, uint32_t id) } else { - tBTA_JV_DATA_IND *p_data_ind = &evt->data_ind; UINT8 buffer[L2CAP_MAX_SDU_LENGTH]; UINT32 count; @@ -740,8 +717,6 @@ static void on_l2cap_data_ind(tBTA_JV *evt, uint32_t id) static void btsock_l2cap_cbk(tBTA_JV_EVT event, tBTA_JV *p_data, void *user_data) { - int rc; - switch (event) { case BTA_JV_L2CAP_START_EVT: on_srv_l2cap_listen_started(&p_data->l2c_start, (uint32_t)user_data); diff --git a/btif/src/btif_storage.c b/btif/src/btif_storage.c index dc325f08..95d61d87 100644 --- a/btif/src/btif_storage.c +++ b/btif/src/btif_storage.c @@ -1192,7 +1192,6 @@ bt_status_t btif_in_fetch_bonded_ble_device(const char *remote_bd_addr, int add, { int device_type; int addr_type; - UINT32 i; bt_bdaddr_t bd_addr; BD_ADDR bta_bd_addr; bool device_added = false; diff --git a/hci/BUILD.gn b/hci/BUILD.gn index 63b4ebcf..c199ff03 100644 --- a/hci/BUILD.gn +++ b/hci/BUILD.gn @@ -66,10 +66,6 @@ executable("net_test_hci") { "//stack/include", ] - cflags = [ - "-Wno-unused-variable", - ] - deps = [ "//hci", "//osi", diff --git a/main/BUILD.gn b/main/BUILD.gn index e89bbc2f..94c62803 100644 --- a/main/BUILD.gn +++ b/main/BUILD.gn @@ -77,9 +77,6 @@ shared_library("bluetooth.default") { # TODO(armansito): Remove all of the flags below, as we want to be able to # compile the source code with as many warnings enabled as possible. cflags = [ - "-Wno-unused-variable", - "-Wno-unused-value", - "-Wno-unused-function", "-Wno-int-to-pointer-cast", ] diff --git a/stack/BUILD.gn b/stack/BUILD.gn index c224e19a..23cdb1d5 100644 --- a/stack/BUILD.gn +++ b/stack/BUILD.gn @@ -169,9 +169,6 @@ static_library("stack") { # TODO(armansito): Remove all of these flags. cflags = [ - "-Wno-unused-variable", - "-Wno-unused-value", - "-Wno-unused-function", "-Wno-pointer-to-int-cast", "-Wno-int-to-pointer-cast", ] diff --git a/stack/a2dp/a2d_sbc.c b/stack/a2dp/a2d_sbc.c index 4b786b45..fd7c8165 100644 --- a/stack/a2dp/a2d_sbc.c +++ b/stack/a2dp/a2d_sbc.c @@ -284,8 +284,9 @@ tA2D_STATUS A2D_ParsSbcInfo(tA2D_SBC_CIE *p_ie, UINT8 *p_info, BOOLEAN for_caps) status = A2D_INVALID_PARAMS; else { - losc = *p_info++; - *p_info++; + losc = *p_info; + *p_info += 2; + /* If the function is called for the wrong Media Type or Media Codec Type */ if(losc != A2D_SBC_INFO_LEN || *p_info != A2D_MEDIA_CT_SBC) status = A2D_WRONG_CODEC; diff --git a/stack/btm/btm_ble.c b/stack/btm/btm_ble.c index 59548986..0101b97a 100644 --- a/stack/btm/btm_ble.c +++ b/stack/btm/btm_ble.c @@ -683,7 +683,6 @@ void BTM_ReadDevInfo (BD_ADDR remote_bda, tBT_DEVICE_TYPE *p_dev_type, tBLE_ADDR BOOLEAN BTM_ReadConnectedTransportAddress(BD_ADDR remote_bda, tBT_TRANSPORT transport) { tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev(remote_bda); - tACL_CONN *p = btm_bda_to_acl(remote_bda, transport); /* if no device can be located, return */ if (p_dev_rec == NULL) @@ -1466,61 +1465,6 @@ void btm_ble_link_encrypted(BD_ADDR bd_addr, UINT8 encr_enable) gatt_notify_enc_cmpl(p_dev_rec->ble.pseudo_addr); } -/******************************************************************************* -** Function btm_enc_proc_ltk -** Description send LTK reply when it's ready. -*******************************************************************************/ -static void btm_enc_proc_ltk(tSMP_ENC *p) -{ - UINT8 i; - BTM_TRACE_DEBUG ("btm_enc_proc_ltk"); - if (p && p->param_len == BT_OCTET16_LEN) - { - for (i = 0; i < (BT_OCTET16_LEN - btm_cb.key_size); i ++) - p->param_buf[BT_OCTET16_LEN - i - 1] = 0; - btsnd_hcic_ble_ltk_req_reply(btm_cb.enc_handle, p->param_buf); - } -} - -/******************************************************************************* -** Function btm_enc_proc_slave_y -** Description calculate LTK when Y is ready -*******************************************************************************/ -static void btm_enc_proc_slave_y(tSMP_ENC *p) -{ - UINT16 div, y; - UINT8 *pp = p->param_buf; - tBTM_CB *p_cb = &btm_cb; - tSMP_ENC output; - tBTM_SEC_DEV_REC *p_dev_rec; - - BTM_TRACE_DEBUG ("btm_enc_proc_slave_y"); - if (p != NULL) - { - STREAM_TO_UINT16(y, pp); - - div = p_cb->ediv ^ y; - p_dev_rec = btm_find_dev_by_handle (p_cb->enc_handle); - - if ( p_dev_rec && - p_dev_rec->ble.keys.div == div ) - { - BTM_TRACE_DEBUG ("LTK request OK"); - /* calculating LTK , LTK = E er(div) */ - SMP_Encrypt(p_cb->devcb.ble_encryption_key_value, BT_OCTET16_LEN, (UINT8 *)&div, 2, &output); - btm_enc_proc_ltk(&output); - } - else - { - BTM_TRACE_DEBUG ("LTK request failed - send negative reply"); - btsnd_hcic_ble_ltk_req_neg_reply(p_cb->enc_handle); - if (p_dev_rec) - btm_ble_link_encrypted(p_dev_rec->bd_addr, 0); - - } - } -} - /******************************************************************************* ** ** Function btm_ble_ltk_request_reply @@ -1535,7 +1479,6 @@ void btm_ble_ltk_request_reply(BD_ADDR bda, BOOLEAN use_stk, BT_OCTET16 stk) { tBTM_SEC_DEV_REC *p_rec = btm_find_dev (bda); tBTM_CB *p_cb = &btm_cb; - tSMP_ENC output; if (p_rec == NULL) { diff --git a/stack/btm/btm_ble_gap.c b/stack/btm/btm_ble_gap.c index 43d0f363..153b5985 100644 --- a/stack/btm/btm_ble_gap.c +++ b/stack/btm/btm_ble_gap.c @@ -486,6 +486,7 @@ tBTM_STATUS BTM_BleBroadcast(BOOLEAN start) return status; } +#if BLE_VND_INCLUDED == TRUE /******************************************************************************* ** ** Function btm_vsc_brcm_features_complete @@ -497,7 +498,6 @@ tBTM_STATUS BTM_BleBroadcast(BOOLEAN start) *******************************************************************************/ static void btm_ble_vendor_capability_vsc_cmpl_cback (tBTM_VSC_CMPL *p_vcs_cplt_params) { -#if BLE_VND_INCLUDED == TRUE UINT8 status = 0xFF; UINT8 *p; @@ -555,15 +555,15 @@ static void btm_ble_vendor_capability_vsc_cmpl_cback (tBTM_VSC_CMPL *p_vcs_cplt_ if (btm_cb.cmn_ble_vsc_cb.max_irk_list_sz > 0 && controller_get_interface()->get_ble_resolving_list_max_size() == 0) btm_ble_resolving_list_init(btm_cb.cmn_ble_vsc_cb.max_irk_list_sz); -#endif +#endif /* (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE) */ if (btm_cb.cmn_ble_vsc_cb.tot_scan_results_strg > 0) btm_ble_batchscan_init(); if (p_ctrl_le_feature_rd_cmpl_cback != NULL) p_ctrl_le_feature_rd_cmpl_cback(status); -#endif } +#endif /* BLE_VND_INCLUDED == TRUE */ /******************************************************************************* ** diff --git a/stack/btm/btm_dev.c b/stack/btm/btm_dev.c index 671d4a6f..99934f88 100644 --- a/stack/btm/btm_dev.c +++ b/stack/btm/btm_dev.c @@ -469,7 +469,6 @@ void btm_consolidate_dev(tBTM_SEC_DEV_REC *p_target_rec) #if BLE_INCLUDED == TRUE tBTM_SEC_DEV_REC *p_dev_rec = &btm_cb.sec_dev_rec[0]; tBTM_SEC_DEV_REC temp_rec = *p_target_rec; - BD_ADDR dummy_bda = {0}; BTM_TRACE_DEBUG("%s", __func__); diff --git a/stack/btm/btm_devctl.c b/stack/btm/btm_devctl.c index 3a707884..896bef57 100644 --- a/stack/btm/btm_devctl.c +++ b/stack/btm/btm_devctl.c @@ -262,9 +262,6 @@ void btm_dev_timeout (TIMER_LIST_ENT *p_tle) *******************************************************************************/ static void btm_decode_ext_features_page (UINT8 page_number, const UINT8 *p_features) { - UINT8 last; - UINT8 first; - BTM_TRACE_DEBUG ("btm_decode_ext_features_page page: %d", page_number); switch (page_number) { diff --git a/stack/btm/btm_sec.c b/stack/btm/btm_sec.c index 83b65240..26ee89ce 100644 --- a/stack/btm/btm_sec.c +++ b/stack/btm/btm_sec.c @@ -103,10 +103,8 @@ static UINT16 btm_sec_set_serv_level4_flags (UINT16 cur_security, BOOLEAN is_or static BOOLEAN btm_sec_queue_encrypt_request (BD_ADDR bd_addr, tBT_TRANSPORT transport, tBTM_SEC_CALLBACK *p_callback, void *p_ref_data); -static void btm_sec_clean_pending_req_queue (BD_ADDR remote_bda, tBT_TRANSPORT transport) ; static void btm_sec_check_pending_enc_req (tBTM_SEC_DEV_REC *p_dev_rec, tBT_TRANSPORT transport, UINT8 encr_enable); -static BOOLEAN btm_sec_acceptor_rejects_bonding (tBTM_SEC_DEV_REC *p_dev_rec); static BOOLEAN btm_sec_use_smp_br_chnl(tBTM_SEC_DEV_REC *p_dev_rec); static BOOLEAN btm_sec_is_master(tBTM_SEC_DEV_REC *p_dev_rec); @@ -6085,38 +6083,6 @@ void btm_sec_set_peer_sec_caps(tACL_CONN *p_acl_cb, tBTM_SEC_DEV_REC *p_dev_rec) } } -/******************************************************************************* -** -** Function btm_sec_clean_pending_req_queue -** -** Description This function cleans up the pending security request when the -** link to the target device dropped. -** -** Returns void -** -*******************************************************************************/ -static void btm_sec_clean_pending_req_queue (BD_ADDR remote_bda, tBT_TRANSPORT transport) -{ - tBTM_SEC_QUEUE_ENTRY *p_e; - BUFFER_Q *bq = &btm_cb.sec_pending_q; - - p_e = (tBTM_SEC_QUEUE_ENTRY *)GKI_getfirst(bq); - - if (p_e != NULL) - { - if (memcmp(p_e->bd_addr, remote_bda, BD_ADDR_LEN) == 0 -#if BLE_INCLUDED == TRUE - && p_e->transport == transport -#endif - ) - { - (*p_e->p_callback) (remote_bda, transport, p_e->p_ref_data, BTM_ERR_PROCESSING); - GKI_remove_from_queue(bq, (void *)p_e); - } - p_e = (tBTM_SEC_QUEUE_ENTRY *) GKI_getnext ((void *)p_e); - } -} - /******************************************************************************* ** ** Function btm_sec_is_serv_level0 diff --git a/stack/gap/gap_conn.c b/stack/gap/gap_conn.c index 67b89225..6c6c5e74 100644 --- a/stack/gap/gap_conn.c +++ b/stack/gap/gap_conn.c @@ -127,7 +127,6 @@ UINT16 GAP_ConnOpen (char *p_serv_name, UINT8 service_id, BOOLEAN is_server, { tGAP_CCB *p_ccb; UINT16 cid; - tBT_UUID bt_uuid = {2, {GAP_PROTOCOL_ID}}; GAP_TRACE_EVENT ("GAP_CONN - Open Request"); @@ -235,7 +234,7 @@ UINT16 GAP_ConnOpen (char *p_serv_name, UINT8 service_id, BOOLEAN is_server, p_ccb->con_flags |= GAP_CCB_FLAGS_SEC_DONE; /* Check if L2CAP started the connection process */ - if (p_rem_bda && ((cid = L2CA_CONNECT_REQ (p_ccb->psm, p_rem_bda, &p_ccb->ertm_info, &bt_uuid)) != 0)) + if (p_rem_bda && ((cid = L2CA_CONNECT_REQ (p_ccb->psm, p_rem_bda, &p_ccb->ertm_info)) != 0)) { p_ccb->connection_id = cid; return (p_ccb->gap_handle); @@ -739,7 +738,6 @@ static void gap_connect_ind (BD_ADDR bd_addr, UINT16 l2cap_cid, UINT16 psm, UIN { UINT16 xx; tGAP_CCB *p_ccb; - tBT_UUID bt_uuid = {2, {GAP_PROTOCOL_ID}}; /* See if we have a CCB listening for the connection */ for (xx = 0, p_ccb = gap_cb.conn.ccb_pool; xx < GAP_MAX_CONNECTIONS; xx++, p_ccb++) @@ -770,7 +768,7 @@ static void gap_connect_ind (BD_ADDR bd_addr, UINT16 l2cap_cid, UINT16 psm, UIN p_ccb->connection_id = l2cap_cid; /* Send response to the L2CAP layer. */ - L2CA_CONNECT_RSP (bd_addr, l2cap_id, l2cap_cid, L2CAP_CONN_OK, L2CAP_CONN_OK, &p_ccb->ertm_info, &bt_uuid); + L2CA_CONNECT_RSP (bd_addr, l2cap_id, l2cap_cid, L2CAP_CONN_OK, L2CAP_CONN_OK, &p_ccb->ertm_info); GAP_TRACE_EVENT("GAP_CONN - Rcvd L2CAP conn ind, CID: 0x%x", p_ccb->connection_id); diff --git a/stack/gatt/gatt_attr.c b/stack/gatt/gatt_attr.c index fe3fcc42..62f48f0d 100644 --- a/stack/gatt/gatt_attr.c +++ b/stack/gatt/gatt_attr.c @@ -483,7 +483,6 @@ static void gatt_cl_start_config_ccc(tGATT_PROFILE_CLCB *p_clcb) *******************************************************************************/ void GATT_ConfigServiceChangeCCC (BD_ADDR remote_bda, BOOLEAN enable, tBT_TRANSPORT transport) { - UINT16 conn_id = GATT_INVALID_CONN_ID; tGATT_PROFILE_CLCB *p_clcb = gatt_profile_find_clcb_by_bd_addr (remote_bda, transport); if (p_clcb == NULL) diff --git a/stack/hid/hidh_conn.c b/stack/hid/hidh_conn.c index 0cc69761..efaa1f64 100644 --- a/stack/hid/hidh_conn.c +++ b/stack/hid/hidh_conn.c @@ -321,7 +321,6 @@ void hidh_sec_check_complete_orig (BD_ADDR bd_addr, tBT_TRANSPORT transport, voi { tHID_HOST_DEV_CTB *p_dev = (tHID_HOST_DEV_CTB *) p_ref_data; UINT8 dhandle; - UINT32 reason; UNUSED(bd_addr); UNUSED (transport); diff --git a/stack/include/l2c_api.h b/stack/include/l2c_api.h index 837dbc85..b431d565 100644 --- a/stack/include/l2c_api.h +++ b/stack/include/l2c_api.h @@ -319,8 +319,8 @@ typedef struct #define L2CA_REGISTER(a,b,c) L2CA_Register(a,(tL2CAP_APPL_INFO *)b) #define L2CA_DEREGISTER(a) L2CA_Deregister(a) -#define L2CA_CONNECT_REQ(a,b,c,d) L2CA_ErtmConnectReq(a,b,c) -#define L2CA_CONNECT_RSP(a,b,c,d,e,f,g) L2CA_ErtmConnectRsp(a,b,c,d,e,f) +#define L2CA_CONNECT_REQ(a,b,c) L2CA_ErtmConnectReq(a,b,c) +#define L2CA_CONNECT_RSP(a,b,c,d,e,f) L2CA_ErtmConnectRsp(a,b,c,d,e,f) #define L2CA_CONFIG_REQ(a,b) L2CA_ConfigReq(a,b) #define L2CA_CONFIG_RSP(a,b) L2CA_ConfigRsp(a,b) #define L2CA_DISCONNECT_REQ(a) L2CA_DisconnectReq(a) diff --git a/stack/l2cap/l2c_ble.c b/stack/l2cap/l2c_ble.c index 2460bd44..f7d65f0d 100644 --- a/stack/l2cap/l2c_ble.c +++ b/stack/l2cap/l2c_ble.c @@ -263,7 +263,6 @@ void l2cble_notify_le_connection (BD_ADDR bda) void l2cble_scanner_conn_comp (UINT16 handle, BD_ADDR bda, tBLE_ADDR_TYPE type, UINT16 conn_interval, UINT16 conn_latency, UINT16 conn_timeout) { - int i; tL2C_LCB *p_lcb; tBTM_SEC_DEV_REC *p_dev_rec = btm_find_or_alloc_dev (bda); @@ -372,7 +371,6 @@ void l2cble_scanner_conn_comp (UINT16 handle, BD_ADDR bda, tBLE_ADDR_TYPE type, void l2cble_advertiser_conn_comp (UINT16 handle, BD_ADDR bda, tBLE_ADDR_TYPE type, UINT16 conn_interval, UINT16 conn_latency, UINT16 conn_timeout) { - int i; tL2C_LCB *p_lcb; tBTM_SEC_DEV_REC *p_dev_rec; UNUSED(type); @@ -480,9 +478,13 @@ void l2cble_conn_comp(UINT16 handle, UINT8 role, BD_ADDR bda, tBLE_ADDR_TYPE typ static void l2cble_start_conn_update (tL2C_LCB *p_lcb) { UINT16 min_conn_int, max_conn_int, slave_latency, supervision_tout; - tBTM_SEC_DEV_REC *p_dev_rec = btm_find_or_alloc_dev(p_lcb->remote_bd_addr); tACL_CONN *p_acl_cb = btm_bda_to_acl(p_lcb->remote_bd_addr, BT_TRANSPORT_LE); + // TODO(armansito): The return value of this call wasn't being used but the + // logic of this function might be depending on its side effects. We should + // verify if this call is needed at all and remove it otherwise. + btm_find_or_alloc_dev(p_lcb->remote_bd_addr); + if (p_lcb->conn_update_mask & L2C_BLE_UPDATE_PENDING) return; if (p_lcb->conn_update_mask & L2C_BLE_CONN_UPDATE_DISABLE)