Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 828092b7 authored by Zach Johnson's avatar Zach Johnson Committed by Chris Manton
Browse files

More simplification to bta_dm_acl_change

Instead of constantly referencing the array by index, grab a pointer
to the object and use that.

Bug: 159815595
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: I5d9549bab81ea3ff4a83ded7a4cb3eb62734ec8f
parent 7b75ffe4
Loading
Loading
Loading
Loading
+6 −7
Original line number Diff line number Diff line
@@ -2746,14 +2746,14 @@ static void bta_dm_acl_change(bool is_new, const RawAddress& bd_addr,
    if (bta_dm_cb.p_sec_cback) bta_dm_cb.p_sec_cback(BTA_DM_LINK_UP_EVT, &conn);
  } else {
    for (uint8_t i = 0; i < bta_dm_cb.device_list.count; i++) {
      if (bta_dm_cb.device_list.peer_device[i].peer_bdaddr != bd_addr ||
          bta_dm_cb.device_list.peer_device[i].transport != transport)
      auto device = &bta_dm_cb.device_list.peer_device[i];
      if (device->peer_bdaddr != bd_addr || device->transport != transport)
        continue;

      if (bta_dm_cb.device_list.peer_device[i].conn_state == BTA_DM_UNPAIRING) {
        if (BTM_SecDeleteDevice(
                bta_dm_cb.device_list.peer_device[i].peer_bdaddr))
      if (device->conn_state == BTA_DM_UNPAIRING) {
        if (BTM_SecDeleteDevice(device->peer_bdaddr)) {
          issue_unpair_cb = true;
        }

        /* remove all cached GATT information */
        BTA_GATTC_Refresh(bd_addr);
@@ -2762,8 +2762,7 @@ static void bta_dm_acl_change(bool is_new, const RawAddress& bd_addr,
                         issue_unpair_cb);
      }

      conn.link_down.is_removed =
          bta_dm_cb.device_list.peer_device[i].remove_dev_pending;
      conn.link_down.is_removed = device->remove_dev_pending;

      // Iterate to the one before the last when shrinking the list,
      // otherwise we memcpy garbage data into the record.