diff options
| author | Furkan Sahin <furkan-dev@proton.me> | 2025-01-07 13:21:56 +0100 |
|---|---|---|
| committer | Furkan Sahin <furkan-dev@proton.me> | 2025-01-07 13:21:56 +0100 |
| commit | 86d128b708d76a76587d4ce796b567ba4be36e66 (patch) | |
| tree | b5691def14719b8f49af16d35b29494b6ab35667 /swaybar/tray/watcher.c | |
| parent | 459f8dc51ab25e823390e15cbf1c3718b4239aa3 (diff) | |
Use has_prefix() instead of strncmp() throughout
This is safer than hardcoded string lengths.
Diffstat (limited to 'swaybar/tray/watcher.c')
| -rw-r--r-- | swaybar/tray/watcher.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/swaybar/tray/watcher.c b/swaybar/tray/watcher.c index 54f000bd..28496403 100644 --- a/swaybar/tray/watcher.c +++ b/swaybar/tray/watcher.c @@ -31,9 +31,9 @@ static int handle_lost_service(sd_bus_message *msg, struct swaybar_watcher *watcher = data; for (int idx = 0; idx < watcher->items->length; ++idx) { char *id = watcher->items->items[idx]; - int cmp_res = using_standard_protocol(watcher) ? - cmp_id(id, service) : strncmp(id, service, strlen(service)); - if (cmp_res == 0) { + bool cmp_res = using_standard_protocol(watcher) ? + cmp_id(id, service) == 0 : has_prefix(id, service); + if (cmp_res) { sway_log(SWAY_DEBUG, "Unregistering Status Notifier Item '%s'", id); list_del(watcher->items, idx--); sd_bus_emit_signal(watcher->bus, obj_path, watcher->interface, |
