This fixes the queue look up when checking for hci controllers.
---
mesh/mesh-mgmt.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/mesh/mesh-mgmt.c b/mesh/mesh-mgmt.c
index 27272d4d2..a2881dc37 100644
--- a/mesh/mesh-mgmt.c
+++ b/mesh/mesh-mgmt.c
@@ -45,9 +45,18 @@ static struct mgmt *mgmt_mesh;
static struct l_queue *controllers;
static struct l_queue *read_info_regs;
-static bool simple_match(const void *a, const void *b)
+static bool index_present(uint16_t index)
{
- return a == b;
+ const struct l_queue_entry *l = l_queue_get_entries(controllers);
+
+ for (; l; l = l->next) {
+ uint16_t idx = (uint16_t) L_PTR_TO_UINT(l->data);
+
+ if (idx == index)
+ return true;
+ }
+
+ return false;
}
static void process_read_info_req(void *data, void *user_data)
@@ -101,7 +110,7 @@ static void read_info_cb(uint8_t status, uint16_t length,
static void index_added(uint16_t index, uint16_t length, const void *param,
void *user_data)
{
- if (l_queue_find(controllers, simple_match, L_UINT_TO_PTR(index)))
+ if (index_present(index))
return;
l_queue_push_tail(controllers, L_UINT_TO_PTR(index));
--
2.21.0