OSDN Git Service

Add const stack/l2cap/l2c_link::l2c_link_send_to_lower
authorChris Manton <cmanton@google.com>
Sat, 22 Aug 2020 15:26:49 +0000 (08:26 -0700)
committerChris Manton <cmanton@google.com>
Sat, 22 Aug 2020 16:11:32 +0000 (09:11 -0700)
Pull out fit-in-buffer conditions

Towards proper interfaces

Bug: 163134718
Tag: #refactor
Test: compile & verify basic functions working

Change-Id: I861f7dc5eef2ee032a8e08c681ee5f18c7b5d277

stack/l2cap/l2c_link.cc

index d4c5e9b..9d52a09 100644 (file)
@@ -1024,9 +1024,13 @@ static void l2c_link_send_to_lower(tL2C_LCB* p_lcb, BT_HDR* p_buf,
   const uint16_t link_xmit_quota = p_lcb->link_xmit_quota;
   const tBT_TRANSPORT transport = p_lcb->transport;
 
-  if (((transport == BT_TRANSPORT_BR_EDR) &&
-       (p_buf->len <= acl_packet_size_classic)) ||
-      ((transport == BT_TRANSPORT_LE) && (p_buf->len <= acl_packet_size_ble))) {
+  const bool is_bdr_and_fits_in_buffer =
+      (transport == BT_TRANSPORT_BR_EDR &&
+       (p_buf->len <= acl_packet_size_classic));
+  const bool is_ble_and_fits_in_buffer =
+      (transport == BT_TRANSPORT_LE && (p_buf->len <= acl_packet_size_ble));
+
+  if (is_bdr_and_fits_in_buffer || is_ble_and_fits_in_buffer) {
     if (link_xmit_quota == 0) {
       if (transport == BT_TRANSPORT_LE)
         l2cb.ble_round_robin_unacked++;