OSDN Git Service

Replace BT_HDR => BT_HDR_RIGID
authorChris Manton <cmanton@google.com>
Sat, 6 Mar 2021 23:35:36 +0000 (15:35 -0800)
committerChris Manton <cmanton@google.com>
Wed, 21 Apr 2021 00:30:14 +0000 (00:30 +0000)
Toward structurally sound code

Bug: 163134718
Test: gd/cert/run
Tag: #refactor

Change-Id: Ib6569c0c19c7f1e6f4b9e9c1abc27e30d1e33fbf

38 files changed:
bta/ag/bta_ag_int.h
bta/ag/bta_ag_main.cc
bta/av/bta_av_aact.cc
bta/av/bta_av_act.cc
bta/av/bta_av_api.cc
bta/av/bta_av_ci.cc
bta/av/bta_av_int.h
bta/av/bta_av_main.cc
bta/dm/bta_dm_int.h
bta/dm/bta_dm_main.cc
bta/gatt/bta_gattc_act.cc
bta/gatt/bta_gattc_api.cc
bta/gatt/bta_gattc_int.h
bta/gatt/bta_gattc_main.cc
bta/gatt/bta_gatts_api.cc
bta/gatt/bta_gatts_int.h
bta/gatt/bta_gatts_main.cc
bta/hd/bta_hd_api.cc
bta/hd/bta_hd_int.h
bta/hd/bta_hd_main.cc
bta/hf_client/bta_hf_client_api.cc
bta/hf_client/bta_hf_client_int.h
bta/hf_client/bta_hf_client_main.cc
bta/hf_client/bta_hf_client_sco.cc
bta/hh/bta_hh_int.h
bta/hh/bta_hh_main.cc
bta/pan/bta_pan_act.cc
bta/pan/bta_pan_api.cc
bta/pan/bta_pan_ci.cc
bta/pan/bta_pan_int.h
bta/pan/bta_pan_main.cc
bta/sys/bta_sys.h
bta/sys/bta_sys_main.cc
bta/test/common/mock_stack_acl.cc
bta/test/common/mock_stack_btm_sco.cc
btif/include/btif_common.h
btif/src/btif_a2dp_sink.cc
internal_include/bte.h

index ef20008..6640808 100644 (file)
@@ -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);
index b87cbfd..583102f 100644 (file)
@@ -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:
index c6ce6a8..6e36602 100644 (file)
@@ -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;
 
index bcd1aa3..f6c7e2c 100644 (file)
@@ -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;
 
index cf3bb50..58d3cba 100644 (file)
@@ -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;
index 8a19924..b191e82 100644 (file)
@@ -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;
index a450b97..3be4458 100644 (file)
@@ -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);
index 0ef5a76..9123d03 100644 (file)
@@ -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 */
   }
index cd19afc..6e433d2 100644 (file)
@@ -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*);
index 02f04ce..4708500 100644 (file)
@@ -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);
 
index ee9f460..7a21349 100644 (file)
@@ -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");
index 185261f..93af8c1 100644 (file)
@@ -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;
index 6b2b8d8..161a413 100644 (file)
@@ -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);
 
index afcf271..0227ce3 100644 (file)
@@ -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)
index 6403034..5e49a7c 100644 (file)
@@ -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;
index 42a3a66..25cdf49 100644 (file)
@@ -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);
index 555582a..497f315 100644 (file)
@@ -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) {
index d012770..4b33cd3 100644 (file)
@@ -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);
index a433ebd..67f282b 100644 (file)
@@ -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);
index 0f90db8..022f8fe 100644 (file)
@@ -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) {
index 7981356..5308365 100644 (file)
@@ -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;
index 9727f48..8354ead 100755 (executable)
@@ -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);
index c4b33cf..902af13 100644 (file)
@@ -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);
index 7e2947c..ee906ec 100644 (file)
@@ -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);
index dc85c4a..6055e9e 100644 (file)
@@ -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);
 
index be4adb7..053589d 100644 (file)
@@ -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;
 
index 5e64405..3543ea1 100644 (file)
@@ -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);
index 0959926..a119125 100644 (file)
@@ -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;
index 4a5dfd5..4365fe7 100644 (file)
@@ -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;
index fbc0dc4..5227071 100644 (file)
@@ -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);
index 76869f8..779a8a2 100644 (file)
@@ -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;
 
index 445e8b2..c4295d2 100644 (file)
 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);
index 178d03a..9448606 100644 (file)
@@ -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<BT_HDR*>(p_msg))) !=
+          FROM_HERE,
+          base::Bind(&bta_sys_event, static_cast<BT_HDR_RIGID*>(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<BT_HDR*>(p_msg)),
+          FROM_HERE,
+          base::Bind(&bta_sys_event, static_cast<BT_HDR_RIGID*>(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;
index d1bd4d4..c82656f 100644 (file)
@@ -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__]++;
 }
index c09cdee..ac43989 100644 (file)
@@ -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__]++;
 }
index 7412638..e537dc0 100644 (file)
@@ -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 */
index 32fe82b..fa02a86 100644 (file)
@@ -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<BT_HDR*>(osi_malloc(sizeof(BT_HDR)));
+  BT_HDR_RIGID* p_buf =
+      reinterpret_cast<BT_HDR_RIGID*>(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<BT_HDR*>(osi_malloc(sizeof(BT_HDR)));
+  BT_HDR_RIGID* p_buf =
+      reinterpret_cast<BT_HDR_RIGID*>(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<BT_HDR*>(osi_malloc(sizeof(BT_HDR)));
+  BT_HDR_RIGID* p_buf =
+      reinterpret_cast<BT_HDR_RIGID*>(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<BT_HDR*>(osi_malloc(sizeof(BT_HDR)));
+  BT_HDR_RIGID* p_buf =
+      reinterpret_cast<BT_HDR_RIGID*>(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<BT_HDR*>(osi_malloc(sizeof(BT_HDR)));
+  BT_HDR_RIGID* p_buf =
+      reinterpret_cast<BT_HDR_RIGID*>(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<BT_HDR*>(osi_malloc(sizeof(BT_HDR)));
+  BT_HDR_RIGID* p_buf =
+      reinterpret_cast<BT_HDR_RIGID*>(osi_malloc(sizeof(BT_HDR_RIGID)));
 
   p_buf->event = BTIF_MEDIA_SINK_CLEAR_TRACK;
   btif_a2dp_sink_cb.worker_thread.DoInThread(
index 754cf53..7839bab 100644 (file)
@@ -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;