eiwd

no dbus iwd with iwctl functionality
git clone https://git.daat.foo/repos/eiwd.git
Log | Files | Refs | Submodules | README | LICENSE

commit 1e10d136459d991bbcd1cd306147fddd9b0bf4a5
parent d012a7f2ac3b494c458f9a50ad0ac001f4095475
Author: Andrew Zaborowski <andrew.zaborowski@intel.com>
Date:   Sun, 31 May 2020 02:56:45 +0200

frame-xchg: Use frame_watch_group_match in frame_watch_group_get

Diffstat:
Msrc/frame-xchg.c | 42+++++++++++++++++++-----------------------
1 file changed, 19 insertions(+), 23 deletions(-)

diff --git a/src/frame-xchg.c b/src/frame-xchg.c @@ -439,21 +439,30 @@ err: return NULL; } -static struct watch_group *frame_watch_group_get(uint64_t wdev_id, uint32_t id) +struct watch_group_match_info { + uint64_t wdev_id; + uint32_t id; +}; + +static bool frame_watch_group_match(const void *a, const void *b) { - const struct l_queue_entry *entry; - struct watch_group *group; + const struct watch_group *group = a; + const struct watch_group_match_info *info = b; - for (entry = l_queue_get_entries(watch_groups); entry; - entry = entry->next) { - group = entry->data; + return group->wdev_id == info->wdev_id && group->id == info->id; +} - if (group->id == id && (id == 0 || group->wdev_id == wdev_id)) - return group; +static struct watch_group *frame_watch_group_get(uint64_t wdev_id, uint32_t id) +{ + struct watch_group_match_info info = { id == 0 ? 0 : wdev_id, id }; + struct watch_group *group = l_queue_find(watch_groups, + frame_watch_group_match, &info); + + if (!group) { + group = frame_watch_group_new(wdev_id, id); + l_queue_push_tail(watch_groups, group); } - group = frame_watch_group_new(wdev_id, id); - l_queue_push_tail(watch_groups, group); return group; } @@ -590,19 +599,6 @@ bool frame_watch_add(uint64_t wdev_id, uint32_t group_id, uint16_t frame_type, return true; } -struct watch_group_match_info { - uint64_t wdev_id; - uint32_t id; -}; - -static bool frame_watch_group_match(const void *a, const void *b) -{ - const struct watch_group *group = a; - const struct watch_group_match_info *info = b; - - return group->wdev_id == info->wdev_id && group->id == info->id; -} - bool frame_watch_group_remove(uint64_t wdev_id, uint32_t group_id) { struct watch_group_match_info info = { wdev_id, group_id };