cleanup: Bluetooth stack (BTE names, comma conditions) #1356

Merged
coah80 merged 1 commits from agent/w0929/cleanup2-x1-land into main 2026-10-09 18:00:42 +00:00
13 changed files with 223 additions and 236 deletions

View File

@@ -71,19 +71,11 @@ enum
typedef void tBTA_DM_ACTION(tBTA_DM_MSG *p_data);
typedef UINT8 tBTA_DM_STATE_TABLE_ENTRY[BTA_DM_NUM_COLS];
#if 0
typedef tBTA_DM_STATE_TABLE_ENTRY tBTA_DM_STATE_TABLE[];
#else
typedef tBTA_DM_STATE_TABLE_ENTRY tBTA_DM_STATE_TABLE;
#endif
typedef void tBTA_DM_SEARCH_ACTION(tBTA_DM_MSG *p_data);
typedef UINT8 tBTA_DM_SEARCH_STATE_TABLE_ENTRY[BTA_DM_SEARCH_NUM_COLS];
#if 0
typedef tBTA_DM_SEARCH_STATE_TABLE_ENTRY tBTA_DM_SEARCH_STATE_TABLE[];
#else
typedef tBTA_DM_SEARCH_STATE_TABLE_ENTRY tBTA_DM_SEARCH_STATE_TABLE;
#endif
tBTA_DM_ACTION * const bta_dm_action[] =
{
@@ -108,18 +100,11 @@ tBTA_DM_STATE_TABLE_ENTRY const bta_dm_st_table[] =
{BTA_DM_API_DISABLE_EVT - BTA_SYS_EVT_START(BTA_ID_DM), BTA_DM_IGNORE},
{BTA_DM_API_SET_NAME_EVT - BTA_SYS_EVT_START(BTA_ID_DM), BTA_DM_IGNORE},
{BTA_DM_API_SET_VISIBILITY_EVT - BTA_SYS_EVT_START(BTA_ID_DM), BTA_DM_IGNORE},
#if 0
// not over here?
{BTA_DM_API_BOND_EVT - BTA_SYS_EVT_START(BTA_ID_DM), BTA_DM_IGNORE},
#endif
{BTA_DM_API_PIN_REPLY_EVT - BTA_SYS_EVT_START(BTA_ID_DM), BTA_DM_IGNORE},
{BTA_DM_API_AUTH_REPLY_EVT - BTA_SYS_EVT_START(BTA_ID_DM), BTA_DM_IGNORE},
{BTA_DM_API_SIG_STRENGTH_EVT - BTA_SYS_EVT_START(BTA_ID_DM), BTA_DM_IGNORE},
{BTA_DM_ACL_CHANGE_EVT - BTA_SYS_EVT_START(BTA_ID_DM), BTA_DM_IGNORE},
#if 1
// over here?
{BTA_DM_API_BOND_EVT - BTA_SYS_EVT_START(BTA_ID_DM), BTA_DM_IGNORE},
#endif
{BTA_DM_PM_BTM_STATUS_EVT - BTA_SYS_EVT_START(BTA_ID_DM), BTA_DM_IGNORE},
{BTA_DM_PM_TIMER_EVT - BTA_SYS_EVT_START(BTA_ID_DM), BTA_DM_IGNORE},
{BTA_DM_API_KEEP_ACL_LINKS - BTA_SYS_EVT_START(BTA_ID_DM), BTA_DM_IGNORE},

View File

@@ -66,11 +66,7 @@ enum
typedef void tBTA_HH_ACTION(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data);
typedef UINT8 tBTA_HH_STATE_TABLE_ENTRY[BTA_HH_NUM_COLS];
#if 0
typedef tBTA_HH_STATE_TABLE_ENTRY tBTA_HH_STATE_TABLE[];
#else
typedef tBTA_HH_STATE_TABLE_ENTRY tBTA_HH_STATE_TABLE;
#endif
static char const *bta_hh_evt_code(tBTA_HH_INT_EVT evt_code);
static char const *bta_hh_state_code(tBTA_HH_STATE state_code);

View File

@@ -80,7 +80,8 @@ static void btm_esco_conn_rsp(UINT16 sco_inx, UINT8 hci_status, BD_ADDR bda,
BT_HDR *p_buf;
UINT16 temp_pkt_types;
if ((p_buf = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_REJECT_ESCO)) == NULL)
p_buf = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_REJECT_ESCO);
if (p_buf == NULL)
{
BTM_TRACE(ERROR, "btm_esco_conn_rsp -> No Resources");
return;
@@ -246,8 +247,10 @@ tBTM_STATUS BTM_CreateSco(BD_ADDR remote_bda, BOOLEAN is_orig, UINT16 pkt_types,
if (is_orig)
{
// MWCC requires this combined check for the original instructions.
if (!remote_bda
|| ((acl_handle = BTM_GetHCIConnHandle(remote_bda)) == 0xffff))
|| ((acl_handle = BTM_GetHCIConnHandle(remote_bda))
== BTM_INVALID_HCI_HANDLE))
{
return BTM_UNKNOWN_ADDR;
}
@@ -382,7 +385,8 @@ void btm_sco_chk_pend_unpark(tHCI_STATUS hci_status, tHCI_HANDLE hci_handle,
/* explicitly post-increment */
for (xx = 0; xx < BTM_MAX_SCO_LINKS; xx++, p++)
{
if (p->state == SCO_ST_PEND_UNPARK && mode == 0
// MWCC requires the handle lookup inside this short-circuit condition.
if (p->state == SCO_ST_PEND_UNPARK && mode == HCI_MODE_ACTIVE
&& hci_status == HCI_SUCCESS
&& ((acl_handle = BTM_GetHCIConnHandle(p->esco.data.bd_addr))
== hci_handle))
@@ -494,7 +498,7 @@ void btm_sco_connected(tHCI_STATUS hci_status, BD_ADDR bda,
{
if (p->state == SCO_ST_CONNECTING)
{
if (hci_status != 35)
if (hci_status != HCI_ERR_LMP_ERR_TRANS_COLLISION)
{
p->state = SCO_ST_UNUSED;
@@ -598,6 +602,7 @@ void btm_sco_removed(UINT16 hci_handle, UINT8 reason)
if (btm_num_sco_links_active() <= 1)
btm_chg_all_acl_pkt_types(FALSE);
// MWCC requires the second database address computation after the calls.
p = btm_cb.sco_cb.sco_db;
/* explicitly post-increment */

View File

@@ -89,21 +89,18 @@ void btu_task_init(void)
void btu_task_msg_handler(void)
{
TIMER_LIST_ENT *r30;
BT_HDR *r29;
unsigned char r28;
unsigned short r27;
unsigned char r26;
TIMER_LIST_ENT *p_tle;
BT_HDR *p_msg;
UINT8 i;
UINT16 event;
BOOLEAN handled;
OSTime sp10;
signed (*sp0c)(TIMER_LIST_ENT *);
unsigned short sp0a;
unsigned char sp09;
char sp08;
tBTU_TIMER_CALLBACK *p_timeout_cback;
UINT16 mask;
BOOLEAN messages_done;
sp09 = 0;
sp08 = 1;
sp10 = OSGetTime();
messages_done = FALSE;
OSGetTime();
++_btu_g_count;
@@ -112,7 +109,6 @@ void btu_task_msg_handler(void)
if (execute_btu)
{
execute_btu = 0;
sp08 = btu_count;
btu_count = 1;
}
else
@@ -125,109 +121,110 @@ void btu_task_msg_handler(void)
GKI_enable();
r27 = 0x05;
event = TASK_MBOX_0_EVT_MASK | TASK_MBOX_2_EVT_MASK;
if ((unsigned)_btu_g_count > (unsigned)_btu_last_timer_tick + 500)
{
r27 |= 0x30;
event |= TIMER_0_EVT_MASK | TIMER_1_EVT_MASK;
_btu_last_timer_tick = _btu_g_count;
}
while (sp09 == 0)
while (!messages_done)
{
sp09 = 1;
messages_done = TRUE;
if (r27 & (1 << 0))
if (event & TASK_MBOX_0_EVT_MASK)
{
while ((r29 = GKI_read_mbox(0)))
while ((p_msg = GKI_read_mbox(BTU_HCI_RCV_MBOX)))
{
sp09 = 0;
messages_done = FALSE;
BTU_TASK_TRACE("BTU Task got msg in MBOX0\n");
switch (r29->event & 0xff00)
switch (p_msg->event & 0xff00)
{
case 0x1100:
l2c_rcv_acl_data(r29);
l2c_rcv_acl_data(p_msg);
break;
case 0x1900:
l2c_link_segments_xmitted(r29);
l2c_link_segments_xmitted(p_msg);
break;
case 0x1200:
btm_route_sco_data(r29);
btm_route_sco_data(p_msg);
break;
case 0x1000:
btu_hcif_process_event(r29);
GKI_freebuf(r29);
btu_hcif_process_event(p_msg);
GKI_freebuf(p_msg);
break;
case 0x1600:
btu_hcif_send_cmd(r29);
btu_hcif_send_cmd(p_msg);
break;
default:
r28 = 0;
sp0a = r29->event & 0xff00;
r26 = 0;
i = 0;
mask = p_msg->event & 0xff00;
handled = FALSE;
for (; r26 == 0 && r28 < BTU_MAX_REG_EVENT; ++r28)
for (; !handled && i < BTU_MAX_REG_EVENT; ++i)
{
if (!btu_cb.event_reg[r28].event_cb)
if (!btu_cb.event_reg[i].event_cb)
continue;
if (sp0a != btu_cb.event_reg[r28].event_range)
if (mask != btu_cb.event_reg[i].event_range)
continue;
if (btu_cb.event_reg[r28].event_cb)
// MWCC requires this repeated callback check.
if (btu_cb.event_reg[i].event_cb)
{
(*btu_cb.event_reg[r28].event_cb)(r29);
r26 = 1;
(*btu_cb.event_reg[i].event_cb)(p_msg);
handled = TRUE;
}
}
if (r26 == 0)
GKI_freebuf(r29);
if (!handled)
GKI_freebuf(p_msg);
}
}
}
if (r27 & (1 << 4))
if (event & TIMER_0_EVT_MASK)
{
GKI_update_timer_list(&btu_cb.timer_queue, 1);
r27 &= ~(1 << 4);
event &= ~TIMER_0_EVT_MASK;
while (btu_cb.timer_queue.p_first
&& btu_cb.timer_queue.p_first->ticks == 0)
{
sp09 = 0;
messages_done = FALSE;
r30 = btu_cb.timer_queue.p_first;
GKI_remove_from_timer_list(&btu_cb.timer_queue, r30);
p_tle = btu_cb.timer_queue.p_first;
GKI_remove_from_timer_list(&btu_cb.timer_queue, p_tle);
switch (r30->event)
switch (p_tle->event)
{
case 1:
btm_dev_timeout(r30);
case BTU_TTYPE_BTM_DEV_CTL:
btm_dev_timeout(p_tle);
break;
case 9:
btm_acl_timeout(r30);
case BTU_TTYPE_BTM_ACL:
btm_acl_timeout(p_tle);
break;
case 2:
case 3:
case 4:
l2c_process_timeout(r30);
case BTU_TTYPE_L2CAP_LINK:
case BTU_TTYPE_L2CAP_CHNL:
case BTU_TTYPE_L2CAP_HOLD:
l2c_process_timeout(p_tle);
break;
case 5:
sdp_conn_timeout((tCONN_CB *)r30->param);
case BTU_TTYPE_SDP:
sdp_conn_timeout((tCONN_CB *)p_tle->param);
break;
case 10:
case BTU_TTYPE_BTM_RMT_NAME:
btm_inq_rmt_name_failed();
break;
@@ -235,63 +232,63 @@ void btu_task_msg_handler(void)
btm_discovery_timeout();
break;
case 11:
case 12:
rfcomm_process_timeout(r30);
case BTU_TTYPE_RFCOMM_MFC:
case BTU_TTYPE_RFCOMM_PORT:
rfcomm_process_timeout(p_tle);
break;
case 60:
case BTU_TTYPE_BTU_CMD_CMPL:
btu_hcif_cmd_timeout();
break;
case 66:
hidh_proc_repage_timeout(r30);
case BTU_TTYPE_HID_HOST_REPAGE_TO:
hidh_proc_repage_timeout(p_tle);
break;
case 22:
sp0c = (signed (*)(TIMER_LIST_ENT *p_tle))r30->param;
p_timeout_cback = (tBTU_TIMER_CALLBACK *)p_tle->param;
(*sp0c)(r30);
(*p_timeout_cback)(p_tle);
break;
default:
r28 = 0;
r26 = 0;
i = 0;
handled = FALSE;
for (; r26 == 0 && r28 < BTU_MAX_REG_TIMER; ++r28)
for (; !handled && i < BTU_MAX_REG_TIMER; ++i)
{
if (!btu_cb.timer_reg[r28].timer_cb)
if (!btu_cb.timer_reg[i].timer_cb)
continue;
if (btu_cb.timer_reg[r28].p_tle != r30)
if (btu_cb.timer_reg[i].p_tle != p_tle)
continue;
(*btu_cb.timer_reg[r28].timer_cb)(r30);
r26 = 1;
(*btu_cb.timer_reg[i].timer_cb)(p_tle);
handled = TRUE;
}
}
}
}
if (r27 & (1 << 2))
if (event & TASK_MBOX_2_EVT_MASK)
{
while ((r29 = GKI_read_mbox(2)))
while ((p_msg = GKI_read_mbox(TASK_MBOX_2)))
{
BTU_TASK_TRACE("BTU Task got msg in MBOX2\n");
sp09 = 0;
messages_done = FALSE;
bta_sys_event(r29);
bta_sys_event(p_msg);
}
}
if (r27 & (1 << 5))
if (event & TIMER_1_EVT_MASK)
{
r27 &= ~(1 << 5);
event &= ~TIMER_1_EVT_MASK;
bta_sys_timer_update();
}
if (r27 & (1 << 15))
if (event & (1 << 15))
break;
}

View File

@@ -306,11 +306,6 @@ BOOLEAN gap_is_service_busy(UINT16 request)
return FALSE;
}
# if 0
// Range: 0x730 -> 0x794
unsigned short gap_convert_btm_status(unsigned char btm_status /* r3 */) {}
#endif
UINT16 gap_convert_btm_status(tBTM_STATUS btm_status)
{
switch (btm_status)

View File

@@ -133,16 +133,16 @@ UINT16 hcisu_h2_receive_msg(UINT16 pipe, tHCISU_H2_CB *p_cb)
UINT16 msg_len;
UINT16 len;
UINT8 msg_received;
UINT16 r27;
UINT16 usb_pipe;
if (p_cb->open_state != 2)
return 0;
r27 = pipe + 1;
usb_pipe = pipe + 1;
while (TRUE)
{
if (UUSB_Read(r27, &byte, 1) == 0)
if (UUSB_Read(usb_pipe, &byte, 1) == 0)
break;
++bytes_read;
@@ -151,17 +151,17 @@ UINT16 hcisu_h2_receive_msg(UINT16 pipe, tHCISU_H2_CB *p_cb)
switch (p_cb->rx_state[pipe])
{
case 0:
if (r27 == 1)
if (usb_pipe == 1)
{
p_cb->p_rx_msg[pipe] = GKI_getpoolbuf(GKI_POOL_ID_2);
p_cb->pkt_type[pipe] = 4;
}
else if (r27 == 2)
else if (usb_pipe == 2)
{
p_cb->p_rx_msg[pipe] = GKI_getpoolbuf(GKI_POOL_ID_3);
p_cb->pkt_type[pipe] = 2;
}
else if (r27 == 3)
else if (usb_pipe == 3)
{
p_cb->p_rx_msg[pipe] = GKI_getpoolbuf(GKI_POOL_ID_1);
p_cb->pkt_type[pipe] = 3;
@@ -207,10 +207,10 @@ UINT16 hcisu_h2_receive_msg(UINT16 pipe, tHCISU_H2_CB *p_cb)
{
msg_len = (msg_len << 8) + p_cb->len_hi[pipe];
if ((p_cb->p_rx_msg[pipe] =
(HC_BT_HDR *)l2cap_link_chk_pkt_start(
(BT_HDR *)p_cb->p_rx_msg[pipe]))
== 0)
p_cb->p_rx_msg[pipe] =
(HC_BT_HDR *)l2cap_link_chk_pkt_start(
(BT_HDR *)p_cb->p_rx_msg[pipe]);
if (p_cb->p_rx_msg[pipe] == 0)
{
p_cb->bytes_left[pipe] = msg_len;

View File

@@ -623,28 +623,6 @@ static void hidh_l2cif_data_ind(UINT16 l2cap_cid, BT_HDR *p_msg)
}
}
# if 0
UINT8 hidh_conn_snd_data(UINT8 dhandle /* r1+0x8 */, UINT8 trans_type /* r25 */,
UINT8 param /* r22 */, UINT16 data /* r24 */,
UINT8 report_id /* r23 */, BT_HDR *buf /* r31 */)
{
struct hid_conn *p_hcon; // r30
BT_HDR *p_buf; // r29
UINT8 *p_out; // r27
UINT16 bytes_copied; // r28
UINT8 seg_req; // r1+0xC
UINT16 data_size; // r26
UINT16 cid; // r1+0xE
UINT8 pool_id; // r1+0xB
UINT8 use_data; // r1+0xA
UINT8 blank_datc; // r1+0x9
// References
// -> struct host_ctb hh_cb;
}
#endif
tHID_STATUS hidh_conn_snd_data(UINT8 dhandle, UINT8 trans_type, UINT8 param,
UINT16 data, UINT8 report_id, BT_HDR *buf)
{

View File

@@ -494,23 +494,13 @@ void L2CA_SetCompression(UINT16 local_cid, UINT8 pe_type, UINT8 mem_level,
p_lcb = p_ccb->p_lcb;
if (p_lcb && p_lcb->in_use && p_lcb->link_state == LST_CONNECTED)
{
#if 0
/* ... */
#endif
}
else
{
// MWCC requires these link checks while compression is disabled.
if (!p_lcb || !p_lcb->in_use || p_lcb->link_state != LST_CONNECTED)
return;
}
}
void L2CA_RegisterCompression(tL2CA_COMPRESS_CB *p_callback, int unused)
{
#if 0
/* ... */
#endif
}
UINT8 L2CA_Flush(UINT16 cid)

View File

@@ -561,9 +561,6 @@ static void process_l2cap_cmd(tL2C_LCB *p_lcb, UINT8 *p, UINT16 pkt_len)
void l2c_process_compress_setup_timeout(TIMER_LIST_ENT *p_tle)
{
#if 0
/* ... */
#endif
}
void l2c_process_timeout(TIMER_LIST_ENT *p_tle)

View File

@@ -1201,7 +1201,6 @@ BOOLEAN l2cu_check_feature_req(tL2C_LCB *p_lcb, UINT8 id, UINT8 *p_data,
UINT8 buff[100];
UINT8 *p_out = buff;
UINT8 *p_end = p_data + data_len - 2;
UINT8 pe_type;
UINT8 pe_len;
if (data_len < 4 || p_data[0] != 'R' || p_data[1] != 'Q'
@@ -1218,15 +1217,10 @@ BOOLEAN l2cu_check_feature_req(tL2C_LCB *p_lcb, UINT8 id, UINT8 *p_data,
while (p_data < p_end)
{
pe_type = *p_data++;
p_data++;
pe_len = *p_data++;
switch (pe_type)
{
default:
p_data += pe_len;
break;
}
p_data += pe_len;
}
if (p_data != p_end)
@@ -1259,16 +1253,12 @@ void l2cu_check_feature_rsp(tL2C_LCB *p_lcb, UINT8 id, UINT8 *p_data,
while (p_data < p_end)
{
UINT8 pe_id = *p_data++;
UINT8 pe_len = *p_data++;
UINT8 pe_len;
// This is kind of crazy LOL
switch (pe_id)
{
default:
p_data += pe_len;
break;
}
p_data++;
pe_len = *p_data++;
p_data += pe_len;
}
if (p_data != p_end)
@@ -1277,9 +1267,6 @@ void l2cu_check_feature_rsp(tL2C_LCB *p_lcb, UINT8 id, UINT8 *p_data,
void l2cu_stop_compression(/* void? */)
{
#if 0
/* ... */
#endif
}
BOOLEAN l2cu_lcb_has_feature_enable(/* tL2C_LCB *p_lcb? */)

View File

@@ -336,8 +336,8 @@ BOOLEAN SDP_FindAddProtoListsElemInRec(tSDP_DISC_REC *p_rec, UINT16 layer_uuid,
if (SDP_DISC_ATTR_TYPE(p_sattr->attr_len_type)
== DATA_ELE_SEQ_DESC_TYPE)
{
if ((ret = sdp_fill_proto_elem(p_sattr, layer_uuid, p_elem))
== TRUE)
ret = sdp_fill_proto_elem(p_sattr, layer_uuid, p_elem);
if (ret == TRUE)
{
break;
}
@@ -577,9 +577,11 @@ UINT16 SDP_SetLocalDiRecord(tSDP_DI_RECORD *p_device_info, UINT32 *p_handle)
{
handle = sdp_cb.server_db.di_primary_handle;
}
else if ((handle = SDP_CreateRecord()) == 0)
else
{
return SDP_NO_RESOURCES;
handle = SDP_CreateRecord();
if (handle == 0)
return SDP_NO_RESOURCES;
}
*p_handle = handle;
@@ -724,63 +726,64 @@ UINT16 SDP_GetLocalDiRecord(tSDP_DI_GET_RECORD *p_device_info, UINT32 *p_handle)
if (*p_handle == 0)
*p_handle = sdp_cb.server_db.di_primary_handle;
if ((p_rec = sdp_db_find_record(*p_handle)) != NULL)
p_rec = sdp_db_find_record(*p_handle);
if (p_rec != NULL)
{
// ERRATUM: uses sizeof(tSDP_DI_RECORD), not sizeof(tSDP_DI_GET_RECORD)
memset(p_device_info, 0, sizeof(tSDP_DI_RECORD));
result = SDP_SUCCESS;
if ((p_attr = sdp_db_find_attr_in_rec(p_rec, ATTR_ID_SPECIFICATION_ID,
ATTR_ID_SPECIFICATION_ID))
!= NULL)
p_attr = sdp_db_find_attr_in_rec(
p_rec, ATTR_ID_SPECIFICATION_ID, ATTR_ID_SPECIFICATION_ID);
if (p_attr != NULL)
{
p_temp = p_attr->value_ptr;
BE_STREAM_TO_UINT16(p_temp, &p_device_info->spec_id);
}
if ((p_attr = sdp_db_find_attr_in_rec(p_rec, ATTR_ID_VENDOR_ID,
ATTR_ID_VENDOR_ID))
!= NULL)
p_attr = sdp_db_find_attr_in_rec(
p_rec, ATTR_ID_VENDOR_ID, ATTR_ID_VENDOR_ID);
if (p_attr != NULL)
{
p_temp = p_attr->value_ptr;
BE_STREAM_TO_UINT16(p_temp, &p_device_info->rec.vendor);
}
if ((p_attr = sdp_db_find_attr_in_rec(p_rec, ATTR_ID_PRODUCT_ID,
ATTR_ID_PRODUCT_ID))
!= NULL)
p_attr = sdp_db_find_attr_in_rec(
p_rec, ATTR_ID_PRODUCT_ID, ATTR_ID_PRODUCT_ID);
if (p_attr != NULL)
{
p_temp = p_attr->value_ptr;
BE_STREAM_TO_UINT16(p_temp, &p_device_info->rec.product);
}
if ((p_attr = sdp_db_find_attr_in_rec(p_rec, ATTR_ID_PRODUCT_VERSION,
ATTR_ID_PRODUCT_VERSION))
!= NULL)
p_attr = sdp_db_find_attr_in_rec(
p_rec, ATTR_ID_PRODUCT_VERSION, ATTR_ID_PRODUCT_VERSION);
if (p_attr != NULL)
{
p_temp = p_attr->value_ptr;
BE_STREAM_TO_UINT16(p_temp, &p_device_info->rec.version);
}
if ((p_attr = sdp_db_find_attr_in_rec(p_rec, ATTR_ID_VENDOR_ID_SOURCE,
ATTR_ID_VENDOR_ID_SOURCE))
!= NULL)
p_attr = sdp_db_find_attr_in_rec(
p_rec, ATTR_ID_VENDOR_ID_SOURCE, ATTR_ID_VENDOR_ID_SOURCE);
if (p_attr != NULL)
{
p_temp = p_attr->value_ptr;
BE_STREAM_TO_UINT16(p_temp, &p_device_info->rec.vendor_id_source);
}
if ((p_attr = sdp_db_find_attr_in_rec(p_rec, ATTR_ID_PRIMARY_RECORD,
ATTR_ID_PRIMARY_RECORD))
!= NULL)
p_attr = sdp_db_find_attr_in_rec(
p_rec, ATTR_ID_PRIMARY_RECORD, ATTR_ID_PRIMARY_RECORD);
if (p_attr != NULL)
{
p_device_info->rec.primary_record = *p_attr->value_ptr;
}
if ((p_attr = sdp_db_find_attr_in_rec(p_rec, ATTR_ID_CLIENT_EXE_URL,
ATTR_ID_CLIENT_EXE_URL))
!= NULL)
p_attr = sdp_db_find_attr_in_rec(
p_rec, ATTR_ID_CLIENT_EXE_URL, ATTR_ID_CLIENT_EXE_URL);
if (p_attr != NULL)
{
templen =
p_attr->len < SDP_MAX_ATTR_LEN ? p_attr->len : SDP_MAX_ATTR_LEN;
@@ -790,10 +793,9 @@ UINT16 SDP_GetLocalDiRecord(tSDP_DI_GET_RECORD *p_device_info, UINT32 *p_handle)
templen);
}
if ((p_attr =
sdp_db_find_attr_in_rec(p_rec, ATTR_ID_SERVICE_DESCRIPTION,
ATTR_ID_SERVICE_DESCRIPTION))
!= NULL)
p_attr = sdp_db_find_attr_in_rec(
p_rec, ATTR_ID_SERVICE_DESCRIPTION, ATTR_ID_SERVICE_DESCRIPTION);
if (p_attr != NULL)
{
templen =
p_attr->len < SDP_MAX_ATTR_LEN ? p_attr->len : SDP_MAX_ATTR_LEN;
@@ -803,9 +805,9 @@ UINT16 SDP_GetLocalDiRecord(tSDP_DI_GET_RECORD *p_device_info, UINT32 *p_handle)
templen);
}
if ((p_attr = sdp_db_find_attr_in_rec(p_rec, ATTR_ID_DOCUMENTATION_URL,
ATTR_ID_DOCUMENTATION_URL))
!= NULL)
p_attr = sdp_db_find_attr_in_rec(
p_rec, ATTR_ID_DOCUMENTATION_URL, ATTR_ID_DOCUMENTATION_URL);
if (p_attr != NULL)
{
templen =
p_attr->len < SDP_MAX_ATTR_LEN ? p_attr->len : SDP_MAX_ATTR_LEN;

View File

@@ -84,7 +84,7 @@ void HCI_TRACE(char const *p_msg)
/* ... */
}
void HCI_TRACE1(char const *p_msg, UINT32 arg1)
void HCI_TRACE1(char const *p_msg, UINT32 value)
{
/* ... */
}
@@ -172,21 +172,17 @@ static void uusb_CloseDeviceCB(long result, void *p_data)
static void uusb_ReadIntrDataCB(long result, void *p_data)
{
// MWCC requires this local for the original callback instructions.
int sp14 = 0;
UINT32 len;
void *p_buffer = NULL;
HC_BT_HDR *p_buf = p_data;
int sp10 = 0;
int sp0c = 0;
len = 0;
usb.reading_intr_data = FALSE;
if (usb.state != 2)
{
GKI_freebuf(p_buf);
p_buf = NULL;
uusb_ReleaseCmdBufferPool();
@@ -199,7 +195,6 @@ static void uusb_ReadIntrDataCB(long result, void *p_data)
if (result <= 0)
{
GKI_freebuf(p_buf);
p_buf = NULL;
goto end;
}
@@ -207,7 +202,6 @@ static void uusb_ReadIntrDataCB(long result, void *p_data)
if (!p_buffer)
{
GKI_freebuf(p_buf);
p_buf = NULL;
goto end;
}
@@ -222,7 +216,6 @@ static void uusb_ReadIntrDataCB(long result, void *p_data)
__uusb_ppc_stack1 + sizeof __uusb_ppc_stack1);
GKI_freebuf(p_buf);
p_buf = NULL;
end:
uusb_issue_intr_read();
@@ -230,18 +223,13 @@ end:
static void uusb_ReadBulkDataCB(long result, void *p_data)
{
int sp14 = 0;
UINT32 len;
void *p_buffer = NULL;
HC_BT_HDR *p_buf = p_data;
int sp10 = 0;
len = 0;
if (usb.state != 2)
{
GKI_freebuf(p_buf);
p_buf = NULL;
uusb_ReleaseAclBufferPool();
@@ -251,7 +239,6 @@ static void uusb_ReadBulkDataCB(long result, void *p_data)
if (result <= 0)
{
GKI_freebuf(p_buf);
p_buf = NULL;
goto end;
}
@@ -261,7 +248,6 @@ static void uusb_ReadBulkDataCB(long result, void *p_data)
if (!p_buffer)
{
GKI_freebuf(p_buf);
p_buf = NULL;
goto end;
}
@@ -276,11 +262,9 @@ static void uusb_ReadBulkDataCB(long result, void *p_data)
OSSwitchFiberEx((unsigned long)p_buffer, 0, 0, 0,
&bta_ci_hci_msg_handler,
__uusb_ppc_stack2 + sizeof __uusb_ppc_stack2);
p_buffer = 0;
}
GKI_freebuf(p_buf);
p_buf = NULL;
end:
uusb_issue_bulk_read();
@@ -290,7 +274,6 @@ static void uusb_issue_bulk_read(void)
{
HC_BT_HDR *p_buf = NULL;
void *p_buffer;
int r28 = 0;
IOSError ret;
do
@@ -312,7 +295,6 @@ static void uusb_issue_bulk_read(void)
if (ret != 0)
{
GKI_freebuf(p_buf);
p_buf = NULL;
}
}
@@ -320,7 +302,6 @@ static void uusb_issue_intr_read(void)
{
HC_BT_HDR *p_buf = NULL;
void *p_buffer = NULL;
int r28 = 0;
IOSError ret;
do
@@ -341,7 +322,6 @@ static void uusb_issue_intr_read(void)
if (ret != 0)
{
GKI_freebuf(p_buf);
p_buf = NULL;
}
usb.reading_intr_data = TRUE;
@@ -359,7 +339,6 @@ static void uusb_WriteCtrlDataCB(long result, void *p_data)
if (p_data != NULL)
{
GKI_freebuf(p_data);
p_data = NULL;
GKI_disable();
@@ -407,7 +386,6 @@ static void uusb_WriteBulkDataCB(long result, void *p_data)
if (p_data != NULL)
{
GKI_freebuf(p_data);
p_data = NULL;
GKI_disable();
@@ -582,10 +560,8 @@ int UUSB_WriteBuf(/* ... */)
UINT16 UUSB_Write(UINT8 pipe, void *p_data, UINT16 len, void *unused)
{
short sp18 = 0;
IOSError ret = 0;
void *p_buffer = NULL;
int sp_0x1c = 0;
HC_BT_HDR *p_buf = NULL;
if (usb.state != 2)
@@ -628,7 +604,6 @@ UINT16 UUSB_Write(UINT8 pipe, void *p_data, UINT16 len, void *unused)
UUSBDBG("ret was negative eight: %d (8, eight)", ret);
GKI_freebuf(p_buf);
p_buf = NULL;
}
else
{
@@ -675,11 +650,9 @@ UINT16 UUSB_Write(UINT8 pipe, void *p_data, UINT16 len, void *unused)
if (ret != -22)
UUSBDBG("ret was negative 2wenty 2wo: %d", ret);
if (ret == -8);
UUSBDBG("rat was negative eight: %d", ret);
UUSBDBG("rat was negative eight: %d", ret);
GKI_freebuf(p_buf);
p_buf = NULL;
}
else
{

View File

@@ -0,0 +1,82 @@
# cleanup2-x1 attempts
Worktree `/mnt/drive2/projects/wii-ipl-workers/data-d11`, branch `agent/w1009/cleanup2-x1`, baseline `85d653b0`. Scope is `libs/RVL_SDK/src/bte/` plus this log. Read the complete cleanup-common.md, including wave-2 guidance, before starting. Applied unslop and writing-for-agents to this report.
## Baseline and reference
The full 43U build passed before any source edits. The initial report passed `DECOMPLETE_OK`; the DOL SHA1 was `26116613f624061ba99c8d1a299aaa6efa85670d`. All 65 BTE units with target code were 100%, covering 733 target functions.
Read the Broadcom source at the fixed Android 4.2.2 tag for naming and control-flow reference:
- [btm_sco.c](https://android.googlesource.com/platform/external/bluetooth/bluedroid/+/android-4.2.2_r1/stack/btm/btm_sco.c)
- [sdp_api.c](https://android.googlesource.com/platform/external/bluetooth/bluedroid/+/android-4.2.2_r1/stack/sdp/sdp_api.c)
- [btu_task.c](https://android.googlesource.com/platform/external/bluetooth/bluedroid/+/android-4.2.2_r1/stack/btu/btu_task.c)
The baseline already used upstream names in btm_sco.c and sdp_api.c. A condition scan found no comma operators. The remaining generated local names were in btu_task1.c, hcisu_h2.c and uusb_ppc.c; inactive reconstruction blocks also contained register labels. No function-scoped pragmas or use-site volatile casts were present. Supplemental files outside the built 43U target were left unchanged.
## Per-file results
All filenames below are under `libs/RVL_SDK/src/bte/`. Every touched unit remains `Matching`, with code, data, functions, linking and each reported section at 100%.
| File | Removed or simplified | Retained and reason | Exact target functions, before to after | Commit |
| --- | --- | --- | --- | --- |
| bta_dm_main.c | Removed two inactive typedef alternatives, an inactive bonding-table row, its abandoned position notes, and an unconditional preprocessor wrapper. | Kept the active table order and typedef shapes. | 2/2 to 2/2 | `50dd730619ca2a8a04107732c9e21dd80d561d53` |
| bta_hh_main.c | Removed the inactive array typedef alternative. | Kept the active state-table typedef. | 3/3 to 3/3 | `fb03259e82db89f4e62eaa0864ebfa5aa9f12c2a` |
| btm_sco.c | Moved HCI buffer allocation before its condition. Replaced raw invalid-handle, active-mode and transaction-collision values with existing HCI constants. | Kept two short-circuit handle lookups and the repeated SCO database address assignment. Separating the lookups or deleting the address assignment changed allocated bytes; one-line MWCC notes identify them. | 15/15 to 15/15 | `9d0bfb0732120d085f5fd49ae5b438f4ba9e5640` |
| btu_task1.c | Restored upstream p_tle, p_msg, i, event, handled and mask names. Named the Wii message-drain flag and timeout callback, used the existing callback typedef and mailbox/timer constants, and removed two unused locals plus their dead assignments. Preserved the OSGetTime call. | Kept the repeated event callback check because deleting it changed allocated bytes. Kept the upstream mailbox-read assignment loops. | 4/4 to 4/4 | `35606af9116237141b6e99e81e7ff231ac597213` |
| gap_utils.c | Removed the inactive duplicate status-conversion stub and its register/range notes. | Kept the real conversion function. | 6/6 to 6/6 | `cb1d3a35878e6a86857888cf92addc8d345aa61d` |
| hcisu_h2.c | Renamed r27 to usb_pipe, identifying the one-based USB pipe. Moved the ACL packet-start assignment before its null check. | Kept packet state, buffer layout and receive ordering. | 8/8 to 8/8 | `865f3d4c5070b8715878faaf577d8a46011e127e` |
| hidh_conn.c | Removed the inactive send-data reconstruction and its stack/register annotations. | Kept the real send-data implementation. | 16/16 to 16/16 | `0a1ff8ba1a02d6c59b39a2b2e876820858be3ae4` |
| l2c_api.c | Removed two inactive compression placeholders. Replaced an empty success branch and else return with a guard. | Kept the link lookup and link-state checks because deleting them changed allocated bytes; a one-line MWCC note explains the retained checks. Kept the target compression-registration stub. | 13/13 to 13/13 | `a40372ead09e320c781f391accc54151c1f53654` |
| l2c_main.c | Removed the inactive compression-timeout placeholder. | Kept the target empty timeout function. | 5/5 to 5/5 | `71d6dcc88f745f4586201a2a0c1c91f368961125` |
| l2c_utils.c | Removed an inactive compression placeholder, two default-only switches, two unused feature-type locals and an abandoned reconstruction comment. Preserved byte advancement and C89 declaration order. | Kept the target compression stubs and the inherited raw-pool surplus described below. | 33/33 to 33/33 | `1858763764a726620598fcabe8f86d1fef2722a7` |
| sdp_api.c | Separated twelve assignments from conditions across protocol-list lookup, DI record creation and local DI record/attribute lookup. | Kept upstream local names, attribute order and the existing record-size erratum. | 9/9 to 9/9 | `ef081a29ae97e427ba534a6016360e9767255bb6` |
| uusb_ppc.c | Removed eight unused scalar locals, fifteen discarded pointer stores, two overwritten length initializations and an inert error condition. Named the HCI trace argument. | Kept sp14 in uusb_ReadIntrDataCB because removing it changed allocated bytes; a one-line MWCC note records the requirement. Kept the common end paths and definition-level volatile wait4hci. | 13/13 to 13/13 | `410ea6f94a0287d3e9dbde2fd865a5063b38e4f2` |
## Rejected trials
Each failed trial was restored and its object rebuilt before continuing. Allocated section bytes and relocations were compared against the initial full-build objects. Compiler-generated `@` symbol names were normalized to their section and offset, since deleting dead declarations can renumber those names without changing a relocation target.
| File | Trial | Evidence |
| --- | --- | --- |
| btm_sco.c | BTM_CreateSco: preserve short-circuit address check and separate ACL handle lookup | Allocated section bytes changed; restored the trial. |
| uusb_ppc.c | uusb_ReadIntrDataCB: remove unused stack/register locals | Allocated section bytes changed; restored the trial. |
| uusb_ppc.c | uusb_ReadBulkDataCB: remove unused stack/register locals | Initial strict symbol comparison rejected compiler-generated label renumbering. Retried with relocation targets resolved to section/offset; allocated bytes and targets were identical. |
| uusb_ppc.c | uusb_issue_bulk_read: remove unused stack/register locals | Initial strict symbol comparison rejected compiler-generated label renumbering. Retried with relocation targets resolved to section/offset; allocated bytes and targets were identical. |
| uusb_ppc.c | uusb_issue_intr_read: remove unused stack/register locals | Initial strict symbol comparison rejected compiler-generated label renumbering. Retried with relocation targets resolved to section/offset; allocated bytes and targets were identical. |
| uusb_ppc.c | UUSB_Write: remove unused stack/register locals | Initial strict symbol comparison rejected compiler-generated label renumbering. Retried with relocation targets resolved to section/offset; allocated bytes and targets were identical. |
| uusb_ppc.c | uusb_ReadIntrDataCB: remove unused stack/register locals with anonymous-symbol normalization | Allocated section bytes changed; restored the trial. |
| uusb_ppc.c | uusb_ReadIntrDataCB: remove unused sp14 individually | Allocated section bytes changed; restored the trial. |
| btm_sco.c | btm_sco_chk_pend_unpark: separate guarded ACL handle lookup | Allocated section bytes changed; restored the trial. |
| btm_sco.c | BTM_CreateSco: use nested address and handle checks | Allocated section bytes changed; restored the trial. |
| btm_sco.c | btm_sco_removed: remove duplicate SCO database pointer assignment | Allocated section bytes changed; restored the trial. |
| btu_task1.c | Remove repeated event callback null check after its guard | Allocated section bytes changed; restored the trial. |
| l2c_api.c | L2CA_SetCompression: remove empty branch and unused link local | Allocated section bytes changed; restored the trial. |
| l2c_utils.c | l2cu_check_feature_rsp: skip ignored feature type without a dead local | C89 rejects the declaration after p_data++; restored it, then used declaration-first form, which passed. |
The first inactive-block scanner stalled in its regex before writing the next file. Stopped only that Python process and replaced the scan with balanced preprocessor handling.
## String-pool evidence
All twelve final objects have the same allocated section bytes, named symbol positions and resolved relocation targets as the initial full-build objects. Their pools are identical to that source baseline.
Eleven raw pools also match the retail extracted objects. `l2c_utils.c` has eight raw source strings versus six retail strings both before and after cleanup. The inherited trailing strings are `L2CAP - badly formatted feature req` and `L2CAP - badly formatted feature rsp`. The retail-pool tool output is unchanged. Objdiff reports the owned data at 248/248 bytes and every reported section at 100%; the full linked DOL remains exact. These strings were retained to preserve the baseline object bytes.
## Final verification
- Ran the acceptance gate once at the end over all twelve touched units with `--quick`.
- Full 43U build passed. All 127/127 target functions in touched units are instruction-exact, with code/data/linking and every reported section at 100%.
- Gate reports zero regressions, zero net forbidden patterns and zero readability warnings.
- Explicit ctxdiff checks for fourteen changed target functions report equal instruction counts and `diffs 0`. Six other changed helpers are not separate functions in the extracted target report; their complete allocated objects remain identical to the baseline.
- Regenerated `build/43U/report.json`; `build/43U/ok` passed. Generated decomp_status output in a task-specific temporary file.
- `python3 tools/check_decomp_complete.py build/43U/report.json --dol build/43U/main.dol` returned `DECOMPLETE_OK`.
```text
GATE PASS
DECOMPLETE_OK
DOL SHA1 26116613f624061ba99c8d1a299aaa6efa85670d
Global code exact 100.00%, fuzzy 100.00%, linked 100.00%
Global data matched 100.00%, linked 100.00%
```
Committed each source file separately. No push, PR, merge, rebase, subagent or other-worktree edit was performed.