mirror of
https://github.com/swaywm/sway.git
synced 2025-10-31 22:25:26 -04:00
Use has_prefix() instead of strncmp() throughout
This is safer than hardcoded string lengths.
This commit is contained in:
parent
c55dff95bc
commit
0c60d1581f
19 changed files with 44 additions and 49 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue