From 437a21aede3785ae158bfe1ba4347597b492485b Mon Sep 17 00:00:00 2001 From: Chris Manton Date: Tue, 22 Sep 2020 13:21:58 -0700 Subject: [PATCH] Re-Var stack/acl/btm_acl::btm_acl_created Because 'p' is a terrible variable name Towards readable code Bug: 163134718 Tag: #refactor Test: acts -tc BleCocTest Test: ble paired 2 phones Change-Id: I78ef2c1051ba151dbe605114aa5c45097f29bcde --- stack/acl/btm_acl.cc | 60 ++++++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/stack/acl/btm_acl.cc b/stack/acl/btm_acl.cc index 2e49a77de..ad6fbf0bd 100644 --- a/stack/acl/btm_acl.cc +++ b/stack/acl/btm_acl.cc @@ -334,7 +334,6 @@ void btm_acl_process_sca_cmpl_pkt(uint8_t len, uint8_t* data) { void btm_acl_created(const RawAddress& bda, uint16_t hci_handle, uint8_t link_role, tBT_TRANSPORT transport) { tBTM_SEC_DEV_REC* p_dev_rec = NULL; - tACL_CONN* p; uint8_t xx; BTM_TRACE_DEBUG("%s: peer %s hci_handle=%d link_role=%d transport=%d", @@ -342,33 +341,34 @@ void btm_acl_created(const RawAddress& bda, uint16_t hci_handle, transport); /* Ensure we don't have duplicates */ - p = internal_.btm_bda_to_acl(bda, transport); - if (p != (tACL_CONN*)NULL) { - p->hci_handle = hci_handle; - p->link_role = link_role; - p->transport = transport; - btm_set_link_policy(p, btm_cb.acl_cb_.btm_def_link_policy); + tACL_CONN* p_acl = internal_.btm_bda_to_acl(bda, transport); + if (p_acl != (tACL_CONN*)NULL) { + p_acl->hci_handle = hci_handle; + p_acl->link_role = link_role; + p_acl->transport = transport; + btm_set_link_policy(p_acl, btm_cb.acl_cb_.btm_def_link_policy); VLOG(1) << "Duplicate btm_acl_created: RemBdAddr: " << bda; return; } /* Allocate acl_db entry */ - for (xx = 0, p = &btm_cb.acl_cb_.acl_db[0]; xx < MAX_L2CAP_LINKS; xx++, p++) { - if (!p->in_use) { - p->in_use = true; - p->hci_handle = hci_handle; - p->link_role = link_role; - p->link_up_issued = false; - p->remote_addr = bda; - p->sca = 0xFF; - btm_set_link_policy(p, btm_cb.acl_cb_.btm_def_link_policy); - - p->transport = transport; + for (xx = 0, p_acl = &btm_cb.acl_cb_.acl_db[0]; xx < MAX_L2CAP_LINKS; + xx++, p_acl++) { + if (!p_acl->in_use) { + p_acl->in_use = true; + p_acl->hci_handle = hci_handle; + p_acl->link_role = link_role; + p_acl->link_up_issued = false; + p_acl->remote_addr = bda; + p_acl->sca = 0xFF; + btm_set_link_policy(p_acl, btm_cb.acl_cb_.btm_def_link_policy); + + p_acl->transport = transport; if (transport == BT_TRANSPORT_LE) btm_ble_refresh_local_resolvable_private_addr( bda, btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr); - p->switch_role_failed_attempts = 0; - p->reset_switch_role(); + p_acl->switch_role_failed_attempts = 0; + p_acl->reset_switch_role(); /******************************************************************************* * @@ -387,8 +387,8 @@ void btm_acl_created(const RawAddress& bda, uint16_t hci_handle, /* if BR/EDR do something more */ if (transport == BT_TRANSPORT_BR_EDR) { - btsnd_hcic_read_rmt_clk_offset(p->hci_handle); - btsnd_hcic_rmt_ver_req(p->hci_handle); + btsnd_hcic_read_rmt_clk_offset(p_acl->hci_handle); + btsnd_hcic_rmt_ver_req(p_acl->hci_handle); } p_dev_rec = btm_find_dev_by_handle(hci_handle); @@ -402,36 +402,36 @@ void btm_acl_created(const RawAddress& bda, uint16_t hci_handle, * setup */ if ((p_dev_rec->num_read_pages) && (p_dev_rec->num_read_pages <= (HCI_EXT_FEATURES_PAGE_MAX + 1))) { - memcpy(p->peer_lmp_feature_pages, p_dev_rec->feature_pages, + memcpy(p_acl->peer_lmp_feature_pages, p_dev_rec->feature_pages, (HCI_FEATURE_BYTES_PER_PAGE * p_dev_rec->num_read_pages)); - p->num_read_pages = p_dev_rec->num_read_pages; + p_acl->num_read_pages = p_dev_rec->num_read_pages; const uint8_t req_pend = (p_dev_rec->sm4 & BTM_SM4_REQ_PEND); /* Store the Peer Security Capabilites (in SM4 and rmt_sec_caps) */ - btm_sec_set_peer_sec_caps(p, p_dev_rec); + btm_sec_set_peer_sec_caps(p_acl, p_dev_rec); BTM_TRACE_API("%s: pend:%d", __func__, req_pend); if (req_pend) { /* Request for remaining Security Features (if any) */ l2cu_resubmit_pending_sec_req(&p_dev_rec->bd_addr); } - internal_.btm_establish_continue(p); + internal_.btm_establish_continue(p_acl); return; } } /* If here, features are not known yet */ if (p_dev_rec && transport == BT_TRANSPORT_LE) { - btm_ble_get_acl_remote_addr(p_dev_rec, p->active_remote_addr, - &p->active_remote_addr_type); + btm_ble_get_acl_remote_addr(p_dev_rec, p_acl->active_remote_addr, + &p_acl->active_remote_addr_type); if (controller_get_interface() ->supports_ble_peripheral_initiated_feature_exchange() || link_role == HCI_ROLE_MASTER) { - btsnd_hcic_ble_read_remote_feat(p->hci_handle); + btsnd_hcic_ble_read_remote_feat(p_acl->hci_handle); } else { - internal_.btm_establish_continue(p); + internal_.btm_establish_continue(p_acl); } } -- 2.11.0