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/05/20 03:31:28 UTC

[2/3] incubator-mynewt-core git commit: BLE Host - (dbg) Assert proc entries not in list.

BLE Host - (dbg) Assert proc entries not in list.

When BLE_HS_DEBUG is defined, assert that an l2cap_sig proc entry is not
in the list before freeing or inserting it.


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/8a315f46
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/8a315f46
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/8a315f46

Branch: refs/heads/develop
Commit: 8a315f46393aa534d97f0b2595b7e85cc0227157
Parents: 52e7b2f
Author: Christopher Collins <cc...@apache.org>
Authored: Thu May 19 16:26:07 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Thu May 19 20:31:22 2016 -0700

----------------------------------------------------------------------
 net/nimble/host/src/ble_l2cap_sig.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8a315f46/net/nimble/host/src/ble_l2cap_sig.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_l2cap_sig.c b/net/nimble/host/src/ble_l2cap_sig.c
index ddb69e7..647b4cb 100644
--- a/net/nimble/host/src/ble_l2cap_sig.c
+++ b/net/nimble/host/src/ble_l2cap_sig.c
@@ -106,6 +106,22 @@ static void *ble_l2cap_sig_proc_mem;
 static struct os_mempool ble_l2cap_sig_proc_pool;
 
 /*****************************************************************************
+ * $debug                                                                    *
+ *****************************************************************************/
+
+static void
+ble_l2cap_sig_dbg_assert_proc_not_inserted(struct ble_l2cap_sig_proc *proc)
+{
+#if BLE_HS_DEBUG
+    struct ble_l2cap_sig_proc *cur;
+
+    STAILQ_FOREACH(cur, &ble_l2cap_sig_procs, next) {
+        BLE_HS_DBG_ASSERT(cur != proc);
+    }
+#endif
+}
+
+/*****************************************************************************
  * $misc                                                                     *
  *****************************************************************************/
 
@@ -158,6 +174,8 @@ ble_l2cap_sig_proc_free(struct ble_l2cap_sig_proc *proc)
     int rc;
 
     if (proc != NULL) {
+        ble_l2cap_sig_dbg_assert_proc_not_inserted(proc);
+
         rc = os_memblock_put(&ble_l2cap_sig_proc_pool, proc);
         BLE_HS_DBG_ASSERT_EVAL(rc == 0);
     }
@@ -166,6 +184,8 @@ ble_l2cap_sig_proc_free(struct ble_l2cap_sig_proc *proc)
 static void
 ble_l2cap_sig_proc_insert(struct ble_l2cap_sig_proc *proc)
 {
+    ble_l2cap_sig_dbg_assert_proc_not_inserted(proc);
+
     BLE_HS_DBG_ASSERT(ble_hs_thread_safe());
     STAILQ_INSERT_HEAD(&ble_l2cap_sig_procs, proc, next);
 }