aboutsummaryrefslogtreecommitdiff
path: root/swaybar/tray/watcher.c
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2023-02-28 16:43:05 +0100
committerSimon Ser <contact@emersion.fr>2023-04-14 18:34:54 +0200
commit08c1946d71039e583696842c3558b337aede1cbf (patch)
tree3873db2edfb31146bd6cd17dae63f068aef34f05 /swaybar/tray/watcher.c
parentac8962eb626a8c715241ae91646f2d1bfcb61533 (diff)
Use format_str() throughout
Diffstat (limited to 'swaybar/tray/watcher.c')
-rw-r--r--swaybar/tray/watcher.c9
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 @@
#include <string.h>
#include "list.h"
#include "log.h"
+#include "stringop.h"
#include "swaybar/tray/watcher.h"
static const char *obj_path = "/StatusNotifierWatcher";
@@ -76,9 +77,7 @@ static int register_sni(sd_bus_message *msg, void *data, sd_bus_error *error) {
service = service_or_path;
path = "/StatusNotifierItem";
}
- size_t id_len = snprintf(NULL, 0, "%s%s", service, path) + 1;
- id = malloc(id_len);
- snprintf(id, id_len, "%s%s", service, path);
+ id = format_str("%s%s", service, path);
}
if (list_seq_find(watcher->items, cmp_id, id) == -1) {
@@ -159,9 +158,7 @@ struct swaybar_watcher *create_watcher(char *protocol, sd_bus *bus) {
return NULL;
}
- size_t len = snprintf(NULL, 0, "org.%s.StatusNotifierWatcher", protocol) + 1;
- watcher->interface = malloc(len);
- snprintf(watcher->interface, len, "org.%s.StatusNotifierWatcher", protocol);
+ watcher->interface = format_str("org.%s.StatusNotifierWatcher", protocol);
sd_bus_slot *signal_slot = NULL, *vtable_slot = NULL;
int ret = sd_bus_add_object_vtable(bus, &vtable_slot, obj_path,