diff options
Diffstat (limited to 'swaybar/tray/watcher.c')
-rw-r--r-- | swaybar/tray/watcher.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/swaybar/tray/watcher.c b/swaybar/tray/watcher.c index 16afc27c..551e1d12 100644 --- a/swaybar/tray/watcher.c +++ b/swaybar/tray/watcher.c | |||
@@ -6,6 +6,7 @@ | |||
6 | #include <string.h> | 6 | #include <string.h> |
7 | #include "list.h" | 7 | #include "list.h" |
8 | #include "log.h" | 8 | #include "log.h" |
9 | #include "stringop.h" | ||
9 | #include "swaybar/tray/watcher.h" | 10 | #include "swaybar/tray/watcher.h" |
10 | 11 | ||
11 | static const char *obj_path = "/StatusNotifierWatcher"; | 12 | static const char *obj_path = "/StatusNotifierWatcher"; |
@@ -76,9 +77,7 @@ static int register_sni(sd_bus_message *msg, void *data, sd_bus_error *error) { | |||
76 | service = service_or_path; | 77 | service = service_or_path; |
77 | path = "/StatusNotifierItem"; | 78 | path = "/StatusNotifierItem"; |
78 | } | 79 | } |
79 | size_t id_len = snprintf(NULL, 0, "%s%s", service, path) + 1; | 80 | id = format_str("%s%s", service, path); |
80 | id = malloc(id_len); | ||
81 | snprintf(id, id_len, "%s%s", service, path); | ||
82 | } | 81 | } |
83 | 82 | ||
84 | if (list_seq_find(watcher->items, cmp_id, id) == -1) { | 83 | if (list_seq_find(watcher->items, cmp_id, id) == -1) { |
@@ -159,9 +158,7 @@ struct swaybar_watcher *create_watcher(char *protocol, sd_bus *bus) { | |||
159 | return NULL; | 158 | return NULL; |
160 | } | 159 | } |
161 | 160 | ||
162 | size_t len = snprintf(NULL, 0, "org.%s.StatusNotifierWatcher", protocol) + 1; | 161 | watcher->interface = format_str("org.%s.StatusNotifierWatcher", protocol); |
163 | watcher->interface = malloc(len); | ||
164 | snprintf(watcher->interface, len, "org.%s.StatusNotifierWatcher", protocol); | ||
165 | 162 | ||
166 | sd_bus_slot *signal_slot = NULL, *vtable_slot = NULL; | 163 | sd_bus_slot *signal_slot = NULL, *vtable_slot = NULL; |
167 | int ret = sd_bus_add_object_vtable(bus, &vtable_slot, obj_path, | 164 | int ret = sd_bus_add_object_vtable(bus, &vtable_slot, obj_path, |