OSDN Git Service

Simplify StackAclBtmAcl::btm_bda_to_acl
authorChris Manton <cmanton@google.com>
Sun, 16 Aug 2020 22:03:26 +0000 (15:03 -0700)
committerChris Manton <cmanton@google.com>
Tue, 6 Oct 2020 06:03:42 +0000 (06:03 +0000)
Towards proper interfaces

Bug: 163134718
Tag: #refactor
Test: act.py -tc BleCocTest
Test: ble paired 2 phones
Test: classic paired Bose SoundLink

Change-Id: I6573f60cbf5e469fe780c6d5a4506c0dcd39f590

stack/acl/btm_acl.cc

index ebccfa1..c7fd126 100644 (file)
@@ -203,22 +203,20 @@ void BTM_acl_after_controller_started() {
  *                 (BR/EDR or LE)
  *
  * Returns         Returns pointer to the ACL DB for the requested BDA if found.
- *                 NULL if not found.
+ *                 nullptr if not found.
  *
  ******************************************************************************/
 tACL_CONN* StackAclBtmAcl::btm_bda_to_acl(const RawAddress& bda,
                                           tBT_TRANSPORT transport) {
-  tACL_CONN* p = &btm_cb.acl_cb_.acl_db[0];
-  uint16_t xx;
-  for (xx = 0; xx < MAX_L2CAP_LINKS; xx++, p++) {
-    if ((p->in_use) && p->remote_addr == bda && p->transport == transport) {
+  tACL_CONN* p_acl = &btm_cb.acl_cb_.acl_db[0];
+  for (uint8_t index = 0; index < MAX_L2CAP_LINKS; index++, p_acl++) {
+    if ((p_acl->in_use) && p_acl->remote_addr == bda &&
+        p_acl->transport == transport) {
       BTM_TRACE_DEBUG("btm_bda_to_acl found");
-      return (p);
+      return p_acl;
     }
   }
-
-  /* If here, no BD Addr found */
-  return ((tACL_CONN*)NULL);
+  return nullptr;
 }
 
 /*******************************************************************************