OSDN Git Service

Fix btm_sco_connected usage
authorHansong Zhang <hsz@google.com>
Thu, 21 Jan 2021 19:25:38 +0000 (11:25 -0800)
committerHansong Zhang <hsz@google.com>
Thu, 21 Jan 2021 22:58:55 +0000 (14:58 -0800)
Don't invoke when bda is nullptr.

Test: cert/run
Tag: #gd-refactor
Bug: 141555841
Change-Id: I2509e905849c6b9e224242e2486a8e3496e6314a

stack/btm/btm_sco.cc
stack/btu/btu_hcif.cc
stack/include/sco_hci_link_interface.h

index 92a7f5e..3782685 100644 (file)
@@ -683,7 +683,7 @@ void btm_sco_conn_req(const RawAddress& bda, DEV_CLASS dev_class,
  * Returns          void
  *
  ******************************************************************************/
-void btm_sco_connected(uint8_t hci_status, const RawAddress* bda,
+void btm_sco_connected(uint8_t hci_status, const RawAddress& bda,
                        uint16_t hci_handle, tBTM_ESCO_DATA* p_esco_data) {
   tSCO_CONN* p = &btm_cb.sco_cb.sco_db[0];
   uint16_t xx;
@@ -693,7 +693,7 @@ void btm_sco_connected(uint8_t hci_status, const RawAddress* bda,
   for (xx = 0; xx < BTM_MAX_SCO_LINKS; xx++, p++) {
     if (((p->state == SCO_ST_CONNECTING) || (p->state == SCO_ST_LISTENING) ||
          (p->state == SCO_ST_W4_CONN_RSP)) &&
-        (p->rem_bd_known) && (!bda || p->esco.data.bd_addr == *bda)) {
+        (p->rem_bd_known) && (p->esco.data.bd_addr == bda)) {
       if (hci_status != HCI_SUCCESS) {
         /* Report the error if originator, otherwise remain in Listen mode */
         if (p->is_orig) {
@@ -726,15 +726,13 @@ void btm_sco_connected(uint8_t hci_status, const RawAddress* bda,
       p->state = SCO_ST_CONNECTED;
       p->hci_handle = hci_handle;
 
-      RawAddress bd_addr(*bda);
-
       if (hci_status == HCI_SUCCESS) {
-        BTM_LogHistory(kBtmLogTag, bd_addr, "Connection success",
+        BTM_LogHistory(kBtmLogTag, bda, "Connection success",
                        base::StringPrintf("handle:0x%04x %s", hci_handle,
                                           (spt) ? "listener" : "initiator"));
       } else {
         BTM_LogHistory(
-            kBtmLogTag, bd_addr, "Connection failed",
+            kBtmLogTag, bda, "Connection failed",
             base::StringPrintf(
                 "reason:%s",
                 hci_reason_code_text(static_cast<tHCI_REASON>(hci_status))
index d06bf26..9d2aff6 100644 (file)
@@ -962,7 +962,7 @@ static void btu_hcif_connection_comp_evt(uint8_t* p, uint8_t evt_len) {
     memset(&esco_data, 0, sizeof(tBTM_ESCO_DATA));
     /* esco_data.link_type = HCI_LINK_TYPE_SCO; already zero */
     esco_data.bd_addr = bda;
-    btm_sco_connected(status, &bda, handle, &esco_data);
+    btm_sco_connected(status, bda, handle, &esco_data);
   }
 }
 
@@ -1178,7 +1178,7 @@ static void btu_hcif_esco_connection_comp_evt(uint8_t* p) {
   handle = HCID_GET_HANDLE(handle);
 
   data.bd_addr = bda;
-  btm_sco_connected(status, &bda, handle, &data);
+  btm_sco_connected(status, bda, handle, &data);
 }
 
 /*******************************************************************************
@@ -1437,8 +1437,6 @@ static void btu_hcif_hdl_command_status(uint16_t opcode, uint8_t status,
         // Determine if initial connection failed or is a change of setup
         if (btm_is_sco_active(handle)) {
           btm_esco_proc_conn_chg(status, handle, 0, 0, 0, 0);
-        } else {
-          btm_sco_connected(status, nullptr, handle, nullptr);
         }
       }
       break;
index 065651d..f43c5dc 100644 (file)
@@ -32,7 +32,7 @@ extern void btm_sco_chk_pend_unpark(tHCI_STATUS hci_status,
                                     uint16_t hci_handle);
 extern void btm_sco_conn_req(const RawAddress& bda, DEV_CLASS dev_class,
                              uint8_t link_type);
-extern void btm_sco_connected(uint8_t hci_status, const RawAddress* bda,
+extern void btm_sco_connected(uint8_t hci_status, const RawAddress& bda,
                               uint16_t hci_handle, tBTM_ESCO_DATA* p_esco_data);
 extern bool btm_sco_removed(uint16_t hci_handle, tHCI_REASON reason);