From bcaa36df771fa46efbddf76b79dde15efb0649a3 Mon Sep 17 00:00:00 2001 From: Chris Manton Date: Sat, 6 Mar 2021 15:35:36 -0800 Subject: [PATCH] Replace BT_HDR => BT_HDR_RIGID Toward structurally sound code Bug: 163134718 Test: gd/cert/run Tag: #refactor Change-Id: Ib6569c0c19c7f1e6f4b9e9c1abc27e30d1e33fbf --- bta/ag/bta_ag_int.h | 2 +- bta/ag/bta_ag_main.cc | 2 +- bta/av/bta_av_aact.cc | 2 +- bta/av/bta_av_act.cc | 4 +-- bta/av/bta_av_api.cc | 10 +++---- bta/av/bta_av_ci.cc | 2 +- bta/av/bta_av_int.h | 50 +++++++++++++++++++---------------- bta/av/bta_av_main.cc | 2 +- bta/dm/bta_dm_int.h | 20 +++++++------- bta/dm/bta_dm_main.cc | 2 +- bta/gatt/bta_gattc_act.cc | 6 ++--- bta/gatt/bta_gattc_api.cc | 2 +- bta/gatt/bta_gattc_int.h | 24 ++++++++--------- bta/gatt/bta_gattc_main.cc | 2 +- bta/gatt/bta_gatts_api.cc | 8 +++--- bta/gatt/bta_gatts_int.h | 18 ++++++------- bta/gatt/bta_gatts_main.cc | 2 +- bta/hd/bta_hd_api.cc | 8 +++--- bta/hd/bta_hd_int.h | 16 +++++------ bta/hd/bta_hd_main.cc | 2 +- bta/hf_client/bta_hf_client_api.cc | 6 ++--- bta/hf_client/bta_hf_client_int.h | 12 ++++----- bta/hf_client/bta_hf_client_main.cc | 2 +- bta/hf_client/bta_hf_client_sco.cc | 4 +-- bta/hh/bta_hh_int.h | 18 ++++++------- bta/hh/bta_hh_main.cc | 2 +- bta/pan/bta_pan_act.cc | 4 +-- bta/pan/bta_pan_api.cc | 4 +-- bta/pan/bta_pan_ci.cc | 2 +- bta/pan/bta_pan_int.h | 16 +++++------ bta/pan/bta_pan_main.cc | 2 +- bta/sys/bta_sys.h | 5 +++- bta/sys/bta_sys_main.cc | 10 ++++--- bta/test/common/mock_stack_acl.cc | 6 +++-- bta/test/common/mock_stack_btm_sco.cc | 4 ++- btif/include/btif_common.h | 2 +- btif/src/btif_a2dp_sink.cc | 32 +++++++++++++--------- internal_include/bte.h | 2 +- 38 files changed, 169 insertions(+), 148 deletions(-) diff --git a/bta/ag/bta_ag_int.h b/bta/ag/bta_ag_int.h index ef2000888..6640808ef 100644 --- a/bta/ag/bta_ag_int.h +++ b/bta/ag/bta_ag_int.h @@ -296,7 +296,7 @@ extern const tBTA_AG_HF_IND bta_ag_local_hf_ind_cfg[]; /***************************************************************************** * Function prototypes ****************************************************************************/ -bool bta_ag_hdl_event(BT_HDR* p_msg); +bool bta_ag_hdl_event(BT_HDR_RIGID* p_msg); /* API functions */ extern void bta_ag_api_enable(tBTA_AG_CBACK* p_cback); diff --git a/bta/ag/bta_ag_main.cc b/bta/ag/bta_ag_main.cc index b87cbfdc6..583102fa8 100644 --- a/bta/ag/bta_ag_main.cc +++ b/bta/ag/bta_ag_main.cc @@ -760,7 +760,7 @@ void bta_ag_sm_execute_by_handle(uint16_t handle, uint16_t event, * @param p_msg event message * @return True to free p_msg, or False if p_msg is freed within this function */ -bool bta_ag_hdl_event(BT_HDR* p_msg) { +bool bta_ag_hdl_event(BT_HDR_RIGID* p_msg) { switch (p_msg->event) { case BTA_AG_RING_TIMEOUT_EVT: case BTA_AG_SVC_TIMEOUT_EVT: diff --git a/bta/av/bta_av_aact.cc b/bta/av/bta_av_aact.cc index c6ce6a84c..6e36602de 100644 --- a/bta/av/bta_av_aact.cc +++ b/bta/av/bta_av_aact.cc @@ -2183,7 +2183,7 @@ void bta_av_start_ok(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) { bool initiator = false; bool suspend = false; uint8_t new_role = p_scb->role; - BT_HDR hdr; + BT_HDR_RIGID hdr; tHCI_ROLE cur_role; uint8_t local_tsep = p_scb->seps[p_scb->sep_idx].tsep; diff --git a/bta/av/bta_av_act.cc b/bta/av/bta_av_act.cc index bcd1aa357..f6c7e2cec 100644 --- a/bta/av/bta_av_act.cc +++ b/bta/av/bta_av_act.cc @@ -183,7 +183,7 @@ static void bta_av_del_sdp_rec(uint32_t* p_sdp_handle) { * ******************************************************************************/ static void bta_av_avrc_sdp_cback(UNUSED_ATTR uint16_t status) { - BT_HDR* p_msg = (BT_HDR*)osi_malloc(sizeof(BT_HDR)); + BT_HDR_RIGID* p_msg = (BT_HDR_RIGID*)osi_malloc(sizeof(BT_HDR_RIGID)); p_msg->event = BTA_AV_SDP_AVRC_DISC_EVT; @@ -1291,7 +1291,7 @@ void bta_av_conn_chg(tBTA_AV_DATA* p_data) { * ******************************************************************************/ void bta_av_disable(tBTA_AV_CB* p_cb, UNUSED_ATTR tBTA_AV_DATA* p_data) { - BT_HDR hdr; + BT_HDR_RIGID hdr; bool disabling_in_progress = false; uint16_t xx; diff --git a/bta/av/bta_av_api.cc b/bta/av/bta_av_api.cc index cf3bb50bb..58d3cba2c 100644 --- a/bta/av/bta_av_api.cc +++ b/bta/av/bta_av_api.cc @@ -76,7 +76,7 @@ void BTA_AvEnable(tBTA_AV_FEAT features, tBTA_AV_CBACK* p_cback) { * ******************************************************************************/ void BTA_AvDisable(void) { - BT_HDR* p_buf = (BT_HDR*)osi_malloc(sizeof(BT_HDR)); + BT_HDR_RIGID* p_buf = (BT_HDR_RIGID*)osi_malloc(sizeof(BT_HDR_RIGID)); bta_sys_deregister(BTA_ID_AV); p_buf->event = BTA_AV_API_DISABLE_EVT; @@ -126,7 +126,7 @@ void BTA_AvRegister(tBTA_AV_CHNL chnl, const char* p_service_name, * ******************************************************************************/ void BTA_AvDeregister(tBTA_AV_HNDL hndl) { - BT_HDR* p_buf = (BT_HDR*)osi_malloc(sizeof(BT_HDR)); + BT_HDR_RIGID* p_buf = (BT_HDR_RIGID*)osi_malloc(sizeof(BT_HDR_RIGID)); p_buf->layer_specific = hndl; p_buf->event = BTA_AV_API_DEREGISTER_EVT; @@ -176,7 +176,7 @@ void BTA_AvOpen(const RawAddress& bd_addr, tBTA_AV_HNDL handle, bool use_rc, void BTA_AvClose(tBTA_AV_HNDL handle) { LOG_INFO("%s: bta_handle:0x%x", __func__, handle); - BT_HDR* p_buf = (BT_HDR*)osi_malloc(sizeof(BT_HDR)); + BT_HDR_RIGID* p_buf = (BT_HDR_RIGID*)osi_malloc(sizeof(BT_HDR_RIGID)); p_buf->event = BTA_AV_API_CLOSE_EVT; p_buf->layer_specific = handle; @@ -217,7 +217,7 @@ void BTA_AvDisconnect(const RawAddress& bd_addr) { void BTA_AvStart(tBTA_AV_HNDL handle) { LOG_INFO("Starting audio/video stream data transfer bta_handle:%hhu", handle); - BT_HDR* p_buf = (BT_HDR*)osi_malloc(sizeof(BT_HDR)); + BT_HDR_RIGID* p_buf = (BT_HDR_RIGID*)osi_malloc(sizeof(BT_HDR_RIGID)); p_buf->event = BTA_AV_API_START_EVT; p_buf->layer_specific = handle; @@ -237,7 +237,7 @@ void BTA_AvStart(tBTA_AV_HNDL handle) { void BTA_AvOffloadStart(tBTA_AV_HNDL hndl) { LOG_INFO("%s: bta_handle=0x%x", __func__, hndl); - BT_HDR* p_buf = (BT_HDR*)osi_malloc(sizeof(BT_HDR)); + BT_HDR_RIGID* p_buf = (BT_HDR_RIGID*)osi_malloc(sizeof(BT_HDR_RIGID)); p_buf->event = BTA_AV_API_OFFLOAD_START_EVT; p_buf->layer_specific = hndl; diff --git a/bta/av/bta_av_ci.cc b/bta/av/bta_av_ci.cc index 8a1992476..b191e8216 100644 --- a/bta/av/bta_av_ci.cc +++ b/bta/av/bta_av_ci.cc @@ -41,7 +41,7 @@ * ******************************************************************************/ void bta_av_ci_src_data_ready(tBTA_AV_CHNL chnl) { - BT_HDR* p_buf = (BT_HDR*)osi_malloc(sizeof(BT_HDR)); + BT_HDR_RIGID* p_buf = (BT_HDR_RIGID*)osi_malloc(sizeof(BT_HDR_RIGID)); p_buf->layer_specific = chnl; p_buf->event = BTA_AV_CI_SRC_DATA_READY_EVT; diff --git a/bta/av/bta_av_int.h b/bta/av/bta_av_int.h index a450b9738..3be4458d8 100644 --- a/bta/av/bta_av_int.h +++ b/bta/av/bta_av_int.h @@ -219,14 +219,14 @@ typedef struct { /* data type for BTA_AV_API_ENABLE_EVT */ typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; tBTA_AV_CBACK* p_cback; tBTA_AV_FEAT features; } tBTA_AV_API_ENABLE; /* data type for BTA_AV_API_REGISTER_EVT */ typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; char p_service_name[BTA_SERVICE_NAME_LEN + 1]; uint8_t app_id; tBTA_AV_SINK_DATA_CBACK* p_app_sink_data_cback; @@ -254,7 +254,7 @@ inline std::string bta_av_role_switch_result_text( /* data type for BTA_AV_API_OPEN_EVT */ typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; RawAddress bd_addr; bool use_rc; tBTA_AV_RS_RES switch_res; @@ -263,7 +263,7 @@ typedef struct { /* data type for BTA_AV_API_STOP_EVT */ typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; bool suspend; bool flush; bool reconfig_stop; // True if the stream is stopped for reconfiguration @@ -271,20 +271,20 @@ typedef struct { /* data type for BTA_AV_API_DISCONNECT_EVT */ typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; RawAddress bd_addr; } tBTA_AV_API_DISCNT; /* data type for BTA_AV_API_PROTECT_REQ_EVT */ typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; uint8_t* p_data; uint16_t len; } tBTA_AV_API_PROTECT_REQ; /* data type for BTA_AV_API_PROTECT_RSP_EVT */ typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; uint8_t* p_data; uint16_t len; uint8_t error_code; @@ -292,27 +292,31 @@ typedef struct { /* data type for BTA_AV_API_REMOTE_CMD_EVT */ typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; tAVRC_MSG_PASS msg; uint8_t label; } tBTA_AV_API_REMOTE_CMD; /* data type for BTA_AV_API_VENDOR_CMD_EVT and RSP */ typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; tAVRC_MSG_VENDOR msg; uint8_t label; } tBTA_AV_API_VENDOR; /* data type for BTA_AV_API_RC_OPEN_EVT */ -typedef struct { BT_HDR hdr; } tBTA_AV_API_OPEN_RC; +typedef struct { + BT_HDR_RIGID hdr; +} tBTA_AV_API_OPEN_RC; /* data type for BTA_AV_API_RC_CLOSE_EVT */ -typedef struct { BT_HDR hdr; } tBTA_AV_API_CLOSE_RC; +typedef struct { + BT_HDR_RIGID hdr; +} tBTA_AV_API_CLOSE_RC; /* data type for BTA_AV_API_META_RSP_EVT */ typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; bool is_rsp; uint8_t label; tBTA_AV_CODE rsp_code; @@ -321,7 +325,7 @@ typedef struct { /* data type for BTA_AV_API_RECONFIG_EVT */ typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; uint8_t codec_info[AVDT_CODEC_SIZE]; /* codec configuration */ uint8_t* p_protect_info; uint8_t num_protect; @@ -331,7 +335,7 @@ typedef struct { /* data type for BTA_AV_CI_SETCONFIG_OK_EVT and BTA_AV_CI_SETCONFIG_FAIL_EVT */ typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; tBTA_AV_HNDL hndl; uint8_t err_code; uint8_t category; @@ -343,7 +347,7 @@ typedef struct { /* data type for all stream events from AVDTP */ typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; AvdtpSepConfig cfg; /* configuration/capabilities parameters */ tAVDT_CTRL msg; /* AVDTP callback message parameters */ RawAddress bd_addr; /* bd address */ @@ -355,7 +359,7 @@ typedef struct { /* data type for BTA_AV_AVRC_MSG_EVT */ typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; tAVRC_MSG msg; uint8_t handle; uint8_t label; @@ -364,33 +368,33 @@ typedef struct { /* data type for BTA_AV_AVRC_OPEN_EVT, BTA_AV_AVRC_CLOSE_EVT */ typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; RawAddress peer_addr; uint8_t handle; } tBTA_AV_RC_CONN_CHG; /* data type for BTA_AV_CONN_CHG_EVT */ typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; RawAddress peer_addr; bool is_up; } tBTA_AV_CONN_CHG; /* data type for BTA_AV_ROLE_CHANGE_EVT */ typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; uint8_t new_role; uint8_t hci_status; } tBTA_AV_ROLE_RES; /* data type for BTA_AV_SDP_DISC_OK_EVT */ typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; } tBTA_AV_SDP_RES; /* data type for BTA_AV_API_OFFLOAD_RSP_EVT */ typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; tBTA_AV_STATUS status; } tBTA_AV_API_STATUS_RSP; @@ -419,7 +423,7 @@ typedef uint8_t tBTA_AV_ROLE; /* union of all event datatypes */ union tBTA_AV_DATA { - BT_HDR hdr; + BT_HDR_RIGID hdr; tBTA_AV_API_ENABLE api_enable; tBTA_AV_API_REG api_reg; tBTA_AV_API_OPEN api_open; @@ -711,7 +715,7 @@ extern void bta_av_sm_execute(tBTA_AV_CB* p_cb, uint16_t event, tBTA_AV_DATA* p_data); extern void bta_av_ssm_execute(tBTA_AV_SCB* p_scb, uint16_t event, tBTA_AV_DATA* p_data); -extern bool bta_av_hdl_event(BT_HDR* p_msg); +extern bool bta_av_hdl_event(BT_HDR_RIGID* p_msg); extern const char* bta_av_evt_code(uint16_t evt_code); extern bool bta_av_switch_if_needed(tBTA_AV_SCB* p_scb); extern bool bta_av_link_role_ok(tBTA_AV_SCB* p_scb, uint8_t bits); diff --git a/bta/av/bta_av_main.cc b/bta/av/bta_av_main.cc index 0ef5a76e7..9123d037d 100644 --- a/bta/av/bta_av_main.cc +++ b/bta/av/bta_av_main.cc @@ -1212,7 +1212,7 @@ void bta_av_sm_execute(tBTA_AV_CB* p_cb, uint16_t event, tBTA_AV_DATA* p_data) { * Returns bool * ******************************************************************************/ -bool bta_av_hdl_event(BT_HDR* p_msg) { +bool bta_av_hdl_event(BT_HDR_RIGID* p_msg) { if (p_msg->event > BTA_AV_LAST_EVT) { return true; /* to free p_msg */ } diff --git a/bta/dm/bta_dm_int.h b/bta/dm/bta_dm_int.h index cd19afc61..6e433d2ef 100644 --- a/bta/dm/bta_dm_int.h +++ b/bta/dm/bta_dm_int.h @@ -71,14 +71,14 @@ enum { /* data type for BTA_DM_API_SEARCH_EVT */ typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; tBTA_SERVICE_MASK services; tBTA_DM_SEARCH_CBACK* p_cback; } tBTA_DM_API_SEARCH; /* data type for BTA_DM_API_DISCOVER_EVT */ typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; RawAddress bd_addr; tBTA_DM_SEARCH_CBACK* p_cback; tBT_TRANSPORT transport; @@ -92,7 +92,7 @@ typedef struct { } tBTA_DM_API_PIN_REPLY; typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; RawAddress bd_addr; tBTM_IO_CAP io_cap; tBTM_OOB_DATA oob_data; @@ -108,25 +108,25 @@ typedef struct { /* data type for BTA_DM_REMT_NAME_EVT */ typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; tBTA_DM_SEARCH result; } tBTA_DM_REM_NAME; /* data type for tBTA_DM_DISC_RESULT */ typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; tBTA_DM_SEARCH result; } tBTA_DM_DISC_RESULT; /* data type for BTA_DM_INQUIRY_CMPL_EVT */ typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; uint8_t num; } tBTA_DM_INQUIRY_CMPL; /* data type for BTA_DM_SDP_RESULT_EVT */ typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; uint16_t sdp_result; } tBTA_DM_SDP_RESULT; @@ -142,14 +142,14 @@ typedef struct { } tBTA_DM_API_ADD_DEVICE; typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; bool enable; } tBTA_DM_API_BLE_FEATURE; /* union of all data types */ typedef union { /* GKI event buffer header */ - BT_HDR hdr; + BT_HDR_RIGID hdr; tBTA_DM_API_SEARCH search; @@ -468,7 +468,7 @@ extern tBTA_DM_SEARCH_CB bta_dm_search_cb; /* DI control block */ extern tBTA_DM_DI_CB bta_dm_di_cb; -extern bool bta_dm_search_sm_execute(BT_HDR* p_msg); +extern bool bta_dm_search_sm_execute(BT_HDR_RIGID* p_msg); extern void bta_dm_search_sm_disable(void); extern void bta_dm_enable(tBTA_DM_SEC_CBACK*); diff --git a/bta/dm/bta_dm_main.cc b/bta/dm/bta_dm_main.cc index 02f04ceed..470850082 100644 --- a/bta/dm/bta_dm_main.cc +++ b/bta/dm/bta_dm_main.cc @@ -59,7 +59,7 @@ uint8_t bta_dm_search_get_state() { return bta_dm_search_cb.state; } * Returns void * ******************************************************************************/ -bool bta_dm_search_sm_execute(BT_HDR* p_msg) { +bool bta_dm_search_sm_execute(BT_HDR_RIGID* p_msg) { APPL_TRACE_EVENT("bta_dm_search_sm_execute state:%d, event:0x%x", bta_dm_search_cb.state, p_msg->event); diff --git a/bta/gatt/bta_gattc_act.cc b/bta/gatt/bta_gattc_act.cc index ee9f460ba..7a2134917 100644 --- a/bta/gatt/bta_gattc_act.cc +++ b/bta/gatt/bta_gattc_act.cc @@ -236,7 +236,7 @@ void bta_gattc_deregister(tBTA_GATTC_RCB* p_clreg) { p_clreg->dereg_pending = true; - BT_HDR buf; + BT_HDR_RIGID buf; buf.event = BTA_GATTC_API_CLOSE_EVT; buf.layer_specific = bta_gattc_cb.clcb[i].bta_conn_id; bta_gattc_close(&bta_gattc_cb.clcb[i], (tBTA_GATTC_DATA*)&buf); @@ -245,7 +245,7 @@ void bta_gattc_deregister(tBTA_GATTC_RCB* p_clreg) { /** process connect API request */ void bta_gattc_process_api_open(tBTA_GATTC_DATA* p_msg) { - uint16_t event = ((BT_HDR*)p_msg)->event; + uint16_t event = ((BT_HDR_RIGID*)p_msg)->event; tBTA_GATTC_RCB* p_clreg = bta_gattc_cl_get_regcb(p_msg->api_conn.client_if); if (!p_clreg) { @@ -277,7 +277,7 @@ void bta_gattc_process_api_open(tBTA_GATTC_DATA* p_msg) { void bta_gattc_process_api_open_cancel(tBTA_GATTC_DATA* p_msg) { CHECK(p_msg != nullptr); - uint16_t event = ((BT_HDR*)p_msg)->event; + uint16_t event = ((BT_HDR_RIGID*)p_msg)->event; if (!p_msg->api_cancel_conn.is_direct) { LOG_DEBUG("Cancel GATT client background connection"); diff --git a/bta/gatt/bta_gattc_api.cc b/bta/gatt/bta_gattc_api.cc index 185261fd7..93af8c159 100644 --- a/bta/gatt/bta_gattc_api.cc +++ b/bta/gatt/bta_gattc_api.cc @@ -181,7 +181,7 @@ void BTA_GATTC_CancelOpen(tGATT_IF client_if, const RawAddress& remote_bda, * ******************************************************************************/ void BTA_GATTC_Close(uint16_t conn_id) { - BT_HDR* p_buf = (BT_HDR*)osi_malloc(sizeof(BT_HDR)); + BT_HDR_RIGID* p_buf = (BT_HDR_RIGID*)osi_malloc(sizeof(BT_HDR_RIGID)); p_buf->event = BTA_GATTC_API_CLOSE_EVT; p_buf->layer_specific = conn_id; diff --git a/bta/gatt/bta_gattc_int.h b/bta/gatt/bta_gattc_int.h index 6b2b8d865..161a413bf 100644 --- a/bta/gatt/bta_gattc_int.h +++ b/bta/gatt/bta_gattc_int.h @@ -85,7 +85,7 @@ typedef uint16_t tBTA_GATTC_INT_EVT; /* internal strucutre for GATTC register API */ typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; RawAddress remote_bda; tGATT_IF client_if; bool is_direct; @@ -97,7 +97,7 @@ typedef struct { typedef tBTA_GATTC_API_OPEN tBTA_GATTC_API_CANCEL_OPEN; typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; tGATT_AUTH_REQ auth_req; // read by handle data @@ -114,7 +114,7 @@ typedef struct { } tBTA_GATTC_API_READ; typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; tGATT_AUTH_REQ auth_req; uint16_t handle; tGATT_WRITE_TYPE write_type; @@ -126,45 +126,45 @@ typedef struct { } tBTA_GATTC_API_WRITE; typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; bool is_execute; } tBTA_GATTC_API_EXEC; typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; uint16_t cid; } tBTA_GATTC_API_CONFIRM; typedef tGATT_CL_COMPLETE tBTA_GATTC_CMPL; typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; uint8_t op_code; tGATT_STATUS status; tBTA_GATTC_CMPL* p_cmpl; } tBTA_GATTC_OP_CMPL; typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; bluetooth::Uuid* p_srvc_uuid; } tBTA_GATTC_API_SEARCH; typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; tGATT_AUTH_REQ auth_req; uint8_t num_attr; uint16_t handles[GATT_MAX_READ_MULTI_HANDLES]; } tBTA_GATTC_API_READ_MULTI; typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; uint16_t mtu; GATT_CONFIGURE_MTU_OP_CB mtu_cb; void* mtu_cb_data; } tBTA_GATTC_API_CFG_MTU; typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; RawAddress remote_bda; tGATT_IF client_if; uint8_t role; @@ -173,7 +173,7 @@ typedef struct { } tBTA_GATTC_INT_CONN; typedef union { - BT_HDR hdr; + BT_HDR_RIGID hdr; tBTA_GATTC_API_OPEN api_conn; tBTA_GATTC_API_CANCEL_OPEN api_cancel_conn; tBTA_GATTC_API_READ api_read; @@ -323,7 +323,7 @@ extern tBTA_GATTC_CB bta_gattc_cb; /***************************************************************************** * Function prototypes ****************************************************************************/ -extern bool bta_gattc_hdl_event(BT_HDR* p_msg); +extern bool bta_gattc_hdl_event(BT_HDR_RIGID* p_msg); extern bool bta_gattc_sm_execute(tBTA_GATTC_CLCB* p_clcb, uint16_t event, tBTA_GATTC_DATA* p_data); diff --git a/bta/gatt/bta_gattc_main.cc b/bta/gatt/bta_gattc_main.cc index afcf27191..0227ce32a 100644 --- a/bta/gatt/bta_gattc_main.cc +++ b/bta/gatt/bta_gattc_main.cc @@ -361,7 +361,7 @@ bool bta_gattc_sm_execute(tBTA_GATTC_CLCB* p_clcb, uint16_t event, * Returns bool * ******************************************************************************/ -bool bta_gattc_hdl_event(BT_HDR* p_msg) { +bool bta_gattc_hdl_event(BT_HDR_RIGID* p_msg) { tBTA_GATTC_CLCB* p_clcb = NULL; bool rt = true; #if (BTA_GATT_DEBUG == TRUE) diff --git a/bta/gatt/bta_gatts_api.cc b/bta/gatt/bta_gatts_api.cc index 6403034a5..5e49a7c93 100644 --- a/bta/gatt/bta_gatts_api.cc +++ b/bta/gatt/bta_gatts_api.cc @@ -61,7 +61,7 @@ void BTA_GATTS_Disable(void) { return; } - BT_HDR* p_buf = (BT_HDR*)osi_malloc(sizeof(BT_HDR)); + BT_HDR_RIGID* p_buf = (BT_HDR_RIGID*)osi_malloc(sizeof(BT_HDR_RIGID)); p_buf->event = BTA_GATTS_API_DISABLE_EVT; bta_sys_sendmsg(p_buf); bta_sys_deregister(BTA_ID_GATTS); @@ -193,7 +193,7 @@ extern void BTA_GATTS_AddService(tGATT_IF server_if, * ******************************************************************************/ void BTA_GATTS_DeleteService(uint16_t service_id) { - BT_HDR* p_buf = (BT_HDR*)osi_malloc(sizeof(BT_HDR)); + BT_HDR_RIGID* p_buf = (BT_HDR_RIGID*)osi_malloc(sizeof(BT_HDR_RIGID)); p_buf->event = BTA_GATTS_API_DEL_SRVC_EVT; p_buf->layer_specific = service_id; @@ -213,7 +213,7 @@ void BTA_GATTS_DeleteService(uint16_t service_id) { * ******************************************************************************/ void BTA_GATTS_StopService(uint16_t service_id) { - BT_HDR* p_buf = (BT_HDR*)osi_malloc(sizeof(BT_HDR)); + BT_HDR_RIGID* p_buf = (BT_HDR_RIGID*)osi_malloc(sizeof(BT_HDR_RIGID)); p_buf->event = BTA_GATTS_API_STOP_SRVC_EVT; p_buf->layer_specific = service_id; @@ -355,7 +355,7 @@ void BTA_GATTS_CancelOpen(tGATT_IF server_if, const RawAddress& remote_bda, * ******************************************************************************/ void BTA_GATTS_Close(uint16_t conn_id) { - BT_HDR* p_buf = (BT_HDR*)osi_malloc(sizeof(BT_HDR)); + BT_HDR_RIGID* p_buf = (BT_HDR_RIGID*)osi_malloc(sizeof(BT_HDR_RIGID)); p_buf->event = BTA_GATTS_API_CLOSE_EVT; p_buf->layer_specific = conn_id; diff --git a/bta/gatt/bta_gatts_int.h b/bta/gatt/bta_gatts_int.h index 42a3a6606..25cdf4923 100644 --- a/bta/gatt/bta_gatts_int.h +++ b/bta/gatt/bta_gatts_int.h @@ -61,28 +61,28 @@ typedef uint16_t tBTA_GATTS_INT_EVT; /* internal strucutre for GATTC register API */ typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; bluetooth::Uuid app_uuid; tBTA_GATTS_CBACK* p_cback; bool eatt_support; } tBTA_GATTS_API_REG; typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; tGATT_IF server_if; } tBTA_GATTS_INT_START_IF; typedef tBTA_GATTS_INT_START_IF tBTA_GATTS_API_DEREG; typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; tGATT_IF server_if; btgatt_db_element_t* service; uint16_t count; } tBTA_GATTS_API_ADD_SERVICE; typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; uint16_t attr_id; uint16_t len; bool need_confirm; @@ -90,19 +90,19 @@ typedef struct { } tBTA_GATTS_API_INDICATION; typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; uint32_t trans_id; tGATT_STATUS status; tGATTS_RSP* p_rsp; } tBTA_GATTS_API_RSP; typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; tBT_TRANSPORT transport; } tBTA_GATTS_API_START; typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; RawAddress remote_bda; tGATT_IF server_if; bool is_direct; @@ -113,7 +113,7 @@ typedef struct { typedef tBTA_GATTS_API_OPEN tBTA_GATTS_API_CANCEL_OPEN; typedef union { - BT_HDR hdr; + BT_HDR_RIGID hdr; tBTA_GATTS_API_REG api_reg; tBTA_GATTS_API_DEREG api_dereg; tBTA_GATTS_API_ADD_SERVICE api_add_service; @@ -159,7 +159,7 @@ extern tBTA_GATTS_CB bta_gatts_cb; /***************************************************************************** * Function prototypes ****************************************************************************/ -extern bool bta_gatts_hdl_event(BT_HDR* p_msg); +extern bool bta_gatts_hdl_event(BT_HDR_RIGID* p_msg); extern void bta_gatts_api_disable(tBTA_GATTS_CB* p_cb); extern void bta_gatts_api_enable(tBTA_GATTS_CB* p_cb, tBTA_GATTS_DATA* p_data); diff --git a/bta/gatt/bta_gatts_main.cc b/bta/gatt/bta_gatts_main.cc index 555582a43..497f31558 100644 --- a/bta/gatt/bta_gatts_main.cc +++ b/bta/gatt/bta_gatts_main.cc @@ -39,7 +39,7 @@ tBTA_GATTS_CB bta_gatts_cb; * Returns void * ******************************************************************************/ -bool bta_gatts_hdl_event(BT_HDR* p_msg) { +bool bta_gatts_hdl_event(BT_HDR_RIGID* p_msg) { tBTA_GATTS_CB* p_cb = &bta_gatts_cb; switch (p_msg->event) { diff --git a/bta/hd/bta_hd_api.cc b/bta/hd/bta_hd_api.cc index d01277007..4b33cd3ab 100644 --- a/bta/hd/bta_hd_api.cc +++ b/bta/hd/bta_hd_api.cc @@ -79,7 +79,7 @@ void BTA_HdDisable(void) { bta_sys_deregister(BTA_ID_HD); - BT_HDR* p_buf = (BT_HDR*)osi_malloc(sizeof(BT_HDR)); + BT_HDR_RIGID* p_buf = (BT_HDR_RIGID*)osi_malloc(sizeof(BT_HDR_RIGID)); p_buf->event = BTA_HD_API_DISABLE_EVT; bta_sys_sendmsg(p_buf); } @@ -152,7 +152,7 @@ extern void BTA_HdRegisterApp(tBTA_HD_APP_INFO* p_app_info, extern void BTA_HdUnregisterApp(void) { APPL_TRACE_API("%s", __func__); - BT_HDR* p_buf = (BT_HDR*)osi_malloc(sizeof(BT_HDR)); + BT_HDR_RIGID* p_buf = (BT_HDR_RIGID*)osi_malloc(sizeof(BT_HDR_RIGID)); p_buf->event = BTA_HD_API_UNREGISTER_APP_EVT; bta_sys_sendmsg(p_buf); @@ -203,7 +203,7 @@ extern void BTA_HdSendReport(tBTA_HD_REPORT* p_report) { extern void BTA_HdVirtualCableUnplug(void) { APPL_TRACE_API("%s", __func__); - BT_HDR* p_buf = (BT_HDR*)osi_malloc(sizeof(BT_HDR)); + BT_HDR_RIGID* p_buf = (BT_HDR_RIGID*)osi_malloc(sizeof(BT_HDR_RIGID)); p_buf->event = BTA_HD_API_VC_UNPLUG_EVT; bta_sys_sendmsg(p_buf); @@ -242,7 +242,7 @@ extern void BTA_HdConnect(const RawAddress& addr) { ******************************************************************************/ extern void BTA_HdDisconnect(void) { APPL_TRACE_API("%s", __func__); - BT_HDR* p_buf = (BT_HDR*)osi_malloc(sizeof(BT_HDR)); + BT_HDR_RIGID* p_buf = (BT_HDR_RIGID*)osi_malloc(sizeof(BT_HDR_RIGID)); p_buf->event = BTA_HD_API_DISCONNECT_EVT; bta_sys_sendmsg(p_buf); diff --git a/bta/hd/bta_hd_int.h b/bta/hd/bta_hd_int.h index a433ebd59..67f282bc0 100644 --- a/bta/hd/bta_hd_int.h +++ b/bta/hd/bta_hd_int.h @@ -63,7 +63,7 @@ typedef uint16_t tBTA_HD_INT_EVT; #define BTA_HD_INVALID_EVT (BTA_HD_API_DISABLE_EVT + 1) typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; tBTA_HD_CBACK* p_cback; } tBTA_HD_API_ENABLE; @@ -80,7 +80,7 @@ typedef struct { #define BTA_HD_STATE_REMOVING 0x05 typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; char name[BTA_HD_APP_NAME_LEN]; char description[BTA_HD_APP_DESCRIPTION_LEN]; char provider[BTA_HD_APP_PROVIDER_LEN]; @@ -95,7 +95,7 @@ typedef struct { #define BTA_HD_REPORT_LEN HID_DEV_MTU_SIZE typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; bool use_intr; uint8_t type; uint8_t id; @@ -104,18 +104,18 @@ typedef struct { } tBTA_HD_SEND_REPORT; typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; RawAddress addr; } tBTA_HD_DEVICE_CTRL; typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; uint8_t error; } tBTA_HD_REPORT_ERR; /* union of all event data types */ typedef union { - BT_HDR hdr; + BT_HDR_RIGID hdr; tBTA_HD_API_ENABLE api_enable; tBTA_HD_REGISTER_APP register_app; tBTA_HD_SEND_REPORT send_report; @@ -124,7 +124,7 @@ typedef union { } tBTA_HD_DATA; typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; RawAddress addr; uint32_t data; BT_HDR* p_data; @@ -150,7 +150,7 @@ extern tBTA_HD_CB bta_hd_cb; /***************************************************************************** * Function prototypes ****************************************************************************/ -extern bool bta_hd_hdl_event(BT_HDR* p_msg); +extern bool bta_hd_hdl_event(BT_HDR_RIGID* p_msg); extern void bta_hd_api_enable(tBTA_HD_DATA* p_data); extern void bta_hd_api_disable(void); diff --git a/bta/hd/bta_hd_main.cc b/bta/hd/bta_hd_main.cc index 0f90db8ee..022f8fe6c 100644 --- a/bta/hd/bta_hd_main.cc +++ b/bta/hd/bta_hd_main.cc @@ -176,7 +176,7 @@ static void bta_hd_better_state_machine(uint16_t event, tBTA_HD_DATA* p_data) { * Returns void * ******************************************************************************/ -bool bta_hd_hdl_event(BT_HDR* p_msg) { +bool bta_hd_hdl_event(BT_HDR_RIGID* p_msg) { APPL_TRACE_API("%s: p_msg->event=%d", __func__, p_msg->event); switch (p_msg->event) { diff --git a/bta/hf_client/bta_hf_client_api.cc b/bta/hf_client/bta_hf_client_api.cc index 7981356d7..53083655b 100644 --- a/bta/hf_client/bta_hf_client_api.cc +++ b/bta/hf_client/bta_hf_client_api.cc @@ -111,7 +111,7 @@ void BTA_HfClientOpen(const RawAddress& bd_addr, uint16_t* p_handle) { * ******************************************************************************/ void BTA_HfClientClose(uint16_t handle) { - BT_HDR* p_buf = (BT_HDR*)osi_malloc(sizeof(BT_HDR)); + BT_HDR_RIGID* p_buf = (BT_HDR_RIGID*)osi_malloc(sizeof(BT_HDR_RIGID)); p_buf->event = BTA_HF_CLIENT_API_CLOSE_EVT; p_buf->layer_specific = handle; @@ -131,7 +131,7 @@ void BTA_HfClientClose(uint16_t handle) { * ******************************************************************************/ void BTA_HfClientAudioOpen(uint16_t handle) { - BT_HDR* p_buf = (BT_HDR*)osi_malloc(sizeof(BT_HDR)); + BT_HDR_RIGID* p_buf = (BT_HDR_RIGID*)osi_malloc(sizeof(BT_HDR_RIGID)); p_buf->event = BTA_HF_CLIENT_API_AUDIO_OPEN_EVT; p_buf->layer_specific = handle; @@ -151,7 +151,7 @@ void BTA_HfClientAudioOpen(uint16_t handle) { * ******************************************************************************/ void BTA_HfClientAudioClose(uint16_t handle) { - BT_HDR* p_buf = (BT_HDR*)osi_malloc(sizeof(BT_HDR)); + BT_HDR_RIGID* p_buf = (BT_HDR_RIGID*)osi_malloc(sizeof(BT_HDR_RIGID)); p_buf->event = BTA_HF_CLIENT_API_AUDIO_CLOSE_EVT; p_buf->layer_specific = handle; diff --git a/bta/hf_client/bta_hf_client_int.h b/bta/hf_client/bta_hf_client_int.h index 9727f48e6..8354eadb5 100755 --- a/bta/hf_client/bta_hf_client_int.h +++ b/bta/hf_client/bta_hf_client_int.h @@ -111,26 +111,26 @@ enum { ****************************************************************************/ /* data type for BTA_HF_CLIENT_API_OPEN_EVT */ typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; RawAddress bd_addr; uint16_t* handle; } tBTA_HF_CLIENT_API_OPEN; /* data type for BTA_HF_CLIENT_DISC_RESULT_EVT */ typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; uint16_t status; } tBTA_HF_CLIENT_DISC_RESULT; /* data type for RFCOMM events */ typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; uint16_t port_handle; } tBTA_HF_CLIENT_RFC; /* generic purpose data type for other events */ typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; bool bool_val; uint8_t uint8_val; uint32_t uint32_val1; @@ -140,7 +140,7 @@ typedef struct { /* union of all event datatypes */ typedef union { - BT_HDR hdr; + BT_HDR_RIGID hdr; tBTA_HF_CLIENT_API_OPEN api_open; tBTA_HF_CLIENT_DISC_RESULT disc_result; tBTA_HF_CLIENT_RFC rfc; @@ -217,7 +217,7 @@ extern tBTA_HF_CLIENT_CB* bta_hf_client_find_cb_by_bda( const RawAddress& bd_addr); extern tBTA_HF_CLIENT_CB* bta_hf_client_find_cb_by_rfc_handle(uint16_t handle); extern tBTA_HF_CLIENT_CB* bta_hf_client_find_cb_by_sco_handle(uint16_t handle); -extern bool bta_hf_client_hdl_event(BT_HDR* p_msg); +extern bool bta_hf_client_hdl_event(BT_HDR_RIGID* p_msg); extern void bta_hf_client_sm_execute(uint16_t event, tBTA_HF_CLIENT_DATA* p_data); extern void bta_hf_client_slc_seq(tBTA_HF_CLIENT_CB* client_cb, bool error); diff --git a/bta/hf_client/bta_hf_client_main.cc b/bta/hf_client/bta_hf_client_main.cc index c4b33cf85..902af1323 100644 --- a/bta/hf_client/bta_hf_client_main.cc +++ b/bta/hf_client/bta_hf_client_main.cc @@ -675,7 +675,7 @@ void bta_hf_client_api_disable() { * Returns bool * ******************************************************************************/ -bool bta_hf_client_hdl_event(BT_HDR* p_msg) { +bool bta_hf_client_hdl_event(BT_HDR_RIGID* p_msg) { APPL_TRACE_DEBUG("%s: %s (0x%x)", __func__, bta_hf_client_evt_str(p_msg->event), p_msg->event); bta_hf_client_sm_execute(p_msg->event, (tBTA_HF_CLIENT_DATA*)p_msg); diff --git a/bta/hf_client/bta_hf_client_sco.cc b/bta/hf_client/bta_hf_client_sco.cc index 7e2947cb9..ee906ec1d 100644 --- a/bta/hf_client/bta_hf_client_sco.cc +++ b/bta/hf_client/bta_hf_client_sco.cc @@ -182,7 +182,7 @@ static void bta_hf_client_sco_conn_cback(uint16_t sco_idx) { return; } - BT_HDR* p_buf = (BT_HDR*)osi_malloc(sizeof(BT_HDR)); + BT_HDR_RIGID* p_buf = (BT_HDR_RIGID*)osi_malloc(sizeof(BT_HDR_RIGID)); p_buf->event = BTA_HF_CLIENT_SCO_OPEN_EVT; p_buf->layer_specific = client_cb->handle; bta_sys_sendmsg(p_buf); @@ -207,7 +207,7 @@ static void bta_hf_client_sco_disc_cback(uint16_t sco_idx) { return; } - BT_HDR* p_buf = (BT_HDR*)osi_malloc(sizeof(BT_HDR)); + BT_HDR_RIGID* p_buf = (BT_HDR_RIGID*)osi_malloc(sizeof(BT_HDR_RIGID)); p_buf->event = BTA_HF_CLIENT_SCO_CLOSE_EVT; p_buf->layer_specific = client_cb->handle; bta_sys_sendmsg(p_buf); diff --git a/bta/hh/bta_hh_int.h b/bta/hh/bta_hh_int.h index dc85c4a62..6055e9e2b 100644 --- a/bta/hh/bta_hh_int.h +++ b/bta/hh/bta_hh_int.h @@ -88,7 +88,7 @@ typedef uint8_t tBTA_HH_STATE; /* data structure used to send a command/data to HID device */ typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; uint8_t t_type; uint8_t param; uint8_t rpt_id; @@ -98,27 +98,27 @@ typedef struct { /* data type for BTA_HH_API_ENABLE_EVT */ typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; uint8_t service_name[BTA_SERVICE_NAME_LEN + 1]; tBTA_HH_CBACK* p_cback; } tBTA_HH_API_ENABLE; typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; RawAddress bd_addr; tBTA_HH_PROTO_MODE mode; } tBTA_HH_API_CONN; /* internal event data from BTE HID callback */ typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; RawAddress addr; uint32_t data; BT_HDR* p_data; } tBTA_HH_CBACK_DATA; typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; RawAddress bda; uint16_t attr_mask; uint16_t sub_event; @@ -128,7 +128,7 @@ typedef struct { } tBTA_HH_MAINT_DEV; typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; uint16_t conn_id; tBTA_GATT_REASON reason; /* disconnect reason code, not useful when connect event is reported */ @@ -136,14 +136,14 @@ typedef struct { } tBTA_HH_LE_CLOSE; typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; uint16_t scan_int; uint16_t scan_win; } tBTA_HH_SCPP_UPDATE; /* union of all event data types */ typedef union { - BT_HDR hdr; + BT_HDR_RIGID hdr; tBTA_HH_API_ENABLE api_enable; tBTA_HH_API_CONN api_conn; tBTA_HH_CMD_DATA api_sndcmd; @@ -282,7 +282,7 @@ extern tBTA_HH_CFG* p_bta_hh_cfg; /***************************************************************************** * Function prototypes ****************************************************************************/ -extern bool bta_hh_hdl_event(BT_HDR* p_msg); +extern bool bta_hh_hdl_event(BT_HDR_RIGID* p_msg); extern void bta_hh_sm_execute(tBTA_HH_DEV_CB* p_cb, uint16_t event, tBTA_HH_DATA* p_data); diff --git a/bta/hh/bta_hh_main.cc b/bta/hh/bta_hh_main.cc index be4adb7d6..053589d8c 100644 --- a/bta/hh/bta_hh_main.cc +++ b/bta/hh/bta_hh_main.cc @@ -301,7 +301,7 @@ void bta_hh_sm_execute(tBTA_HH_DEV_CB* p_cb, uint16_t event, * Returns void * ******************************************************************************/ -bool bta_hh_hdl_event(BT_HDR* p_msg) { +bool bta_hh_hdl_event(BT_HDR_RIGID* p_msg) { uint8_t index = BTA_HH_IDX_INVALID; tBTA_HH_DEV_CB* p_cb = NULL; diff --git a/bta/pan/bta_pan_act.cc b/bta/pan/bta_pan_act.cc index 5e644057a..3543ea1e1 100644 --- a/bta/pan/bta_pan_act.cc +++ b/bta/pan/bta_pan_act.cc @@ -145,7 +145,7 @@ static void bta_pan_data_flow_cb(uint16_t handle, tPAN_RESULT result) { if (p_scb == NULL) return; if (result == PAN_TX_FLOW_ON) { - BT_HDR* p_buf = (BT_HDR*)osi_malloc(sizeof(BT_HDR)); + BT_HDR_RIGID* p_buf = (BT_HDR_RIGID*)osi_malloc(sizeof(BT_HDR_RIGID)); p_buf->layer_specific = handle; p_buf->event = BTA_PAN_BNEP_FLOW_ENABLE_EVT; bta_sys_sendmsg(p_buf); @@ -196,7 +196,7 @@ static void bta_pan_data_buf_ind_cback(uint16_t handle, const RawAddress& src, ((tBTA_PAN_DATA_PARAMS*)p_new_buf)->forward = forward; fixed_queue_enqueue(p_scb->data_queue, p_new_buf); - BT_HDR* p_event = (BT_HDR*)osi_malloc(sizeof(BT_HDR)); + BT_HDR_RIGID* p_event = (BT_HDR_RIGID*)osi_malloc(sizeof(BT_HDR_RIGID)); p_event->layer_specific = handle; p_event->event = BTA_PAN_RX_FROM_BNEP_READY_EVT; bta_sys_sendmsg(p_event); diff --git a/bta/pan/bta_pan_api.cc b/bta/pan/bta_pan_api.cc index 0959926d3..a119125e8 100644 --- a/bta/pan/bta_pan_api.cc +++ b/bta/pan/bta_pan_api.cc @@ -77,7 +77,7 @@ void BTA_PanEnable(tBTA_PAN_CBACK p_cback) { * ******************************************************************************/ void BTA_PanDisable(void) { - BT_HDR* p_buf = (BT_HDR*)osi_malloc(sizeof(BT_HDR)); + BT_HDR_RIGID* p_buf = (BT_HDR_RIGID*)osi_malloc(sizeof(BT_HDR_RIGID)); bta_sys_deregister(BTA_ID_PAN); p_buf->event = BTA_PAN_API_DISABLE_EVT; @@ -157,7 +157,7 @@ void BTA_PanOpen(const RawAddress& bd_addr, tBTA_PAN_ROLE local_role, * ******************************************************************************/ void BTA_PanClose(uint16_t handle) { - BT_HDR* p_buf = (BT_HDR*)osi_malloc(sizeof(BT_HDR)); + BT_HDR_RIGID* p_buf = (BT_HDR_RIGID*)osi_malloc(sizeof(BT_HDR_RIGID)); p_buf->event = BTA_PAN_API_CLOSE_EVT; p_buf->layer_specific = handle; diff --git a/bta/pan/bta_pan_ci.cc b/bta/pan/bta_pan_ci.cc index 4a5dfd506..4365fe728 100644 --- a/bta/pan/bta_pan_ci.cc +++ b/bta/pan/bta_pan_ci.cc @@ -67,7 +67,7 @@ void bta_pan_ci_tx_ready(uint16_t handle) { * ******************************************************************************/ void bta_pan_ci_rx_ready(uint16_t handle) { - BT_HDR* p_buf = (BT_HDR*)osi_malloc(sizeof(BT_HDR)); + BT_HDR_RIGID* p_buf = (BT_HDR_RIGID*)osi_malloc(sizeof(BT_HDR_RIGID)); p_buf->layer_specific = handle; p_buf->event = BTA_PAN_CI_RX_READY_EVT; diff --git a/bta/pan/bta_pan_int.h b/bta/pan/bta_pan_int.h index fbc0dc4a5..52270719a 100644 --- a/bta/pan/bta_pan_int.h +++ b/bta/pan/bta_pan_int.h @@ -67,13 +67,13 @@ enum { BTA_PAN_IDLE_ST, BTA_PAN_OPEN_ST, BTA_PAN_CLOSING_ST }; /* data type for BTA_PAN_API_ENABLE_EVT */ typedef struct { - BT_HDR hdr; /* Event header */ + BT_HDR_RIGID hdr; /* Event header */ tBTA_PAN_CBACK* p_cback; /* PAN callback function */ } tBTA_PAN_API_ENABLE; /* data type for BTA_PAN_API_REG_ROLE_EVT */ typedef struct { - BT_HDR hdr; /* Event header */ + BT_HDR_RIGID hdr; /* Event header */ char user_name[BTA_SERVICE_NAME_LEN + 1]; /* Service name */ char nap_name[BTA_SERVICE_NAME_LEN + 1]; /* Service name */ tBTA_PAN_ROLE role; @@ -83,7 +83,7 @@ typedef struct { /* data type for BTA_PAN_API_OPEN_EVT */ typedef struct { - BT_HDR hdr; /* Event header */ + BT_HDR_RIGID hdr; /* Event header */ tBTA_PAN_ROLE local_role; /* local role */ tBTA_PAN_ROLE peer_role; /* peer role */ RawAddress bd_addr; /* peer bdaddr */ @@ -91,20 +91,20 @@ typedef struct { /* data type for BTA_PAN_CI_TX_FLOW_EVT */ typedef struct { - BT_HDR hdr; /* Event header */ + BT_HDR_RIGID hdr; /* Event header */ bool enable; /* Flow control setting */ } tBTA_PAN_CI_TX_FLOW; /* data type for BTA_PAN_CONN_OPEN_EVT */ typedef struct { - BT_HDR hdr; /* Event header */ + BT_HDR_RIGID hdr; /* Event header */ tPAN_RESULT result; } tBTA_PAN_CONN; /* union of all data types */ typedef union { - BT_HDR hdr; + BT_HDR_RIGID hdr; tBTA_PAN_API_ENABLE api_enable; tBTA_PAN_API_SET_ROLE api_set_role; tBTA_PAN_API_OPEN api_open; @@ -141,7 +141,7 @@ typedef struct { /* pan data param */ typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; RawAddress src; RawAddress dst; uint16_t protocol; @@ -164,7 +164,7 @@ extern tBTA_PAN_SCB* bta_pan_scb_alloc(void); extern void bta_pan_scb_dealloc(tBTA_PAN_SCB* p_scb); extern uint8_t bta_pan_scb_to_idx(tBTA_PAN_SCB* p_scb); extern tBTA_PAN_SCB* bta_pan_scb_by_handle(uint16_t handle); -extern bool bta_pan_hdl_event(BT_HDR* p_msg); +extern bool bta_pan_hdl_event(BT_HDR_RIGID* p_msg); /* action functions */ extern void bta_pan_enable(tBTA_PAN_DATA* p_data); diff --git a/bta/pan/bta_pan_main.cc b/bta/pan/bta_pan_main.cc index 76869f81c..779a8a234 100644 --- a/bta/pan/bta_pan_main.cc +++ b/bta/pan/bta_pan_main.cc @@ -307,7 +307,7 @@ tBTA_PAN_SCB* bta_pan_scb_by_handle(uint16_t handle) { * Returns void * ******************************************************************************/ -bool bta_pan_hdl_event(BT_HDR* p_msg) { +bool bta_pan_hdl_event(BT_HDR_RIGID* p_msg) { tBTA_PAN_SCB* p_scb; bool freebuf = true; diff --git a/bta/sys/bta_sys.h b/bta/sys/bta_sys.h index 445e8b27b..c4295d2c7 100644 --- a/bta/sys/bta_sys.h +++ b/bta/sys/bta_sys.h @@ -41,7 +41,10 @@ typedef bool(tBTA_SYS_VS_EVT_HDLR)(uint16_t evt, void* p); /* event handler function type */ -typedef bool(tBTA_SYS_EVT_HDLR)(BT_HDR* p_msg); +typedef bool(tBTA_SYS_EVT_HDLR)(BT_HDR_RIGID* p_msg); +static_assert( + sizeof(BT_HDR) == sizeof(BT_HDR_RIGID), + "Rigid replacement should be same size struct with flexible member"); /* disable function type */ typedef void(tBTA_SYS_DISABLE)(void); diff --git a/bta/sys/bta_sys_main.cc b/bta/sys/bta_sys_main.cc index 178d03aa2..944860661 100644 --- a/bta/sys/bta_sys_main.cc +++ b/bta/sys/bta_sys_main.cc @@ -82,7 +82,7 @@ void BTA_sys_signal_hw_error() { * Returns void * ******************************************************************************/ -static void bta_sys_event(BT_HDR* p_msg) { +static void bta_sys_event(BT_HDR_RIGID* p_msg) { uint8_t id; bool freebuf = true; @@ -163,7 +163,8 @@ bool bta_sys_is_register(uint8_t id) { return bta_sys_cb.is_reg[id]; } ******************************************************************************/ void bta_sys_sendmsg(void* p_msg) { if (do_in_main_thread( - FROM_HERE, base::Bind(&bta_sys_event, static_cast(p_msg))) != + FROM_HERE, + base::Bind(&bta_sys_event, static_cast(p_msg))) != BT_STATUS_SUCCESS) { LOG(ERROR) << __func__ << ": do_in_main_thread failed"; } @@ -171,7 +172,8 @@ void bta_sys_sendmsg(void* p_msg) { void bta_sys_sendmsg_delayed(void* p_msg, const base::TimeDelta& delay) { if (do_in_main_thread_delayed( - FROM_HERE, base::Bind(&bta_sys_event, static_cast(p_msg)), + FROM_HERE, + base::Bind(&bta_sys_event, static_cast(p_msg)), delay) != BT_STATUS_SUCCESS) { LOG(ERROR) << __func__ << ": do_in_main_thread_delayed failed"; } @@ -189,7 +191,7 @@ void bta_sys_sendmsg_delayed(void* p_msg, const base::TimeDelta& delay) { ******************************************************************************/ void bta_sys_start_timer(alarm_t* alarm, uint64_t interval_ms, uint16_t event, uint16_t layer_specific) { - BT_HDR* p_buf = (BT_HDR*)osi_malloc(sizeof(BT_HDR)); + BT_HDR_RIGID* p_buf = (BT_HDR_RIGID*)osi_malloc(sizeof(BT_HDR_RIGID)); p_buf->event = event; p_buf->layer_specific = layer_specific; diff --git a/bta/test/common/mock_stack_acl.cc b/bta/test/common/mock_stack_acl.cc index d1bd4d4e7..c82656f82 100644 --- a/bta/test/common/mock_stack_acl.cc +++ b/bta/test/common/mock_stack_acl.cc @@ -281,7 +281,7 @@ void acl_disconnect_after_role_switch(uint16_t conn_handle, void acl_disconnect_from_handle(uint16_t handle, tHCI_STATUS reason) { mock_function_count_map[__func__]++; } -void acl_link_segments_xmitted(BT_HDR* p_msg) { +void acl_link_segments_xmitted(BT_HDR_RIGID* p_msg) { mock_function_count_map[__func__]++; } void acl_packets_completed(uint16_t handle, uint16_t credits) { @@ -294,7 +294,9 @@ void acl_process_extended_features(uint16_t handle, uint8_t current_page_number, void acl_process_num_completed_pkts(uint8_t* p, uint8_t evt_len) { mock_function_count_map[__func__]++; } -void acl_rcv_acl_data(BT_HDR* p_msg) { mock_function_count_map[__func__]++; } +void acl_rcv_acl_data(BT_HDR_RIGID* p_msg) { + mock_function_count_map[__func__]++; +} void acl_reject_connection_request(const RawAddress& bd_addr, uint8_t reason) { mock_function_count_map[__func__]++; } diff --git a/bta/test/common/mock_stack_btm_sco.cc b/bta/test/common/mock_stack_btm_sco.cc index c09cdee83..ac43989d9 100644 --- a/bta/test/common/mock_stack_btm_sco.cc +++ b/bta/test/common/mock_stack_btm_sco.cc @@ -90,7 +90,9 @@ void btm_esco_proc_conn_chg(uint8_t status, uint16_t handle, uint16_t rx_pkt_len, uint16_t tx_pkt_len) { mock_function_count_map[__func__]++; } -void btm_route_sco_data(BT_HDR* p_msg) { mock_function_count_map[__func__]++; } +void btm_route_sco_data(BT_HDR_RIGID* p_msg) { + mock_function_count_map[__func__]++; +} void btm_sco_acl_removed(const RawAddress* bda) { mock_function_count_map[__func__]++; } diff --git a/btif/include/btif_common.h b/btif/include/btif_common.h index 741263817..e537dc0b1 100644 --- a/btif/include/btif_common.h +++ b/btif/include/btif_common.h @@ -138,7 +138,7 @@ typedef void(tBTIF_COPY_CBACK)(uint16_t event, char* p_dest, char* p_src); /* this type handles all btif context switches between BTU and HAL */ typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; tBTIF_CBACK* p_cb; /* context switch callback */ /* parameters passed to callback */ diff --git a/btif/src/btif_a2dp_sink.cc b/btif/src/btif_a2dp_sink.cc index 32fe82b64..fa02a8682 100644 --- a/btif/src/btif_a2dp_sink.cc +++ b/btif/src/btif_a2dp_sink.cc @@ -70,12 +70,12 @@ enum { }; typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; uint8_t codec_info[AVDT_CODEC_SIZE]; } tBTIF_MEDIA_SINK_DECODER_UPDATE; typedef struct { - BT_HDR hdr; + BT_HDR_RIGID hdr; btif_a2dp_sink_focus_state_t focus_state; } tBTIF_MEDIA_SINK_FOCUS_UPDATE; @@ -136,7 +136,7 @@ static void btif_a2dp_sink_start_session_delayed( static void btif_a2dp_sink_end_session_delayed(); static void btif_a2dp_sink_shutdown_delayed(); static void btif_a2dp_sink_cleanup_delayed(); -static void btif_a2dp_sink_command_ready(BT_HDR* p_msg); +static void btif_a2dp_sink_command_ready(BT_HDR_RIGID* p_msg); static void btif_a2dp_sink_audio_handle_stop_decoding(); static void btif_decode_alarm_cb(void* context); static void btif_a2dp_sink_audio_handle_start_decoding(); @@ -348,7 +348,7 @@ tA2DP_CHANNEL_COUNT btif_a2dp_sink_get_channel_count() { return btif_a2dp_sink_cb.channel_count; } -static void btif_a2dp_sink_command_ready(BT_HDR* p_msg) { +static void btif_a2dp_sink_command_ready(BT_HDR_RIGID* p_msg) { LOG_VERBOSE("%s: event %d %s", __func__, p_msg->event, dump_media_event(p_msg->event)); @@ -398,12 +398,14 @@ void btif_a2dp_sink_update_decoder(const uint8_t* p_codec_info) { p_buf->hdr.event = BTIF_MEDIA_SINK_DECODER_UPDATE; btif_a2dp_sink_cb.worker_thread.DoInThread( - FROM_HERE, base::BindOnce(btif_a2dp_sink_command_ready, (BT_HDR*)p_buf)); + FROM_HERE, + base::BindOnce(btif_a2dp_sink_command_ready, (BT_HDR_RIGID*)p_buf)); } void btif_a2dp_sink_on_idle() { LOG_INFO("%s", __func__); - BT_HDR* p_buf = reinterpret_cast(osi_malloc(sizeof(BT_HDR))); + BT_HDR_RIGID* p_buf = + reinterpret_cast(osi_malloc(sizeof(BT_HDR_RIGID))); p_buf->event = BTIF_MEDIA_SINK_SUSPEND; btif_a2dp_sink_cb.worker_thread.DoInThread( FROM_HERE, base::BindOnce(btif_a2dp_sink_command_ready, p_buf)); @@ -415,7 +417,8 @@ void btif_a2dp_sink_on_idle() { void btif_a2dp_sink_on_stopped(UNUSED_ATTR tBTA_AV_SUSPEND* p_av_suspend) { LOG_INFO("%s", __func__); - BT_HDR* p_buf = reinterpret_cast(osi_malloc(sizeof(BT_HDR))); + BT_HDR_RIGID* p_buf = + reinterpret_cast(osi_malloc(sizeof(BT_HDR_RIGID))); p_buf->event = BTIF_MEDIA_SINK_SUSPEND; btif_a2dp_sink_cb.worker_thread.DoInThread( FROM_HERE, base::BindOnce(btif_a2dp_sink_command_ready, p_buf)); @@ -426,7 +429,8 @@ void btif_a2dp_sink_on_stopped(UNUSED_ATTR tBTA_AV_SUSPEND* p_av_suspend) { void btif_a2dp_sink_on_suspended(UNUSED_ATTR tBTA_AV_SUSPEND* p_av_suspend) { LOG_INFO("%s", __func__); - BT_HDR* p_buf = reinterpret_cast(osi_malloc(sizeof(BT_HDR))); + BT_HDR_RIGID* p_buf = + reinterpret_cast(osi_malloc(sizeof(BT_HDR_RIGID))); p_buf->event = BTIF_MEDIA_SINK_SUSPEND; btif_a2dp_sink_cb.worker_thread.DoInThread( FROM_HERE, base::BindOnce(btif_a2dp_sink_command_ready, p_buf)); @@ -438,7 +442,8 @@ void btif_a2dp_sink_on_suspended(UNUSED_ATTR tBTA_AV_SUSPEND* p_av_suspend) { bool btif_a2dp_sink_on_start() { LOG_INFO("%s", __func__); - BT_HDR* p_buf = reinterpret_cast(osi_malloc(sizeof(BT_HDR))); + BT_HDR_RIGID* p_buf = + reinterpret_cast(osi_malloc(sizeof(BT_HDR_RIGID))); p_buf->event = BTIF_MEDIA_SINK_START; btif_a2dp_sink_cb.worker_thread.DoInThread( FROM_HERE, base::BindOnce(btif_a2dp_sink_command_ready, p_buf)); @@ -681,7 +686,8 @@ void btif_a2dp_sink_audio_rx_flush_req() { return; } - BT_HDR* p_buf = reinterpret_cast(osi_malloc(sizeof(BT_HDR))); + BT_HDR_RIGID* p_buf = + reinterpret_cast(osi_malloc(sizeof(BT_HDR_RIGID))); p_buf->event = BTIF_MEDIA_SINK_AUDIO_RX_FLUSH; btif_a2dp_sink_cb.worker_thread.DoInThread( FROM_HERE, base::BindOnce(btif_a2dp_sink_command_ready, p_buf)); @@ -699,7 +705,8 @@ void btif_a2dp_sink_set_focus_state_req(btif_a2dp_sink_focus_state_t state) { p_buf->focus_state = state; p_buf->hdr.event = BTIF_MEDIA_SINK_SET_FOCUS_STATE; btif_a2dp_sink_cb.worker_thread.DoInThread( - FROM_HERE, base::BindOnce(btif_a2dp_sink_command_ready, (BT_HDR*)p_buf)); + FROM_HERE, + base::BindOnce(btif_a2dp_sink_command_ready, (BT_HDR_RIGID*)p_buf)); } static void btif_a2dp_sink_set_focus_state_event( @@ -728,7 +735,8 @@ void btif_a2dp_sink_set_audio_track_gain(float gain) { static void btif_a2dp_sink_clear_track_event_req() { LOG_INFO("%s", __func__); - BT_HDR* p_buf = reinterpret_cast(osi_malloc(sizeof(BT_HDR))); + BT_HDR_RIGID* p_buf = + reinterpret_cast(osi_malloc(sizeof(BT_HDR_RIGID))); p_buf->event = BTIF_MEDIA_SINK_CLEAR_TRACK; btif_a2dp_sink_cb.worker_thread.DoInThread( diff --git a/internal_include/bte.h b/internal_include/bte.h index 754cf53b5..7839babb0 100644 --- a/internal_include/bte.h +++ b/internal_include/bte.h @@ -98,7 +98,7 @@ void bte_get_startup_options( #define BTE_HCISU_USERIAL_OK 1 typedef void(tUSERIAL_MSG_CBACK)(int status); typedef struct tHCISU_USERIAL_MSG_tag { - BT_HDR hdr; + BT_HDR_RIGID hdr; tUSERIAL_MSG_CBACK* p_cback; uint8_t port; /* port number */ uint8_t op; -- 2.11.0