From 9c16dfcc150d8876e0ebe2e4168690b837618c13 Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Thu, 5 Mar 2015 14:55:21 +0100 Subject: [PATCH] shared/att: Refactor loop in handle_notify Use 'while' instead of 'for' loop for better code readability. --- src/shared/att.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/shared/att.c b/src/shared/att.c index 55d633be7..7671d676f 100644 --- a/src/shared/att.c +++ b/src/shared/att.c @@ -751,8 +751,10 @@ static void handle_notify(struct bt_att *att, uint8_t opcode, uint8_t *pdu, bt_att_ref(att); - for (found = false, entry = queue_get_entries(att->notify_list); - !queue_isempty(att->notify_list) && entry;) { + found = false; + entry = queue_get_entries(att->notify_list); + + while (entry) { struct att_notify *notify = entry->data; entry = entry->next; @@ -765,6 +767,10 @@ static void handle_notify(struct bt_att *att, uint8_t opcode, uint8_t *pdu, if (notify->callback) notify->callback(opcode, pdu, pdu_len, notify->user_data); + + /* callback could remove all entries from notify list */ + if (queue_isempty(att->notify_list)) + break; } /* -- 2.47.3