From 327890d2889c00718a4a2f2131e79a07b93a7bea Mon Sep 17 00:00:00 2001 From: Chris Manton Date: Wed, 26 Aug 2020 10:26:45 -0700 Subject: [PATCH] stack/acl/btm_acl::BTM_GetRole Towards readable code Bug: 163134718 Tag: #refactor Test: compile & verify basic functions working Change-Id: I6dfd3908bbbfe236457d8b629e02e231b407485e --- stack/acl/btm_acl.cc | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/stack/acl/btm_acl.cc b/stack/acl/btm_acl.cc index 21ee8b9e7..b2f2a81cd 100644 --- a/stack/acl/btm_acl.cc +++ b/stack/acl/btm_acl.cc @@ -506,29 +506,19 @@ void btm_acl_update_inquiry_status(uint8_t status) { BTIF_dm_report_inquiry_status_change(status); } -/******************************************************************************* - * - * Function BTM_GetRole - * - * Description This function is called to get the role of the local device - * for the ACL connection with the specified remote device - * - * Returns BTM_SUCCESS if connection exists. - * BTM_UNKNOWN_ADDR if no active link with bd addr specified - * - ******************************************************************************/ tBTM_STATUS BTM_GetRole(const RawAddress& remote_bd_addr, uint8_t* p_role) { - tACL_CONN* p; - BTM_TRACE_DEBUG("BTM_GetRole"); - p = internal_.btm_bda_to_acl(remote_bd_addr, BT_TRANSPORT_BR_EDR); - if (p == NULL) { - *p_role = HCI_ROLE_UNKNOWN; - return (BTM_UNKNOWN_ADDR); + if (p_role == nullptr) { + return BTM_ILLEGAL_VALUE; } + *p_role = HCI_ROLE_UNKNOWN; - /* Get the current role */ - *p_role = p->link_role; - return (BTM_SUCCESS); + tACL_CONN* p_acl = + internal_.btm_bda_to_acl(remote_bd_addr, BT_TRANSPORT_BR_EDR); + if (p_acl == nullptr) { + return BTM_UNKNOWN_ADDR; + } + *p_role = p_acl->link_role; + return BTM_SUCCESS; } /******************************************************************************* -- 2.11.0