You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/07/13 20:55:49 UTC

[36/50] [abbrv] incubator-mynewt-core git commit: BLE Host - Fix for spurious gcc warning.

BLE Host - Fix for spurious gcc warning.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/77b9d5ea
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/77b9d5ea
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/77b9d5ea

Branch: refs/heads/develop
Commit: 77b9d5ea0f75a77e9275d68a06aa9d710fe1560b
Parents: 3714aea
Author: Christopher Collins <cc...@apache.org>
Authored: Sat Jul 9 13:23:58 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Mon Jul 11 16:43:35 2016 -0700

----------------------------------------------------------------------
 net/nimble/host/src/host_hci.c | 62 ++++++++++++++++++++++---------------
 1 file changed, 37 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/77b9d5ea/net/nimble/host/src/host_hci.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/host_hci.c b/net/nimble/host/src/host_hci.c
index b7b1bd1..5251231 100644
--- a/net/nimble/host/src/host_hci.c
+++ b/net/nimble/host/src/host_hci.c
@@ -698,47 +698,59 @@ host_hci_data_rx(struct os_mbuf *om)
     int rc;
 
     rc = ble_hci_util_data_hdr_strip(om, &hci_hdr);
-    if (rc == 0) {
+    if (rc != 0) {
+        goto err;
+    }
+
 #if (BLETEST_THROUGHPUT_TEST == 0)
-        BLE_HS_LOG(DEBUG, "host_hci_data_rx(): handle=%u pb=%x len=%u data=",
-                   BLE_HCI_DATA_HANDLE(hci_hdr.hdh_handle_pb_bc), 
-                   BLE_HCI_DATA_PB(hci_hdr.hdh_handle_pb_bc), 
-                   hci_hdr.hdh_len);
-        ble_hs_misc_log_mbuf(om);
-        BLE_HS_LOG(DEBUG, "\n");
+    BLE_HS_LOG(DEBUG, "host_hci_data_rx(): handle=%u pb=%x len=%u data=",
+               BLE_HCI_DATA_HANDLE(hci_hdr.hdh_handle_pb_bc), 
+               BLE_HCI_DATA_PB(hci_hdr.hdh_handle_pb_bc), 
+               hci_hdr.hdh_len);
+    ble_hs_misc_log_mbuf(om);
+    BLE_HS_LOG(DEBUG, "\n");
 #endif
 
-        if (hci_hdr.hdh_len != OS_MBUF_PKTHDR(om)->omp_len) {
-            rc = BLE_HS_EBADDATA;
-        } else {
-            handle = BLE_HCI_DATA_HANDLE(hci_hdr.hdh_handle_pb_bc);
+    if (hci_hdr.hdh_len != OS_MBUF_PKTHDR(om)->omp_len) {
+        rc = BLE_HS_EBADDATA;
+        goto err;
+    }
 
-            ble_hs_lock();
+    handle = BLE_HCI_DATA_HANDLE(hci_hdr.hdh_handle_pb_bc);
 
-            conn = ble_hs_conn_find(handle);
-            if (conn == NULL) {
-                rc = BLE_HS_ENOTCONN;
-            } else {
-                rc = ble_l2cap_rx(conn, &hci_hdr, om, &rx_cb, &rx_buf);
-                om = NULL;
-            }
+    ble_hs_lock();
 
-            ble_hs_unlock();
-        }
+    conn = ble_hs_conn_find(handle);
+    if (conn == NULL) {
+        rc = BLE_HS_ENOTCONN;
+    } else {
+        rc = ble_l2cap_rx(conn, &hci_hdr, om, &rx_cb, &rx_buf);
+        om = NULL;
     }
 
-    os_mbuf_free_chain(om);
+    ble_hs_unlock();
 
-    if (rc == 0) {
+    switch (rc) {
+    case 0:
+        /* Final fragment received. */
         BLE_HS_DBG_ASSERT(rx_cb != NULL);
         BLE_HS_DBG_ASSERT(rx_buf != NULL);
         rc = rx_cb(handle, &rx_buf);
         os_mbuf_free_chain(rx_buf);
-    } else if (rc == BLE_HS_EAGAIN) {
+        break;
+
+    case BLE_HS_EAGAIN:
         /* More fragments on the way. */
-        rc = 0;
+        break;
+
+    default:
+        goto err;
     }
 
+    return 0;
+
+err:
+    os_mbuf_free_chain(om);
     return rc;
 }