From 4394720415f45db5caea73e1a05351ff98601fe0 Mon Sep 17 00:00:00 2001 From: Pavlin Radoslavov Date: Sat, 13 Feb 2016 08:47:19 -0800 Subject: [PATCH] Fix C/C++ compiler generated warnings * Remove unused functions: -Wno-unused-function * Fix logical operations that are missing parentheses: -Wno-logical-not-parentheses, -Wno-parentheses * Add missing braces in initializers: -Wno-missing-braces * Remove unused variables: -Wno-unused-variable * Fix printf()-like formatting issues: -Wno-format * Avoid using unitialized variables: -Wno-maybe-uninitialized, -Wno-uninitialized * Fix a bug inside bta_gattc_get_gatt_db_impl() when the processed GATT DB attribute type is unknown. * Fix warnings about missing field initializers: -Wno-missing-field-initializers * Re-implement macro COMPILE_ASSERT(COND) to fix a compilation warning: -Wno-non-literal-null-conversion * Fix sign mismatch comparison warnings: -Wno-sign-compare * Fix warnings related to enum conversion: -Wno-enum-conversion * Fix warnings related to incompatible pointer types: -Wno-incompatible-pointer-types * Fix warnings related to enum conversion: -Wno-enum-conversion Bug: 26879229 Change-Id: I522931fe156aeab23ae841051a9e25ceab00b1c2 --- Android.mk | 30 +++++-------- audio_a2dp_hw/audio_a2dp_hw.c | 2 + bta/av/bta_av_aact.c | 16 ++++--- bta/dm/bta_dm_act.c | 52 ---------------------- bta/gatt/bta_gattc_act.c | 6 ++- bta/gatt/bta_gattc_cache.c | 1 + bta/hf_client/bta_hf_client_at.c | 6 ++- bta/jv/bta_jv_act.c | 7 ++- bta/sdp/bta_sdp_act.c | 12 ++--- btif/src/btif_av.c | 2 +- btif/src/btif_avrcp_audio_track.cpp | 1 - btif/src/btif_debug_btsnoop.c | 2 +- btif/src/btif_dm.c | 10 +++-- btif/src/btif_rc.c | 12 +++-- btif/src/btif_sock_thread.c | 55 ----------------------- device/include/interop_database.h | 43 +++++++++--------- hci/src/btsnoop.c | 4 +- hci/src/vendor.c | 4 +- main/bte_logmsg.c | 2 - osi/include/osi.h | 2 +- osi/test/list_test.cpp | 4 +- osi/test/ringbuffer_test.cpp | 76 ++++++++++++++++---------------- service/client/main.cpp | 5 --- service/low_energy_client.cpp | 1 - service/test/parcel_helpers_unittest.cpp | 2 +- stack/avrc/avrc_api.c | 1 - stack/btm/btm_ble_bgconn.c | 2 - stack/btm/btm_ble_gap.c | 4 +- stack/btm/btm_dev.c | 1 - stack/btm/btm_devctl.c | 11 +++-- stack/gatt/gatt_cl.c | 13 ++++-- stack/gatt/gatt_sr.c | 2 +- stack/l2cap/l2cap_client.c | 6 ++- stack/smp/smp_keys.c | 14 ------ test/bluedroidtest/bluedroidtest.c | 62 -------------------------- 35 files changed, 148 insertions(+), 325 deletions(-) diff --git a/Android.mk b/Android.mk index 5849e1425..3b89e2986 100644 --- a/Android.mk +++ b/Android.mk @@ -22,33 +22,25 @@ bluetooth_CFLAGS += -DEXPORT_SYMBOL="__attribute__((visibility(\"default\")))" # # Common C/C++ compiler flags. # -# - gnu-variable-sized-type-not-at-end is needed for a variable-size header in -# a struct. -# - constant-logical-operand is needed for code in l2c_utils.c that looks -# intentional. +# -Wno-constant-logical-operand is needed for code in l2c_utils.c that is +# intentional. +# -Wno-gnu-variable-sized-type-not-at-end is needed, because struct BT_HDR +# is defined as a variable-size header in a struct. +# -Wno-typedef-redefinition is needed because of the way the struct typedef +# is done in osi/include header files. This issue can be obsoleted by +# switching to C11 or C++. +# -Wno-unused-parameter is needed, because there are too many unused +# parameters in all the code. # bluetooth_CFLAGS += \ -fvisibility=hidden \ -Wall \ -Wextra \ -Werror \ - -Wno-typedef-redefinition \ + -Wno-constant-logical-operand \ -Wno-gnu-variable-sized-type-not-at-end \ + -Wno-typedef-redefinition \ -Wno-unused-parameter \ - -Wno-maybe-uninitialized \ - -Wno-uninitialized \ - -Wno-missing-field-initializers \ - -Wno-unused-variable \ - -Wno-non-literal-null-conversion \ - -Wno-sign-compare \ - -Wno-incompatible-pointer-types \ - -Wno-unused-function \ - -Wno-missing-braces \ - -Wno-enum-conversion \ - -Wno-logical-not-parentheses \ - -Wno-parentheses \ - -Wno-constant-logical-operand \ - -Wno-format \ -UNDEBUG \ -DLOG_NDEBUG=1 diff --git a/audio_a2dp_hw/audio_a2dp_hw.c b/audio_a2dp_hw/audio_a2dp_hw.c index 97acc63a6..f4628d4cb 100644 --- a/audio_a2dp_hw/audio_a2dp_hw.c +++ b/audio_a2dp_hw/audio_a2dp_hw.c @@ -134,6 +134,8 @@ static size_t out_get_buffer_size(const struct audio_stream *stream); /***************************************************************************** ** Functions ******************************************************************************/ +/* Function used only in debug mode */ +static const char* dump_a2dp_ctrl_event(char event) __attribute__ ((unused)); /***************************************************************************** ** Miscellaneous helper functions diff --git a/bta/av/bta_av_aact.c b/bta/av/bta_av_aact.c index c1bbbcf22..fce185121 100644 --- a/bta/av/bta_av_aact.c +++ b/bta/av/bta_av_aact.c @@ -1063,7 +1063,8 @@ void bta_av_cleanup(tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data) p_scb->num_disc_snks = 0; alarm_cancel(p_scb->avrc_ct_timer); - vendor_get_interface()->send_command(BT_VND_OP_A2DP_OFFLOAD_STOP, (void*)&p_scb->l2c_cid); + vendor_get_interface()->send_command( + (vendor_opcode_t)BT_VND_OP_A2DP_OFFLOAD_STOP, (void*)&p_scb->l2c_cid); if (p_scb->offload_start_pending) { tBTA_AV_STATUS status = BTA_AV_FAIL_STREAM; (*bta_av_cb.p_cback)(BTA_AV_OFFLOAD_START_RSP_EVT, (tBTA_AV *)&status); @@ -2058,7 +2059,9 @@ void bta_av_str_stopped (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data) if (p_scb->co_started) { - vendor_get_interface()->send_command(BT_VND_OP_A2DP_OFFLOAD_STOP, (void*)&p_scb->l2c_cid); + vendor_get_interface()->send_command( + (vendor_opcode_t)BT_VND_OP_A2DP_OFFLOAD_STOP, + (void*)&p_scb->l2c_cid); if (p_scb->offload_start_pending) { tBTA_AV_STATUS status = BTA_AV_FAIL_STREAM; (*bta_av_cb.p_cback)(BTA_AV_OFFLOAD_START_RSP_EVT, (tBTA_AV *)&status); @@ -2136,7 +2139,6 @@ void bta_av_reconfig (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data) { tAVDT_CFG *p_cfg; tBTA_AV_API_STOP stop; - tBTA_AV_RECONFIG evt; tBTA_AV_API_RCFG *p_rcfg = &p_data->api_reconfig; APPL_TRACE_DEBUG("bta_av_reconfig r:%d, s:%d idx: %d (o:%d)", @@ -2642,7 +2644,9 @@ void bta_av_suspend_cfm (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data) /* in case that we received suspend_ind, we may need to call co_stop here */ if(p_scb->co_started) { - vendor_get_interface()->send_command(BT_VND_OP_A2DP_OFFLOAD_STOP, (void*)&p_scb->l2c_cid); + vendor_get_interface()->send_command( + (vendor_opcode_t)BT_VND_OP_A2DP_OFFLOAD_STOP, + (void*)&p_scb->l2c_cid); if (p_scb->offload_start_pending) { tBTA_AV_STATUS status = BTA_AV_FAIL_STREAM; (*bta_av_cb.p_cback)(BTA_AV_OFFLOAD_START_RSP_EVT, (tBTA_AV *)&status); @@ -3143,7 +3147,9 @@ void bta_av_offload_req(tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data) memcpy(a2dp_offload_start.codec_info, p_scb->cfg.codec_info, sizeof(a2dp_offload_start.codec_info)); - if (!vendor_get_interface()->send_command(BT_VND_OP_A2DP_OFFLOAD_START, &a2dp_offload_start)) { + if (!vendor_get_interface()->send_command( + (vendor_opcode_t)BT_VND_OP_A2DP_OFFLOAD_START, + &a2dp_offload_start)) { status = BTA_AV_SUCCESS; p_scb->offload_start_pending = TRUE; } diff --git a/bta/dm/bta_dm_act.c b/bta/dm/bta_dm_act.c index 3abf4eb21..8a8cfe86d 100644 --- a/bta/dm/bta_dm_act.c +++ b/bta/dm/bta_dm_act.c @@ -63,19 +63,6 @@ static void bta_dm_local_name_cback(BD_ADDR bd_addr); static BOOLEAN bta_dm_check_av(UINT16 event); static void bta_dm_bl_change_cback (tBTM_BL_EVENT_DATA *p_data); - -#if BLE_INCLUDED == TRUE -static void bta_dm_acl_change_cback(BD_ADDR p_bda, DEV_CLASS p_dc, - BD_NAME p_bdn, UINT8 *features, - BOOLEAN is_new, UINT16 handle, - tBT_TRANSPORT transport); -#else -static void bta_dm_acl_change_cback(BD_ADDR p_bda, DEV_CLASS p_dc, - BD_NAME p_bdn, UINT8 *features, - BOOLEAN is_new); -#endif - - static void bta_dm_policy_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app_id, BD_ADDR peer_addr); /* Extended Inquiry Response */ @@ -3052,45 +3039,6 @@ static void bta_dm_bl_change_cback (tBTM_BL_EVENT_DATA *p_data) /******************************************************************************* ** -** Function bta_dm_acl_change_cback -** -** Description Callback from btm when acl connection goes up or down -** -** -** Returns void -** -*******************************************************************************/ -#if BLE_INCLUDED == TRUE -static void bta_dm_acl_change_cback(BD_ADDR p_bda, DEV_CLASS p_dc, - BD_NAME p_bdn, UINT8 *features, - BOOLEAN is_new, UINT16 handle, - tBT_TRANSPORT transport) -#else -static void bta_dm_acl_change_cback(BD_ADDR p_bda, DEV_CLASS p_dc, - BD_NAME p_bdn, UINT8 *features, - BOOLEAN is_new) -#endif -{ - tBTA_DM_ACL_CHANGE *p_msg = (tBTA_DM_ACL_CHANGE *)osi_calloc(sizeof(tBTA_DM_ACL_CHANGE)); - - bdcpy(p_msg->bd_addr, p_bda); - p_msg->is_new = is_new; -#if BLE_INCLUDED == TRUE - p_msg->handle = handle; - p_msg->transport = transport; -#endif - /* This is collision case */ - if (features != NULL) { - if ((features[0] == 0xFF) && !is_new) - p_msg->event = BTM_BL_COLLISION_EVT; - } - - p_msg->hdr.event = BTA_DM_ACL_CHANGE_EVT; - bta_sys_sendmsg(p_msg); -} - -/******************************************************************************* -** ** Function bta_dm_rs_cback ** ** Description Receives the role switch complete event diff --git a/bta/gatt/bta_gattc_act.c b/bta/gatt/bta_gattc_act.c index 798ded823..64ea90ea0 100644 --- a/bta/gatt/bta_gattc_act.c +++ b/bta/gatt/bta_gattc_act.c @@ -1189,7 +1189,6 @@ void bta_gattc_read_multi(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data) void bta_gattc_write(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data) { UINT16 handle = 0; - tGATT_VALUE attr = {0}; tBTA_GATT_STATUS status = BTA_GATT_OK; if (bta_gattc_enqueue(p_clcb, p_data)) @@ -1203,7 +1202,10 @@ void bta_gattc_write(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data) } else { - attr.handle= handle; + tGATT_VALUE attr; + + attr.conn_id = p_clcb->bta_conn_id; + attr.handle = handle; attr.offset = p_data->api_write.offset; attr.len = p_data->api_write.len; attr.auth_req = p_data->api_write.auth_req; diff --git a/bta/gatt/bta_gattc_cache.c b/bta/gatt/bta_gattc_cache.c index 71625d543..e3550342d 100644 --- a/bta/gatt/bta_gattc_cache.c +++ b/bta/gatt/bta_gattc_cache.c @@ -1511,6 +1511,7 @@ static void bta_gattc_get_gatt_db_impl(tBTA_GATTC_SERV *p_srvc_cb, default: LOG_ERROR(LOG_TAG, "%s unknown gatt db attribute type: %d", __func__, p_attr->attr_type); + continue; } bta_gattc_fill_gatt_db_el(curr_db_attr, diff --git a/bta/hf_client/bta_hf_client_at.c b/bta/hf_client/bta_hf_client_at.c index 82a602445..a2a33543f 100644 --- a/bta/hf_client/bta_hf_client_at.c +++ b/bta/hf_client/bta_hf_client_at.c @@ -1639,8 +1639,12 @@ void bta_hf_client_send_at_atd(char *number, UINT32 memory) } else { at_len = snprintf(buf, sizeof(buf), "ATD>%u;\r", memory); } + if (at_len < 0) { + APPL_TRACE_ERROR("%s: error preparing ATD command"); + return; + } - at_len = MIN(at_len, sizeof(buf)); + at_len = MIN((size_t)at_len, sizeof(buf)); bta_hf_client_send_at(BTA_HF_CLIENT_AT_ATD, buf, at_len); } diff --git a/bta/jv/bta_jv_act.c b/bta/jv/bta_jv_act.c index a3e2296e3..0d19b76a6 100644 --- a/bta/jv/bta_jv_act.c +++ b/bta/jv/bta_jv_act.c @@ -1562,13 +1562,14 @@ void bta_jv_rfcomm_connect(tBTA_JV_MSG *p_data) tBTA_JV_RFC_CB *p_cb = NULL; tBTA_JV_PCB *p_pcb; tBTA_JV_API_RFCOMM_CONNECT *cc = &(p_data->rfcomm_connect); - tBTA_JV_RFCOMM_CL_INIT evt_data = {0}; + tBTA_JV_RFCOMM_CL_INIT evt_data; /* TODO DM role manager L2CA_SetDesireRole(cc->role); */ sec_id = bta_jv_alloc_sec_id(); + memset(&evt_data, 0, sizeof(evt_data)); evt_data.sec_id = sec_id; evt_data.status = BTA_JV_SUCCESS; if (0 == sec_id || @@ -1898,10 +1899,12 @@ void bta_jv_rfcomm_start_server(tBTA_JV_MSG *p_data) tBTA_JV_RFC_CB *p_cb = NULL; tBTA_JV_PCB *p_pcb; tBTA_JV_API_RFCOMM_SERVER *rs = &(p_data->rfcomm_server); - tBTA_JV_RFCOMM_START evt_data = {0}; + tBTA_JV_RFCOMM_START evt_data; + /* TODO DM role manager L2CA_SetDesireRole(rs->role); */ + memset(&evt_data, 0, sizeof(evt_data)); evt_data.status = BTA_JV_FAILURE; APPL_TRACE_DEBUG("bta_jv_rfcomm_start_server: sec id in use:%d, rfc_cb in use:%d", get_sec_id_used(), get_rfc_cb_used()); diff --git a/bta/sdp/bta_sdp_act.c b/bta/sdp/bta_sdp_act.c index 9f5b5d394..0168b9cd4 100644 --- a/bta/sdp/bta_sdp_act.c +++ b/bta/sdp/bta_sdp_act.c @@ -50,8 +50,6 @@ static const uint8_t UUID_MAP_MAS[] = {0x00, 0x00, 0x11, 0x32, 0x00, 0x00, 0x10 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB}; static const uint8_t UUID_MAP_MNS[] = {0x00, 0x00, 0x11, 0x33, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB}; -static const uint8_t UUID_SPP[] = {0x00, 0x00, 0x11, 0x01, 0x00, 0x00, 0x10, 0x00, - 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB}; static const uint8_t UUID_SAP[] = {0x00, 0x00, 0x11, 0x2D, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB}; // TODO: @@ -314,7 +312,6 @@ static void bta_create_ops_sdp_record(bluetooth_sdp_record *record, tSDP_DISC_RE static void bta_create_sap_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; @@ -384,12 +381,13 @@ static void bta_create_raw_sdp_record(bluetooth_sdp_record *record, tSDP_DISC_RE 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_SEARCH_COMP evt_data; tBTA_SDP_STATUS status = BTA_SDP_FAILURE; int count = 0; tBT_UUID su; APPL_TRACE_DEBUG("%s() - res: 0x%x", __func__, result); + memset(&evt_data, 0, sizeof(evt_data)); bta_sdp_cb.sdp_active = BTA_SDP_ACTIVE_NONE; if (bta_sdp_cb.p_dm_cback == NULL) return; @@ -488,7 +486,8 @@ void bta_sdp_search(tBTA_SDP_MSG *p_data) /* SDP is still in progress */ status = BTA_SDP_BUSY; if(bta_sdp_cb.p_dm_cback) { - tBTA_SDP_SEARCH_COMP result = {0}; + tBTA_SDP_SEARCH_COMP result; + memset(&result, 0, sizeof(result)); result.uuid = p_data->get_search.uuid; bdcpy(result.remote_addr, p_data->get_search.bd_addr); result.status = status; @@ -519,7 +518,8 @@ void bta_sdp_search(tBTA_SDP_MSG *p_data) /* failed to start SDP. report the failure right away */ if (bta_sdp_cb.p_dm_cback) { - tBTA_SDP_SEARCH_COMP result = {0}; + tBTA_SDP_SEARCH_COMP result; + memset(&result, 0, sizeof(result)); result.uuid = p_data->get_search.uuid; bdcpy(result.remote_addr, p_data->get_search.bd_addr); result.status = status; diff --git a/btif/src/btif_av.c b/btif/src/btif_av.c index fc3ffa89a..28fee889a 100644 --- a/btif/src/btif_av.c +++ b/btif/src/btif_av.c @@ -94,7 +94,7 @@ typedef struct ******************************************************************************/ static btav_callbacks_t *bt_av_src_callbacks = NULL; static btav_callbacks_t *bt_av_sink_callbacks = NULL; -static btif_av_cb_t btif_av_cb = {0}; +static btif_av_cb_t btif_av_cb = {0, {{0}}, 0, 0, 0, 0}; static alarm_t *av_open_on_rc_timer = NULL; /* both interface and media task needs to be ready to alloc incoming request */ diff --git a/btif/src/btif_avrcp_audio_track.cpp b/btif/src/btif_avrcp_audio_track.cpp index 222b6c9b2..456b7091c 100644 --- a/btif/src/btif_avrcp_audio_track.cpp +++ b/btif/src/btif_avrcp_audio_track.cpp @@ -38,7 +38,6 @@ void *BtifAvrcpAudioTrackCreate(int trackFreq, int channelType) { LOG_VERBOSE(LOG_TAG, "%s Track.cpp: btCreateTrack freq %d channel %d ", __func__, trackFreq, channelType); - int ret = -1; sp track = new android::AudioTrack(AUDIO_STREAM_MUSIC, trackFreq, AUDIO_FORMAT_PCM_16_BIT, channelType, (int)0, (audio_output_flags_t)AUDIO_OUTPUT_FLAG_FAST, diff --git a/btif/src/btif_debug_btsnoop.c b/btif/src/btif_debug_btsnoop.c index 5387de9a9..3855663f9 100644 --- a/btif/src/btif_debug_btsnoop.c +++ b/btif/src/btif_debug_btsnoop.c @@ -89,7 +89,7 @@ static bool btsnoop_compress(ringbuffer_t *rb_dst, ringbuffer_t *rb_src) { assert(rb_dst != NULL); assert(rb_src != NULL); - z_stream zs = {0}; + z_stream zs = {.zalloc = Z_NULL, .zfree = Z_NULL, .opaque = Z_NULL}; if (deflateInit(&zs, Z_DEFAULT_COMPRESSION) != Z_OK) return false; diff --git a/btif/src/btif_dm.c b/btif/src/btif_dm.c index 466972894..4f4b31ed9 100644 --- a/btif/src/btif_dm.c +++ b/btif/src/btif_dm.c @@ -1107,9 +1107,13 @@ static void btif_dm_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl) // We could have received a new link key without going through the pairing flow. // If so, we don't want to perform SDP or any other operations on the authenticated // device. - if (!bdaddr_equals(p_auth_cmpl->bd_addr, pairing_cb.bd_addr)) { + if (bdcmp(p_auth_cmpl->bd_addr, pairing_cb.bd_addr) != 0) { char address[32]; - bdaddr_to_string(&p_auth_cmpl->bd_addr, address, sizeof(address)); + bt_bdaddr_t bt_bdaddr; + + memcpy(bt_bdaddr.address, p_auth_cmpl->bd_addr, + sizeof(bt_bdaddr.address)); + bdaddr_to_string(&bt_bdaddr, address, sizeof(address)); LOG_INFO(LOG_TAG, "%s skipping SDP since we did not initiate pairing to %s.", __func__, address); return; } @@ -2351,7 +2355,7 @@ bt_status_t btif_dm_create_bond(const bt_bdaddr_t *bd_addr, int transport) *******************************************************************************/ bt_status_t btif_dm_create_bond_out_of_band(const bt_bdaddr_t *bd_addr, int transport, const bt_out_of_band_data_t *oob_data) { - bdcpy(oob_cb.bdaddr, bd_addr); + bdcpy(oob_cb.bdaddr, bd_addr->address); memcpy(&oob_cb.oob_data, oob_data, sizeof(bt_out_of_band_data_t)); bdstr_t bdstr; diff --git a/btif/src/btif_rc.c b/btif/src/btif_rc.c index cedf80846..95beec3aa 100644 --- a/btif/src/btif_rc.c +++ b/btif/src/btif_rc.c @@ -253,8 +253,6 @@ static void handle_avk_rc_metamsg_cmd(tBTA_AV_META_MSG *pmeta_msg); static void handle_avk_rc_metamsg_rsp(tBTA_AV_META_MSG *pmeta_msg); static void btif_rc_ctrl_upstreams_rsp_cmd( UINT8 event, tAVRC_COMMAND *pavrc_cmd, UINT8 label); -static void btif_rc_ctrl_upstreams_rsp_evt( - UINT16 event, tAVRC_RESPONSE *pavrc_resp, UINT8* p_buf, UINT16 buf_len, UINT8 rsp_type); static void rc_ctrl_procedure_complete(); static void rc_stop_play_status_timer(); static void register_for_event_notification (btif_rc_supported_event_t *p_event); @@ -2708,7 +2706,7 @@ static void handle_app_val_response (tBTA_AV_META_MSG *pmeta_msg, tAVRC_LIST_APP } get_player_app_setting_cmd (p_app_settings->num_attrs, attrs); HAL_CBACK (bt_rc_ctrl_callbacks, playerapplicationsetting_cb, &rc_addr, - p_app_settings->num_attrs, &p_app_settings->attrs, 0, NULL); + p_app_settings->num_attrs, p_app_settings->attrs, 0, NULL); } } else if (p_app_settings->ext_attr_index < p_app_settings->num_ext_attrs) @@ -2821,7 +2819,7 @@ static void handle_app_attr_txt_response (tBTA_AV_META_MSG *pmeta_msg, tAVRC_GET attrs[xx] = p_app_settings->attrs[xx].attr_id; } HAL_CBACK (bt_rc_ctrl_callbacks, playerapplicationsetting_cb, &rc_addr, - p_app_settings->num_attrs, &p_app_settings->attrs, 0, NULL); + p_app_settings->num_attrs, p_app_settings->attrs, 0, NULL); get_player_app_setting_cmd (xx, attrs); return; @@ -2901,7 +2899,7 @@ static void handle_app_attr_val_txt_response (tBTA_AV_META_MSG *pmeta_msg, tAVRC attrs[xx] = p_app_settings->attrs[xx].attr_id; } HAL_CBACK (bt_rc_ctrl_callbacks, playerapplicationsetting_cb, &rc_addr, - p_app_settings->num_attrs, &p_app_settings->attrs, 0, NULL); + p_app_settings->num_attrs, p_app_settings->attrs, 0, NULL); get_player_app_setting_cmd (xx, attrs); return; @@ -2947,8 +2945,8 @@ static void handle_app_attr_val_txt_response (tBTA_AV_META_MSG *pmeta_msg, tAVRC attrs[xx+x] = p_app_settings->ext_attrs[x].attr_id; } HAL_CBACK (bt_rc_ctrl_callbacks, playerapplicationsetting_cb, &rc_addr, - p_app_settings->num_attrs, &p_app_settings->attrs, - p_app_settings->num_ext_attrs, &p_app_settings->ext_attrs); + p_app_settings->num_attrs, p_app_settings->attrs, + p_app_settings->num_ext_attrs, p_app_settings->ext_attrs); get_player_app_setting_cmd (xx + x, attrs); /* Free the application settings information after sending to diff --git a/btif/src/btif_sock_thread.c b/btif/src/btif_sock_thread.c index e9e745c7b..9f12b4cd3 100644 --- a/btif/src/btif_sock_thread.c +++ b/btif/src/btif_sock_thread.c @@ -104,61 +104,6 @@ static inline void add_poll(int h, int fd, int type, int flags, uint32_t user_id static pthread_mutex_t thread_slot_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; -static inline void set_socket_blocking(int s, int blocking) -{ - int opts; - opts = fcntl(s, F_GETFL); - if (opts<0) APPL_TRACE_ERROR("set blocking (%s)", strerror(errno)); - if(blocking) - opts &= ~O_NONBLOCK; - else opts |= O_NONBLOCK; - if (fcntl(s, F_SETFL, opts) < 0) - APPL_TRACE_ERROR("set blocking (%s)", strerror(errno)); -} - -static inline int create_server_socket(const char* name) -{ - int s = socket(AF_LOCAL, SOCK_STREAM, 0); - if(s < 0) - return -1; - APPL_TRACE_DEBUG("covert name to android abstract name:%s", name); - if(osi_socket_local_server_bind(s, name, ANDROID_SOCKET_NAMESPACE_ABSTRACT) >= 0) - { - if(listen(s, 5) == 0) - { - APPL_TRACE_DEBUG("listen to local socket:%s, fd:%d", name, s); - return s; - } - else APPL_TRACE_ERROR("listen to local socket:%s, fd:%d failed, errno:%d", name, s, errno); - } - else APPL_TRACE_ERROR("create local socket:%s fd:%d, failed, errno:%d", name, s, errno); - close(s); - return -1; -} -static inline int connect_server_socket(const char* name) -{ - int s = socket(AF_LOCAL, SOCK_STREAM, 0); - if(s < 0) - return -1; - set_socket_blocking(s, TRUE); - if(osi_socket_local_client_connect(s, name, ANDROID_SOCKET_NAMESPACE_ABSTRACT, SOCK_STREAM) >= 0) - { - APPL_TRACE_DEBUG("connected to local socket:%s, fd:%d", name, s); - return s; - } - else APPL_TRACE_ERROR("connect to local socket:%s, fd:%d failed, errno:%d", name, s, errno); - close(s); - return -1; -} -static inline int accept_server_socket(int s) -{ - struct sockaddr_un client_address; - socklen_t clen; - int fd = accept(s, (struct sockaddr*)&client_address, &clen); - APPL_TRACE_DEBUG("accepted fd:%d for server fd:%d", fd, s); - return fd; -} - static inline int create_thread(void *(*start_routine)(void *), void * arg, pthread_t * thread_id) { diff --git a/device/include/interop_database.h b/device/include/interop_database.h index a7fd3a476..d9aef4023 100644 --- a/device/include/interop_database.h +++ b/device/include/interop_database.h @@ -29,52 +29,51 @@ typedef struct { static const interop_entry_t interop_database[] = { // Nexus Remote (Spike) // Note: May affect other Asus brand devices - {{0x08, 0x62, 0x66, 0,0,0}, 3, INTEROP_DISABLE_LE_SECURE_CONNECTIONS}, - {{0x38, 0x2c, 0x4a, 0xc9, 0,0}, 4, INTEROP_DISABLE_LE_SECURE_CONNECTIONS}, - {{0x38, 0x2c, 0x4a, 0xe6, 0,0}, 4, INTEROP_DISABLE_LE_SECURE_CONNECTIONS}, - {{0x54, 0xa0, 0x50, 0xd9, 0,0}, 4, INTEROP_DISABLE_LE_SECURE_CONNECTIONS}, - {{0xac, 0x9e, 0x17, 0,0,0}, 3, INTEROP_DISABLE_LE_SECURE_CONNECTIONS}, - {{0xf0, 0x79, 0x59, 0,0,0}, 3, INTEROP_DISABLE_LE_SECURE_CONNECTIONS}, + {{{0x08, 0x62, 0x66, 0,0,0}}, 3, INTEROP_DISABLE_LE_SECURE_CONNECTIONS}, + {{{0x38, 0x2c, 0x4a, 0xc9, 0,0}}, 4, INTEROP_DISABLE_LE_SECURE_CONNECTIONS}, + {{{0x38, 0x2c, 0x4a, 0xe6, 0,0}}, 4, INTEROP_DISABLE_LE_SECURE_CONNECTIONS}, + {{{0x54, 0xa0, 0x50, 0xd9, 0,0}}, 4, INTEROP_DISABLE_LE_SECURE_CONNECTIONS}, + {{{0xac, 0x9e, 0x17, 0,0,0}}, 3, INTEROP_DISABLE_LE_SECURE_CONNECTIONS}, + {{{0xf0, 0x79, 0x59, 0,0,0}}, 3, INTEROP_DISABLE_LE_SECURE_CONNECTIONS}, // Motorola Key Link - {{0x1c, 0x96, 0x5a, 0,0,0}, 3, INTEROP_DISABLE_LE_SECURE_CONNECTIONS}, + {{{0x1c, 0x96, 0x5a, 0,0,0}}, 3, INTEROP_DISABLE_LE_SECURE_CONNECTIONS}, // Flic smart button - {{0x80, 0xe4, 0xda, 0x70, 0,0}, 4, INTEROP_DISABLE_LE_SECURE_CONNECTIONS}, + {{{0x80, 0xe4, 0xda, 0x70, 0,0}}, 4, INTEROP_DISABLE_LE_SECURE_CONNECTIONS}, // BMW car kits (Harman/Becker) - {{0x9c, 0xdf, 0x03, 0,0,0}, 3, INTEROP_AUTO_RETRY_PAIRING}, + {{{0x9c, 0xdf, 0x03, 0,0,0}}, 3, INTEROP_AUTO_RETRY_PAIRING}, // Ausdom M05 - unacceptably loud volume - {{0xa0, 0xe9, 0xdb, 0,0,0}, 3, INTEROP_DISABLE_ABSOLUTE_VOLUME}, + {{{0xa0, 0xe9, 0xdb, 0,0,0}}, 3, INTEROP_DISABLE_ABSOLUTE_VOLUME}, // iKross IKBT83B HS - unacceptably loud volume - {{0x00, 0x14, 0x02, 0,0,0}, 3, INTEROP_DISABLE_ABSOLUTE_VOLUME}, + {{{0x00, 0x14, 0x02, 0,0,0}}, 3, INTEROP_DISABLE_ABSOLUTE_VOLUME}, // Jabra EXTREAM2 - unacceptably loud volume - {{0x1c, 0x48, 0xf9, 0,0,0}, 3, INTEROP_DISABLE_ABSOLUTE_VOLUME}, + {{{0x1c, 0x48, 0xf9, 0,0,0}}, 3, INTEROP_DISABLE_ABSOLUTE_VOLUME}, // JayBird BlueBuds X - low granularity on volume control - {{0x44, 0x5e, 0xf3, 0,0,0}, 3, INTEROP_DISABLE_ABSOLUTE_VOLUME}, - {{0xd4, 0x9c, 0x28, 0,0,0}, 3, INTEROP_DISABLE_ABSOLUTE_VOLUME}, + {{{0x44, 0x5e, 0xf3, 0,0,0}}, 3, INTEROP_DISABLE_ABSOLUTE_VOLUME}, + {{{0xd4, 0x9c, 0x28, 0,0,0}}, 3, INTEROP_DISABLE_ABSOLUTE_VOLUME}, // LG Tone HBS-730 - unacceptably loud volume - {{0x00, 0x18, 0x6b, 0,0,0}, 3, INTEROP_DISABLE_ABSOLUTE_VOLUME}, - {{0xb8, 0xad, 0x3e, 0,0,0}, 3, INTEROP_DISABLE_ABSOLUTE_VOLUME}, + {{{0x00, 0x18, 0x6b, 0,0,0}}, 3, INTEROP_DISABLE_ABSOLUTE_VOLUME}, + {{{0xb8, 0xad, 0x3e, 0,0,0}}, 3, INTEROP_DISABLE_ABSOLUTE_VOLUME}, // LG Tone HV-800 - unacceptably loud volume - {{0xa0, 0xe9, 0xdb, 0,0,0}, 3, INTEROP_DISABLE_ABSOLUTE_VOLUME}, + {{{0xa0, 0xe9, 0xdb, 0,0,0}}, 3, INTEROP_DISABLE_ABSOLUTE_VOLUME}, // Mpow Cheetah - unacceptably loud volume - {{0x00, 0x11, 0xb1, 0,0,0}, 3, INTEROP_DISABLE_ABSOLUTE_VOLUME}, + {{{0x00, 0x11, 0xb1, 0,0,0}}, 3, INTEROP_DISABLE_ABSOLUTE_VOLUME}, // SOL REPUBLIC Tracks Air - unable to adjust volume back off from max - {{0xa4, 0x15, 0x66, 0,0,0}, 3, INTEROP_DISABLE_ABSOLUTE_VOLUME}, + {{{0xa4, 0x15, 0x66, 0,0,0}}, 3, INTEROP_DISABLE_ABSOLUTE_VOLUME}, // Swage Rokitboost HS - unacceptably loud volume - {{0x00, 0x14, 0xf1, 0,0,0}, 3, INTEROP_DISABLE_ABSOLUTE_VOLUME}, + {{{0x00, 0x14, 0xf1, 0,0,0}}, 3, INTEROP_DISABLE_ABSOLUTE_VOLUME}, // VW Car Kit - not enough granularity with volume - {{0x00, 0x26, 0x7e, 0,0,0}, 3, INTEROP_DISABLE_ABSOLUTE_VOLUME} - + {{{0x00, 0x26, 0x7e, 0,0,0}}, 3, INTEROP_DISABLE_ABSOLUTE_VOLUME} }; diff --git a/hci/src/btsnoop.c b/hci/src/btsnoop.c index 42f9674e8..50df9106c 100644 --- a/hci/src/btsnoop.c +++ b/hci/src/btsnoop.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -164,7 +165,8 @@ static void update_logging() { // Save the old log if configured to do so if (stack_config->get_btsnoop_should_save_last()) { char last_log_path[PATH_MAX]; - snprintf(last_log_path, PATH_MAX, "%s.%llu", log_path, btsnoop_timestamp()); + snprintf(last_log_path, PATH_MAX, "%s.%" PRIu64, log_path, + btsnoop_timestamp()); if (!rename(log_path, last_log_path) && errno != ENOENT) LOG_ERROR(LOG_TAG, "%s unable to rename '%s' to '%s': %s", __func__, log_path, last_log_path, strerror(errno)); } diff --git a/hci/src/vendor.c b/hci/src/vendor.c index d048242df..c6bbd435a 100644 --- a/hci/src/vendor.c +++ b/hci/src/vendor.c @@ -93,12 +93,12 @@ static void vendor_close(void) { static int send_command(vendor_opcode_t opcode, void *param) { assert(lib_interface != NULL); - return lib_interface->op(opcode, param); + return lib_interface->op((bt_vendor_opcode_t)opcode, param); } static int send_async_command(vendor_async_opcode_t opcode, void *param) { assert(lib_interface != NULL); - return lib_interface->op(opcode, param); + return lib_interface->op((bt_vendor_opcode_t)opcode, param); } static void set_callback(vendor_async_opcode_t opcode, vendor_cb callback) { diff --git a/main/bte_logmsg.c b/main/bte_logmsg.c index efeed4a9f..4a59eac72 100644 --- a/main/bte_logmsg.c +++ b/main/bte_logmsg.c @@ -163,8 +163,6 @@ static tBTTRC_FUNC_MAP bttrc_set_level_map[] = { {0, 0, NULL, NULL, DEFAULT_CONF_TRACE_LEVEL} }; -static const UINT16 bttrc_map_size = sizeof(bttrc_set_level_map)/sizeof(tBTTRC_FUNC_MAP); - void LogMsg(uint32_t trace_set_mask, const char *fmt_str, ...) { static char buffer[BTE_LOG_BUF_SIZE]; int trace_layer = TRACE_GET_LAYER(trace_set_mask); diff --git a/osi/include/osi.h b/osi/include/osi.h index 78aa68cd7..d2cc0a364 100644 --- a/osi/include/osi.h +++ b/osi/include/osi.h @@ -22,7 +22,7 @@ // C++ code that includes base and osi/include/osi.h can thus easily default to // the definition from libbase but we should check here to avoid compile errors. #ifndef COMPILE_ASSERT -#define COMPILE_ASSERT(x) char * DUMMY_PTR = !(x) +#define COMPILE_ASSERT(COND) typedef int failed_compile_assert[(COND) ? 1 : -1] __attribute__ ((unused)) #endif // COMPILE_ASSERT // Macros for safe integer to pointer conversion. In the C language, data is diff --git a/osi/test/list_test.cpp b/osi/test/list_test.cpp index fcb65908a..b7d8ae889 100644 --- a/osi/test/list_test.cpp +++ b/osi/test/list_test.cpp @@ -169,7 +169,7 @@ TEST_F(ListTest, test_list_foreach_full) { int x[] = { 1, 2, 3, 4, 5 }; for (size_t i = 0; i < ARRAY_SIZE(x); ++i) list_append(list, &x[i]); - EXPECT_EQ(list_length(list), 5); + EXPECT_EQ(list_length(list), (size_t)5); // Test complete iteration int sum = 0; @@ -187,7 +187,7 @@ TEST_F(ListTest, test_list_foreach_partial) { int x[] = { 1, 2, 3, 4, 5 }; for (size_t i = 0; i < ARRAY_SIZE(x); ++i) list_append(list, &x[i]); - EXPECT_EQ(list_length(list), 5); + EXPECT_EQ(list_length(list), (size_t)5); // Test partial iteration int find = 4; diff --git a/osi/test/ringbuffer_test.cpp b/osi/test/ringbuffer_test.cpp index 88ff64ccf..af007acf5 100644 --- a/osi/test/ringbuffer_test.cpp +++ b/osi/test/ringbuffer_test.cpp @@ -8,8 +8,8 @@ extern "C" { TEST(RingbufferTest, test_new_simple) { ringbuffer_t *rb = ringbuffer_init(4096); ASSERT_TRUE(rb != NULL); - EXPECT_EQ(4096, ringbuffer_available(rb)); - EXPECT_EQ(0, ringbuffer_size(rb)); + EXPECT_EQ((size_t)4096, ringbuffer_available(rb)); + EXPECT_EQ((size_t)0, ringbuffer_size(rb)); ringbuffer_free(rb); } @@ -18,14 +18,14 @@ TEST(RingbufferTest, test_insert_basic) { uint8_t buffer[10] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A}; ringbuffer_insert(rb, buffer, 10); - EXPECT_EQ(10, ringbuffer_size(rb)); - EXPECT_EQ(6, ringbuffer_available(rb)); + EXPECT_EQ((size_t)10, ringbuffer_size(rb)); + EXPECT_EQ((size_t)6, ringbuffer_available(rb)); uint8_t peek[10] = {0}; size_t peeked = ringbuffer_peek(rb, peek, 10); - EXPECT_EQ(10, ringbuffer_size(rb)); // Ensure size doesn't change - EXPECT_EQ(6, ringbuffer_available(rb)); - EXPECT_EQ(10, peeked); + EXPECT_EQ((size_t)10, ringbuffer_size(rb)); // Ensure size doesn't change + EXPECT_EQ((size_t)6, ringbuffer_available(rb)); + EXPECT_EQ((size_t)10, peeked); ASSERT_TRUE(0 == memcmp(buffer, peek, peeked)); ringbuffer_free(rb); @@ -39,19 +39,19 @@ TEST(RingbufferTest, test_insert_full) { uint8_t peek[5] = {0}; size_t added = ringbuffer_insert(rb, aa, 7); - EXPECT_EQ(5, added); - EXPECT_EQ(0, ringbuffer_available(rb)); - EXPECT_EQ(5, ringbuffer_size(rb)); + EXPECT_EQ((size_t)5, added); + EXPECT_EQ((size_t)0, ringbuffer_available(rb)); + EXPECT_EQ((size_t)5, ringbuffer_size(rb)); added = ringbuffer_insert(rb, bb, 5); - EXPECT_EQ(0, added); - EXPECT_EQ(0, ringbuffer_available(rb)); - EXPECT_EQ(5, ringbuffer_size(rb)); + EXPECT_EQ((size_t)0, added); + EXPECT_EQ((size_t)0, ringbuffer_available(rb)); + EXPECT_EQ((size_t)5, ringbuffer_size(rb)); size_t peeked = ringbuffer_peek(rb, peek, 5); - EXPECT_EQ(5, peeked); - EXPECT_EQ(0, ringbuffer_available(rb)); - EXPECT_EQ(5, ringbuffer_size(rb)); + EXPECT_EQ((size_t)5, peeked); + EXPECT_EQ((size_t)0, ringbuffer_available(rb)); + EXPECT_EQ((size_t)5, ringbuffer_size(rb)); ASSERT_TRUE(0 == memcmp(aa, peek, peeked)); @@ -60,79 +60,79 @@ TEST(RingbufferTest, test_insert_full) { TEST(RingbufferTest, test_multi_insert_delete) { ringbuffer_t *rb = ringbuffer_init(16); - EXPECT_EQ(16, ringbuffer_available(rb)); - EXPECT_EQ(0, ringbuffer_size(rb)); + EXPECT_EQ((size_t)16, ringbuffer_available(rb)); + EXPECT_EQ((size_t)0, ringbuffer_size(rb)); // Insert some bytes uint8_t aa[] = {0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA}; size_t added = ringbuffer_insert(rb, aa, sizeof(aa)); - EXPECT_EQ(8, added); - EXPECT_EQ(8, ringbuffer_available(rb)); - EXPECT_EQ(8, ringbuffer_size(rb)); + EXPECT_EQ((size_t)8, added); + EXPECT_EQ((size_t)8, ringbuffer_available(rb)); + EXPECT_EQ((size_t)8, ringbuffer_size(rb)); uint8_t bb[] = {0xBB, 0xBB, 0xBB, 0xBB, 0xBB}; ringbuffer_insert(rb, bb, sizeof(bb)); - EXPECT_EQ(3, ringbuffer_available(rb)); - EXPECT_EQ(13, ringbuffer_size(rb)); + EXPECT_EQ((size_t)3, ringbuffer_available(rb)); + EXPECT_EQ((size_t)13, ringbuffer_size(rb)); uint8_t content[] = {0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB}; uint8_t peek[16] = {0}; size_t peeked = ringbuffer_peek(rb, peek, 16); - EXPECT_EQ(13, peeked); + EXPECT_EQ((size_t)13, peeked); ASSERT_TRUE(0 == memcmp(content, peek, peeked)); // Delete some bytes ringbuffer_delete(rb, sizeof(aa)); - EXPECT_EQ(11, ringbuffer_available(rb)); - EXPECT_EQ(5, ringbuffer_size(rb)); + EXPECT_EQ((size_t)11, ringbuffer_available(rb)); + EXPECT_EQ((size_t)5, ringbuffer_size(rb)); // Add some more to wrap buffer uint8_t cc[] = {0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC}; ringbuffer_insert(rb, cc, sizeof(cc)); - EXPECT_EQ(2, ringbuffer_available(rb)); - EXPECT_EQ(14, ringbuffer_size(rb)); + EXPECT_EQ((size_t)2, ringbuffer_available(rb)); + EXPECT_EQ((size_t)14, ringbuffer_size(rb)); uint8_t content2[] = {0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xCC, 0xCC}; peeked = ringbuffer_peek(rb, peek, 7); - EXPECT_EQ(7, peeked); + EXPECT_EQ((size_t)7, peeked); ASSERT_TRUE(0 == memcmp(content2, peek, peeked)); // Pop buffer memset(peek, 0, 16); size_t popped = ringbuffer_pop(rb, peek, 7); - EXPECT_EQ(7, popped); - EXPECT_EQ(9, ringbuffer_available(rb)); + EXPECT_EQ((size_t)7, popped); + EXPECT_EQ((size_t)9, ringbuffer_available(rb)); ASSERT_TRUE(0 == memcmp(content2, peek, peeked)); // Add more again to check head motion uint8_t dd[] = { 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD }; added = ringbuffer_insert(rb, dd, sizeof(dd)); - EXPECT_EQ(8, added); - EXPECT_EQ(1, ringbuffer_available(rb)); + EXPECT_EQ((size_t)8, added); + EXPECT_EQ((size_t)1, ringbuffer_available(rb)); // Delete everything ringbuffer_delete(rb, 16); - EXPECT_EQ(16, ringbuffer_available(rb)); - EXPECT_EQ(0, ringbuffer_size(rb)); + EXPECT_EQ((size_t)16, ringbuffer_available(rb)); + EXPECT_EQ((size_t)0, ringbuffer_size(rb)); // Add small token uint8_t ae[] = { 0xAE, 0xAE, 0xAE }; added = ringbuffer_insert(rb, ae, sizeof(ae)); - EXPECT_EQ(13, ringbuffer_available(rb)); + EXPECT_EQ((size_t)13, ringbuffer_available(rb)); // Get everything popped = ringbuffer_pop(rb, peek, 16); EXPECT_EQ(added, popped); - EXPECT_EQ(16, ringbuffer_available(rb)); - EXPECT_EQ(0, ringbuffer_size(rb)); + EXPECT_EQ((size_t)16, ringbuffer_available(rb)); + EXPECT_EQ((size_t)0, ringbuffer_size(rb)); ASSERT_TRUE(0 == memcmp(ae, peek, popped)); ringbuffer_free(rb); diff --git a/service/client/main.cpp b/service/client/main.cpp index 03f00f6a0..49e70d2d5 100644 --- a/service/client/main.cpp +++ b/service/client/main.cpp @@ -64,11 +64,6 @@ namespace { #define COLOR_BOLDYELLOW "\x1B[1;93m" #define CLEAR_LINE "\x1B[2K" -const char kCommandDisable[] = "disable"; -const char kCommandEnable[] = "enable"; -const char kCommandGetState[] = "get-state"; -const char kCommandIsEnabled[] = "is-enabled"; - #define CHECK_ARGS_COUNT(args, op, num, msg) \ if (!(args.size() op num)) { \ PrintError(msg); \ diff --git a/service/low_energy_client.cpp b/service/low_energy_client.cpp index a6653b78c..cc568def8 100644 --- a/service/low_energy_client.cpp +++ b/service/low_energy_client.cpp @@ -172,7 +172,6 @@ bool ProcessAdvertiseData(const AdvertiseData& adv, // The type byte is the next byte in the adv. "TLV" format. uint8_t type = data[i + 1]; - size_t uuid_len = 0; switch (type) { case HCI_EIR_MANUFACTURER_SPECIFIC_TYPE: { diff --git a/service/test/parcel_helpers_unittest.cpp b/service/test/parcel_helpers_unittest.cpp index 2cc39bebf..a9c685261 100644 --- a/service/test/parcel_helpers_unittest.cpp +++ b/service/test/parcel_helpers_unittest.cpp @@ -201,7 +201,7 @@ TEST(ParcelHelpersTest, ScanResult) { const int kTestRssi = 127; - ScanResult result0(kTestAddress, kEmptyBytes, kTestRssi); + ScanResult result0(kEmptyAddress, kEmptyBytes, kTestRssi); ScanResult result1(kTestAddress, kTestBytes, kTestRssi); EXPECT_TRUE(TestScanResult(result0)); diff --git a/stack/avrc/avrc_api.c b/stack/avrc/avrc_api.c index 5845f4dfb..77ca7d45e 100644 --- a/stack/avrc/avrc_api.c +++ b/stack/avrc/avrc_api.c @@ -186,7 +186,6 @@ static void avrc_send_continue_frag(UINT8 handle, UINT8 label) BT_HDR *p_pkt_old, *p_pkt; UINT8 *p_old, *p_data; UINT8 cr = AVCT_RSP; - tAVRC_RSP rej_rsp; p_fcb = &avrc_cb.fcb[handle]; p_pkt = p_fcb->p_fmsg; diff --git a/stack/btm/btm_ble_bgconn.c b/stack/btm/btm_ble_bgconn.c index d82f95149..23450af50 100644 --- a/stack/btm/btm_ble_bgconn.c +++ b/stack/btm/btm_ble_bgconn.c @@ -149,10 +149,8 @@ void btm_update_scanner_filter_policy(tBTM_BLE_SFP scan_policy) BOOLEAN btm_add_dev_to_controller (BOOLEAN to_add, BD_ADDR bd_addr) { tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (bd_addr); - tBLE_ADDR_TYPE addr_type = BLE_ADDR_PUBLIC; BOOLEAN started = FALSE; BD_ADDR dummy_bda = {0}; - tBT_DEVICE_TYPE dev_type; if (p_dev_rec != NULL && p_dev_rec->device_type & BT_DEVICE_TYPE_BLE) { if (to_add) { diff --git a/stack/btm/btm_ble_gap.c b/stack/btm/btm_ble_gap.c index 1f122c156..d6423701f 100644 --- a/stack/btm/btm_ble_gap.c +++ b/stack/btm/btm_ble_gap.c @@ -924,7 +924,7 @@ static bool is_resolving_list_bit_set(void *data, void *context) { tBTM_SEC_DEV_REC *p_dev_rec = data; - if (p_dev_rec->ble.in_controller_list & BTM_RESOLVING_LIST_BIT != 0) + if ((p_dev_rec->ble.in_controller_list & BTM_RESOLVING_LIST_BIT) != 0) return false; return true; @@ -944,7 +944,7 @@ static UINT8 btm_set_conn_mode_adv_init_addr(tBTM_BLE_INQ_CB *p_cb, tBLE_ADDR_TYPE *p_peer_addr_type, tBLE_ADDR_TYPE *p_own_addr_type) { - UINT8 evt_type, i = BTM_SEC_MAX_DEVICE_RECORDS; + UINT8 evt_type; tBTM_SEC_DEV_REC *p_dev_rec; evt_type = (p_cb->connectable_mode == BTM_BLE_NON_CONNECTABLE) ? \ diff --git a/stack/btm/btm_dev.c b/stack/btm/btm_dev.c index cca82ea93..84aa52a74 100644 --- a/stack/btm/btm_dev.c +++ b/stack/btm/btm_dev.c @@ -446,7 +446,6 @@ tBTM_SEC_DEV_REC *btm_find_dev(BD_ADDR bd_addr) void btm_consolidate_dev(tBTM_SEC_DEV_REC *p_target_rec) { #if BLE_INCLUDED == TRUE - tBTM_SEC_DEV_REC *p_dev_rec = NULL; tBTM_SEC_DEV_REC temp_rec = *p_target_rec; BTM_TRACE_DEBUG("%s", __func__); diff --git a/stack/btm/btm_devctl.c b/stack/btm/btm_devctl.c index 0a8f4aa5f..18e20b534 100644 --- a/stack/btm/btm_devctl.c +++ b/stack/btm/btm_devctl.c @@ -859,16 +859,15 @@ tBTM_STATUS BTM_EnableTestMode(void) } /* put device to connectable mode */ - if (!BTM_SetConnectability(BTM_CONNECTABLE, BTM_DEFAULT_CONN_WINDOW, - BTM_DEFAULT_CONN_INTERVAL) == BTM_SUCCESS) - { + if (BTM_SetConnectability(BTM_CONNECTABLE, BTM_DEFAULT_CONN_WINDOW, + BTM_DEFAULT_CONN_INTERVAL) != BTM_SUCCESS) { return BTM_NO_RESOURCES; } /* put device to discoverable mode */ - if (!BTM_SetDiscoverability(BTM_GENERAL_DISCOVERABLE, BTM_DEFAULT_DISC_WINDOW, - BTM_DEFAULT_DISC_INTERVAL) == BTM_SUCCESS) - { + if (BTM_SetDiscoverability(BTM_GENERAL_DISCOVERABLE, + BTM_DEFAULT_DISC_WINDOW, + BTM_DEFAULT_DISC_INTERVAL) != BTM_SUCCESS) { return BTM_NO_RESOURCES; } diff --git a/stack/gatt/gatt_cl.c b/stack/gatt/gatt_cl.c index f678dfce2..433a2f1dc 100644 --- a/stack/gatt/gatt_cl.c +++ b/stack/gatt/gatt_cl.c @@ -611,8 +611,12 @@ void gatt_process_error_rsp(tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UINT8 op_code, void gatt_process_prep_write_rsp (tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UINT8 op_code, UINT16 len, UINT8 *p_data) { - tGATT_VALUE value = {0}; - UINT8 *p= p_data; + UINT8 *p = p_data; + + tGATT_VALUE value = { + .conn_id = p_clcb->conn_id, + .auth_req = GATT_AUTH_REQ_NONE, + }; GATT_TRACE_ERROR("value resp op_code = %s len = %d", gatt_dbg_op_name(op_code), len); @@ -659,7 +663,7 @@ void gatt_process_prep_write_rsp (tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UINT8 op void gatt_process_notification(tGATT_TCB *p_tcb, UINT8 op_code, UINT16 len, UINT8 *p_data) { - tGATT_VALUE value = {0}; + tGATT_VALUE value; tGATT_REG *p_reg; UINT16 conn_id; tGATT_STATUS encrypt_status; @@ -674,7 +678,8 @@ void gatt_process_notification(tGATT_TCB *p_tcb, UINT8 op_code, return; } - STREAM_TO_UINT16 (value.handle, p); + memset(&value, 0, sizeof(value)); + STREAM_TO_UINT16(value.handle, p); value.len = len - 2; memcpy (value.value, p, value.len); diff --git a/stack/gatt/gatt_sr.c b/stack/gatt/gatt_sr.c index 4683e4fcd..f5c5f0f4b 100644 --- a/stack/gatt/gatt_sr.c +++ b/stack/gatt/gatt_sr.c @@ -136,7 +136,7 @@ static BOOLEAN process_read_multi_rsp (tGATT_SR_CMD *p_cmd, tGATT_STATUS status, if (status == GATT_SUCCESS) { GATT_TRACE_DEBUG("Multi read count=%d num_hdls=%d", - fixed_queue_length(&p_cmd->multi_rsp_q), + fixed_queue_length(p_cmd->multi_rsp_q), p_cmd->multi_req.num_handles); /* Wait till we get all the responses */ if (fixed_queue_length(p_cmd->multi_rsp_q) == p_cmd->multi_req.num_handles) diff --git a/stack/l2cap/l2cap_client.c b/stack/l2cap/l2cap_client.c index af51dd24d..7e8b3cb6f 100644 --- a/stack/l2cap/l2cap_client.c +++ b/stack/l2cap/l2cap_client.c @@ -201,7 +201,8 @@ static void connect_completed_cb(uint16_t local_channel_id, uint16_t error_code) } // Use default L2CAP parameters. - tL2CAP_CFG_INFO desired_parameters = { 0 }; + tL2CAP_CFG_INFO desired_parameters; + memset(&desired_parameters, 0, sizeof(desired_parameters)); if (!L2CA_ConfigReq(local_channel_id, &desired_parameters)) { LOG_ERROR(LOG_TAG, "%s error sending L2CAP config parameters.", __func__); client->callbacks.disconnected(client, client->context); @@ -209,7 +210,7 @@ static void connect_completed_cb(uint16_t local_channel_id, uint16_t error_code) } static void config_request_cb(uint16_t local_channel_id, tL2CAP_CFG_INFO *requested_parameters) { - tL2CAP_CFG_INFO response = { 0 }; + tL2CAP_CFG_INFO response; l2cap_client_t *client = find(local_channel_id); if (!client) { @@ -217,6 +218,7 @@ static void config_request_cb(uint16_t local_channel_id, tL2CAP_CFG_INFO *reques return; } + memset(&response, 0, sizeof(response)); response.result = L2CAP_CFG_OK; if (requested_parameters->mtu_present) { diff --git a/stack/smp/smp_keys.c b/stack/smp/smp_keys.c index 3e4ec2c35..a985f9778 100644 --- a/stack/smp/smp_keys.c +++ b/stack/smp/smp_keys.c @@ -58,20 +58,6 @@ static void smp_process_private_key(tSMP_CB *p_cb); static void smp_finish_nonce_generation(tSMP_CB *p_cb); static void smp_process_new_nonce(tSMP_CB *p_cb); -static const tSMP_ACT smp_encrypt_action[] = -{ - smp_generate_compare, /* SMP_GEN_COMPARE */ - smp_generate_confirm, /* SMP_GEN_CONFIRM*/ - smp_generate_stk, /* SMP_GEN_STK*/ - smp_generate_ltk_cont, /* SMP_GEN_LTK */ - smp_generate_ltk, /* SMP_GEN_DIV_LTK */ - smp_generate_rand_vector, /* SMP_GEN_RAND_V */ - smp_generate_y, /* SMP_GEN_EDIV */ - smp_generate_passkey, /* SMP_GEN_TK */ - smp_generate_srand_mrand_confirm, /* SMP_GEN_SRAND_MRAND */ - smp_generate_rand_cont /* SMP_GEN_SRAND_MRAND_CONT */ -}; - #define SMP_PASSKEY_MASK 0xfff00000 void smp_debug_print_nbyte_little_endian(UINT8 *p, const UINT8 *key_name, UINT8 len) diff --git a/test/bluedroidtest/bluedroidtest.c b/test/bluedroidtest/bluedroidtest.c index ac727d872..62db3e12d 100644 --- a/test/bluedroidtest/bluedroidtest.c +++ b/test/bluedroidtest/bluedroidtest.c @@ -88,7 +88,6 @@ static unsigned char bt_enabled = 0; ************************************************************************************/ static void process_cmd(char *p, unsigned char is_job); -static void job_handler(void *param); static void bdt_log(const char *fmt_str, ...); @@ -181,61 +180,6 @@ static const char* dump_bt_status(bt_status_t status) } } -static void hex_dump(char *msg, void *data, int size, int trunc) -{ - unsigned char *p = data; - unsigned char c; - int n; - char bytestr[4] = {0}; - char addrstr[10] = {0}; - char hexstr[ 16*3 + 5] = {0}; - char charstr[16*1 + 5] = {0}; - - bdt_log("%s \n", msg); - - /* truncate */ - if(trunc && (size>32)) - size = 32; - - for(n=1;n<=size;n++) { - if (n%16 == 1) { - /* store address for this line */ - snprintf(addrstr, sizeof(addrstr), "%.4x", - (unsigned int)((uintptr_t)p-(uintptr_t)data) ); - } - - c = *p; - if (isalnum(c) == 0) { - c = '.'; - } - - /* store hex str (for left side) */ - snprintf(bytestr, sizeof(bytestr), "%02X ", *p); - strncat(hexstr, bytestr, sizeof(hexstr)-strlen(hexstr)-1); - - /* store char str (for right side) */ - snprintf(bytestr, sizeof(bytestr), "%c", c); - strncat(charstr, bytestr, sizeof(charstr)-strlen(charstr)-1); - - if(n%16 == 0) { - /* line completed */ - bdt_log("[%4.4s] %-50.50s %s\n", addrstr, hexstr, charstr); - hexstr[0] = 0; - charstr[0] = 0; - } else if(n%8 == 0) { - /* half line: add whitespaces */ - strncat(hexstr, " ", sizeof(hexstr)-strlen(hexstr)-1); - strncat(charstr, " ", sizeof(charstr)-strlen(charstr)-1); - } - p++; /* next byte */ - } - - if (strlen(hexstr) > 0) { - /* print rest of buffer if not empty */ - bdt_log("[%4.4s] %-50.50s %s\n", addrstr, hexstr, charstr); - } -} - /******************************************************************************* ** Console helper functions *******************************************************************************/ @@ -660,7 +604,6 @@ void bdt_cleanup(void) void do_help(char UNUSED *p) { int i = 0; - int max = 0; char line[128]; int pos = 0; @@ -779,11 +722,6 @@ static void process_cmd(char *p, unsigned char is_job) int main (int UNUSED argc, char UNUSED *argv[]) { - int opt; - char cmd[128]; - int args_processed = 0; - int pid = -1; - config_permissions(); bdt_log("\n:::::::::::::::::::::::::::::::::::::::::::::::::::"); bdt_log(":: Bluedroid test app starting"); -- 2.11.0