From 0c422c2027892406b3d0200f80ff7f56e2b325e0 Mon Sep 17 00:00:00 2001 From: Chris Manton Date: Fri, 9 Oct 2020 13:44:07 -0700 Subject: [PATCH] Add return condition to stack/l2cap/l2c_ble::l2cble_conn_comp Eventually not pass control here Bug: 170396407 Tag: #refactor Test: act.py -tc BleCocTest Test: ble paired 2 phones Test: classic paired Bose SoundLink Change-Id: Idda6b2ad34499ce1a7ad0e7770cb973a9b5d44ec --- stack/include/l2cap_hci_link_interface.h | 4 ++-- stack/l2cap/l2c_ble.cc | 16 +++++++++------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/stack/include/l2cap_hci_link_interface.h b/stack/include/l2cap_hci_link_interface.h index 63290fe67..e0c994a44 100644 --- a/stack/include/l2cap_hci_link_interface.h +++ b/stack/include/l2cap_hci_link_interface.h @@ -29,12 +29,12 @@ extern bool l2c_link_hci_disc_comp(uint16_t handle, uint8_t reason); extern void l2c_link_role_changed(const RawAddress* bd_addr, uint8_t new_role, uint8_t hci_status); -extern void l2cble_conn_comp(uint16_t handle, uint8_t role, +extern bool l2cble_conn_comp(uint16_t handle, uint8_t role, const RawAddress& bda, tBLE_ADDR_TYPE type, uint16_t conn_interval, uint16_t conn_latency, uint16_t conn_timeout); -extern void l2cble_conn_comp_from_address_with_type( +extern bool l2cble_conn_comp_from_address_with_type( uint16_t handle, uint8_t role, const tBLE_BD_ADDR& address_with_type, uint16_t conn_interval, uint16_t conn_latency, uint16_t conn_timeout); diff --git a/stack/l2cap/l2c_ble.cc b/stack/l2cap/l2c_ble.cc index 341561fe8..4b971f786 100644 --- a/stack/l2cap/l2c_ble.cc +++ b/stack/l2cap/l2c_ble.cc @@ -266,7 +266,7 @@ void l2cble_notify_le_connection(const RawAddress& bda) { /** This function is called when an HCI Connection Complete event is received. */ -void l2cble_conn_comp(uint16_t handle, uint8_t role, const RawAddress& bda, +bool l2cble_conn_comp(uint16_t handle, uint8_t role, const RawAddress& bda, tBLE_ADDR_TYPE type, uint16_t conn_interval, uint16_t conn_latency, uint16_t conn_timeout) { // role == HCI_ROLE_MASTER => scanner completed connection @@ -281,19 +281,19 @@ void l2cble_conn_comp(uint16_t handle, uint8_t role, const RawAddress& bda, if (!p_lcb) { btm_sec_disconnect(handle, HCI_ERR_NO_CONNECTION); LOG_ERROR("Unable to allocate link resource for le acl connection"); - return; + return false; } else { if (!l2cu_initialize_fixed_ccb(p_lcb, L2CAP_ATT_CID)) { btm_sec_disconnect(handle, HCI_ERR_NO_CONNECTION); LOG_ERROR("Unable to allocate channel resource for le acl connection"); - return; + return false; } } } else if (role == HCI_ROLE_MASTER && p_lcb->link_state != LST_CONNECTING) { LOG_ERROR( "Received le acl connection as role master but not in connecting " "state"); - return; + return false; } if (role == HCI_ROLE_MASTER) alarm_cancel(p_lcb->l2c_lcb_timer); @@ -333,13 +333,15 @@ void l2cble_conn_comp(uint16_t handle, uint8_t role, const RawAddress& bda, l2cu_process_fixed_chnl_resp(p_lcb); } } + return true; } -void l2cble_conn_comp_from_address_with_type( +bool l2cble_conn_comp_from_address_with_type( uint16_t handle, uint8_t role, const tBLE_BD_ADDR& address_with_type, uint16_t conn_interval, uint16_t conn_latency, uint16_t conn_timeout) { - l2cble_conn_comp(handle, role, address_with_type.bda, address_with_type.type, - conn_interval, conn_latency, conn_timeout); + return l2cble_conn_comp(handle, role, address_with_type.bda, + address_with_type.type, conn_interval, conn_latency, + conn_timeout); } /******************************************************************************* -- 2.11.0