From f87c9bb9f70f1a6c8c7081c762c15ba7eaaf971e Mon Sep 17 00:00:00 2001 From: Craig Barnes Date: Sat, 3 Aug 2024 08:12:13 +0100 Subject: xmalloc: remove delim param from xstrjoin() and add separate xstrjoin3() This avoids the need for an unused third argument for most xstrjoin() calls and replaces the cases where it's needed with a more flexible function. Code generation is the same in both cases, when there are 2 string params and a compile-time known delimiter. This commit also converts 4 uses of xasprintf() to use xstrjoin*(). See also: https://godbolt.org/z/xsjrhv9b6 --- slave.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'slave.c') diff --git a/slave.c b/slave.c index 00105adb..bf1ca8e0 100644 --- a/slave.c +++ b/slave.c @@ -55,7 +55,7 @@ find_file_in_path(const char *file) path != NULL; path = strtok(NULL, ":")) { - char *full = xasprintf("%s/%s", path, file); + char *full = xstrjoin3(path, "/", file); if (access(full, F_OK) == 0) { free(path_list); return full; @@ -329,7 +329,7 @@ add_to_env(struct environ *env, const char *name, const char *value) if (env->envp == NULL) setenv(name, value, 1); else { - char *e = xasprintf("%s=%s", name, value); + char *e = xstrjoin3(name, "=", value); /* Search for existing variable. If found, replace it with the new value */ -- cgit v1.3 From 7e1894978fda263f823abbb1e66ea251e96bfd83 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Fri, 9 Aug 2024 13:55:21 +0200 Subject: slave: prefix user notifications with 'foot' To make it clearer _who_ is emitting the warning/errors --- slave.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'slave.c') diff --git a/slave.c b/slave.c index bf1ca8e0..47e59e87 100644 --- a/slave.c +++ b/slave.c @@ -158,6 +158,7 @@ emit_one_notification(int fd, const struct user_notification *notif) xassert(prefix != NULL); if (write(fd, prefix, strlen(prefix)) < 0 || + write(fd, "foot: ", 6) < 0 || write(fd, notif->text, strlen(notif->text)) < 0 || write(fd, postfix, strlen(postfix)) < 0) { @@ -180,7 +181,8 @@ emit_one_notification(int fd, const struct user_notification *notif) } static bool -emit_notifications_of_kind(int fd, const user_notifications_t *notifications, +emit_notifications_of_kind(int fd, + const user_notifications_t *notifications, enum user_notification_kind kind) { tll_foreach(*notifications, it) { -- cgit v1.3