chiark / gitweb /
util: rework strappenda(), and rename it strjoina()
authorLennart Poettering <lennart@poettering.net>
Tue, 3 Feb 2015 01:05:59 +0000 (02:05 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 3 Feb 2015 01:05:59 +0000 (02:05 +0100)
After all it is now much more like strjoin() than strappend(). At the
same time, add support for NULL sentinels, even if they are normally not
necessary.

75 files changed:
src/cgls/cgls.c
src/core/busname.c
src/core/dbus-cgroup.c
src/core/execute.c
src/core/machine-id-setup.c
src/core/manager.c
src/core/mount.c
src/core/namespace.c
src/core/service.c
src/core/socket.c
src/core/swap.c
src/core/unit.c
src/cryptsetup/cryptsetup-generator.c
src/cryptsetup/cryptsetup.c
src/dbus1-generator/dbus1-generator.c
src/efi-boot-generator/efi-boot-generator.c
src/firstboot/firstboot.c
src/fstab-generator/fstab-generator.c
src/getty-generator/getty-generator.c
src/gpt-auto-generator/gpt-auto-generator.c
src/import/curl-util.c
src/import/import-common.c
src/import/import-dkr.c
src/import/import-raw.c
src/journal-remote/journal-remote.c
src/journal-remote/microhttpd-util.c
src/journal/coredump.c
src/journal/journalctl.c
src/journal/journald-server.c
src/journal/journald-syslog.c
src/journal/sd-journal.c
src/libsystemd-terminal/idev-keyboard.c
src/libsystemd/sd-bus/bus-control.c
src/libsystemd/sd-bus/bus-dump.c
src/libsystemd/sd-bus/busctl.c
src/libsystemd/sd-bus/sd-bus.c
src/libsystemd/sd-login/sd-login.c
src/libudev/libudev-device.c
src/locale/localed.c
src/login/logind-button.c
src/login/logind-dbus.c
src/login/logind-user.c
src/machine/machine.c
src/machine/machinectl.c
src/network/networkd-link.c
src/nspawn/nspawn.c
src/resolve/resolved-bus.c
src/run/run.c
src/shared/cgroup-show.c
src/shared/cgroup-util.c
src/shared/condition.c
src/shared/conf-files.c
src/shared/generator.c
src/shared/install.c
src/shared/logs-show.c
src/shared/machine-image.c
src/shared/pager.c
src/shared/path-util.c
src/shared/switch-root.c
src/shared/time-util.c
src/shared/util.c
src/shared/util.h
src/system-update-generator/system-update-generator.c
src/systemctl/systemctl.c
src/sysusers/sysusers.c
src/test/test-conf-files.c
src/test/test-copy.c
src/test/test-namespace.c
src/test/test-path-lookup.c
src/test/test-path.c
src/test/test-tmpfiles.c
src/test/test-util.c
src/tty-ask-password-agent/tty-ask-password-agent.c
src/udev/udev-builtin-net_id.c
src/udev/udevadm-util.c

index f400bcc..579e06d 100644 (file)
@@ -203,7 +203,7 @@ int main(int argc, char *argv[]) {
                                 _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
                                 _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
 
-                                m = strappenda("/run/systemd/machines/", arg_machine);
+                                m = strjoina("/run/systemd/machines/", arg_machine);
                                 r = parse_env_file(m, NEWLINE, "SCOPE", &scope, NULL);
                                 if (r < 0) {
                                         log_error_errno(r, "Failed to get machine path: %m");
index ca9ceb8..bc3a2bc 100644 (file)
@@ -205,7 +205,7 @@ static int busname_verify(BusName *n) {
                 return -EINVAL;
         }
 
-        e = strappenda(n->name, ".busname");
+        e = strjoina(n->name, ".busname");
         if (!unit_has_name(UNIT(n), e)) {
                 log_unit_error(UNIT(n)->id, "%s's Name= setting doesn't match unit name. Refusing.", UNIT(n)->id);
                 return -EINVAL;
index db99834..4a9df06 100644 (file)
@@ -574,7 +574,7 @@ int bus_cgroup_set_property(
                         c->device_policy = p;
                         u->cgroup_realized_mask &= ~CGROUP_DEVICE;
 
-                        buf = strappenda("DevicePolicy=", policy);
+                        buf = strjoina("DevicePolicy=", policy);
                         unit_write_drop_in_private(u, mode, name, buf);
                 }
 
index 19d3ec0..874cdc7 100644 (file)
@@ -1582,9 +1582,9 @@ static int exec_child(
 
                 if (context->private_tmp && runtime) {
                         if (runtime->tmp_dir)
-                                tmp = strappenda(runtime->tmp_dir, "/tmp");
+                                tmp = strjoina(runtime->tmp_dir, "/tmp");
                         if (runtime->var_tmp_dir)
-                                var = strappenda(runtime->var_tmp_dir, "/tmp");
+                                var = strjoina(runtime->var_tmp_dir, "/tmp");
                 }
 
                 r = setup_namespace(
@@ -2588,7 +2588,7 @@ void exec_command_dump(ExecCommand *c, FILE *f, const char *prefix) {
         assert(f);
 
         prefix = strempty(prefix);
-        prefix2 = strappenda(prefix, "\t");
+        prefix2 = strjoina(prefix, "\t");
 
         cmd = exec_command_line(c->argv);
         fprintf(f,
index 7e0aee6..d00a532 100644 (file)
@@ -73,7 +73,7 @@ static int generate(char id[34], const char *root) {
         if (isempty(root))
                 dbus_machine_id = "/var/lib/dbus/machine-id";
         else
-                dbus_machine_id = strappenda(root, "/var/lib/dbus/machine-id");
+                dbus_machine_id = strjoina(root, "/var/lib/dbus/machine-id");
 
         /* First, try reading the D-Bus machine id, unless it is a symlink */
         fd = open(dbus_machine_id, O_RDONLY|O_CLOEXEC|O_NOCTTY|O_NOFOLLOW);
@@ -199,7 +199,7 @@ int machine_id_commit(const char *root) {
         else {
                 char *x;
 
-                x = strappenda(root, "/etc/machine-id");
+                x = strjoina(root, "/etc/machine-id");
                 etc_machine_id = path_kill_slashes(x);
         }
 
@@ -281,10 +281,10 @@ int machine_id_setup(const char *root) {
         } else {
                 char *x;
 
-                x = strappenda(root, "/etc/machine-id");
+                x = strjoina(root, "/etc/machine-id");
                 etc_machine_id = path_kill_slashes(x);
 
-                x = strappenda(root, "/run/machine-id");
+                x = strjoina(root, "/run/machine-id");
                 run_machine_id = path_kill_slashes(x);
         }
 
index 0b24cdd..5fba004 100644 (file)
@@ -2106,8 +2106,7 @@ void manager_send_unit_audit(Manager *m, Unit *u, int type, bool success) {
                 return;
         }
 
-        msg = strappenda("unit=", p);
-
+        msg = strjoina("unit=", p);
         if (audit_log_user_comm_message(audit_fd, type, msg, "systemd", NULL, NULL, NULL, success) < 0) {
                 if (errno == EPERM)
                         /* We aren't allowed to send audit messages?
index a0b5fda..f3977e6 100644 (file)
@@ -976,7 +976,7 @@ static void mount_enter_remounting(Mount *m) {
                 const char *o;
 
                 if (m->parameters_fragment.options)
-                        o = strappenda("remount,", m->parameters_fragment.options);
+                        o = strjoina("remount,", m->parameters_fragment.options);
                 else
                         o = "remount";
 
index 4b8dbdd..4fecd32 100644 (file)
@@ -157,24 +157,24 @@ static int mount_dev(BindMount *m) {
         if (!mkdtemp(temporary_mount))
                 return -errno;
 
-        dev = strappenda(temporary_mount, "/dev");
+        dev = strjoina(temporary_mount, "/dev");
         (void)mkdir(dev, 0755);
         if (mount("tmpfs", dev, "tmpfs", MS_NOSUID|MS_STRICTATIME, "mode=755") < 0) {
                 r = -errno;
                 goto fail;
         }
 
-        devpts = strappenda(temporary_mount, "/dev/pts");
+        devpts = strjoina(temporary_mount, "/dev/pts");
         (void)mkdir(devpts, 0755);
         if (mount("/dev/pts", devpts, NULL, MS_BIND, NULL) < 0) {
                 r = -errno;
                 goto fail;
         }
 
-        devptmx = strappenda(temporary_mount, "/dev/ptmx");
+        devptmx = strjoina(temporary_mount, "/dev/ptmx");
         symlink("pts/ptmx", devptmx);
 
-        devshm = strappenda(temporary_mount, "/dev/shm");
+        devshm = strjoina(temporary_mount, "/dev/shm");
         (void)mkdir(devshm, 01777);
         r = mount("/dev/shm", devshm, NULL, MS_BIND, NULL);
         if (r < 0) {
@@ -182,15 +182,15 @@ static int mount_dev(BindMount *m) {
                 goto fail;
         }
 
-        devmqueue = strappenda(temporary_mount, "/dev/mqueue");
+        devmqueue = strjoina(temporary_mount, "/dev/mqueue");
         (void)mkdir(devmqueue, 0755);
         mount("/dev/mqueue", devmqueue, NULL, MS_BIND, NULL);
 
-        devhugepages = strappenda(temporary_mount, "/dev/hugepages");
+        devhugepages = strjoina(temporary_mount, "/dev/hugepages");
         (void)mkdir(devhugepages, 0755);
         mount("/dev/hugepages", devhugepages, NULL, MS_BIND, NULL);
 
-        devlog = strappenda(temporary_mount, "/dev/log");
+        devlog = strjoina(temporary_mount, "/dev/log");
         symlink("/run/systemd/journal/dev-log", devlog);
 
         NULSTR_FOREACH(d, devnodes) {
@@ -280,7 +280,7 @@ static int mount_kdbus(BindMount *m) {
         if (!mkdtemp(temporary_mount))
                 return log_error_errno(errno, "Failed create temp dir: %m");
 
-        root = strappenda(temporary_mount, "/kdbus");
+        root = strjoina(temporary_mount, "/kdbus");
         (void)mkdir(root, 0755);
         if (mount("tmpfs", root, "tmpfs", MS_NOSUID|MS_STRICTATIME, "mode=777") < 0) {
                 r = -errno;
@@ -295,7 +295,7 @@ static int mount_kdbus(BindMount *m) {
                 goto fail;
         }
 
-        busnode = strappenda(root, "/bus");
+        busnode = strjoina(root, "/bus");
         if (mknod(busnode, (st.st_mode & ~07777) | 0600, st.st_rdev) < 0) {
                 log_error_errno(errno, "mknod() for %s failed: %m", busnode);
                 r = -errno;
@@ -566,7 +566,7 @@ static int setup_one_tmp_dir(const char *id, const char *prefix, char **path) {
         RUN_WITH_UMASK(0000) {
                 char *y;
 
-                y = strappenda(x, "/tmp");
+                y = strjoina(x, "/tmp");
 
                 if (mkdir(y, 0777 | S_ISVTX) < 0)
                         return -errno;
@@ -594,7 +594,7 @@ int setup_tmp_dirs(const char *id, char **tmp_dir, char **var_tmp_dir) {
         if (r < 0) {
                 char *t;
 
-                t = strappenda(a, "/tmp");
+                t = strjoina(a, "/tmp");
                 rmdir(t);
                 rmdir(a);
 
index 15a2ed7..15e29be 100644 (file)
@@ -562,7 +562,7 @@ static int service_add_extras(Service *s) {
                 if (r < 0)
                         return r;
 
-                n = strappenda(s->bus_name, ".busname");
+                n = strjoina(s->bus_name, ".busname");
                 r = unit_add_dependency_by_name(UNIT(s), UNIT_AFTER, n, NULL, true);
                 if (r < 0)
                         return r;
@@ -619,7 +619,7 @@ static void service_dump(Unit *u, FILE *f, const char *prefix) {
         assert(s);
 
         prefix = strempty(prefix);
-        prefix2 = strappenda(prefix, "\t");
+        prefix2 = strjoina(prefix, "\t");
 
         fprintf(f,
                 "%sService State: %s\n"
@@ -1123,7 +1123,7 @@ static int service_spawn(
         }
 
         if (is_control && UNIT(s)->cgroup_path) {
-                path = strappenda(UNIT(s)->cgroup_path, "/control");
+                path = strjoina(UNIT(s)->cgroup_path, "/control");
                 cg_create(SYSTEMD_CGROUP_CONTROLLER, path);
         } else
                 path = UNIT(s)->cgroup_path;
@@ -1489,7 +1489,7 @@ static void service_kill_control_processes(Service *s) {
         if (!UNIT(s)->cgroup_path)
                 return;
 
-        p = strappenda(UNIT(s)->cgroup_path, "/control");
+        p = strjoina(UNIT(s)->cgroup_path, "/control");
         cg_kill_recursive(SYSTEMD_CGROUP_CONTROLLER, p, SIGKILL, true, true, true, NULL);
 }
 
index 85f7f16..d3dabc8 100644 (file)
@@ -266,7 +266,7 @@ static int socket_add_device_link(Socket *s) {
         if (!s->bind_to_device || streq(s->bind_to_device, "lo"))
                 return 0;
 
-        t = strappenda("/sys/subsystem/net/devices/", s->bind_to_device);
+        t = strjoina("/sys/subsystem/net/devices/", s->bind_to_device);
         return unit_add_node_link(UNIT(s), t, false);
 }
 
@@ -473,7 +473,7 @@ static void socket_dump(Unit *u, FILE *f, const char *prefix) {
         assert(f);
 
         prefix = strempty(prefix);
-        prefix2 = strappenda(prefix, "\t");
+        prefix2 = strjoina(prefix, "\t");
 
         fprintf(f,
                 "%sSocket State: %s\n"
index 4fbabda..6997921 100644 (file)
@@ -749,7 +749,7 @@ static void swap_enter_activating(Swap *s) {
                 if (streq(discard, "all"))
                         discard_arg = "--discard";
                 else
-                        discard_arg = strappenda("--discard=", discard);
+                        discard_arg = strjoina("--discard=", discard);
 
                 r = exec_command_append(s->control_command, discard_arg, NULL);
                 if (r < 0)
index c3433b2..2f95737 100644 (file)
@@ -868,7 +868,7 @@ void unit_dump(Unit *u, FILE *f, const char *prefix) {
         assert(u->type >= 0);
 
         prefix = strempty(prefix);
-        prefix2 = strappenda(prefix, "\t");
+        prefix2 = strjoina(prefix, "\t");
 
         fprintf(f,
                 "%s-> Unit %s:\n"
index 27b2360..05061c0 100644 (file)
@@ -183,7 +183,7 @@ static int create_disk(
         if (ferror(f))
                 return log_error_errno(errno, "Failed to write file %s: %m", p);
 
-        from = strappenda("../", n);
+        from = strjoina("../", n);
 
         if (!noauto) {
 
index 26141a0..3f613d9 100644 (file)
@@ -295,7 +295,7 @@ static int get_password(const char *name, usec_t until, bool accept_cached, char
         if (!escaped_name)
                 return log_oom();
 
-        id = strappenda("cryptsetup:", escaped_name);
+        id = strjoina("cryptsetup:", escaped_name);
 
         r = ask_password_auto(text, "drive-harddisk", id, until, accept_cached, passwords);
         if (r < 0)
@@ -309,7 +309,7 @@ static int get_password(const char *name, usec_t until, bool accept_cached, char
                 if (asprintf(&text, "Please enter passphrase for disk %s! (verification)", name) < 0)
                         return log_oom();
 
-                id = strappenda("cryptsetup-verification:", escaped_name);
+                id = strjoina("cryptsetup-verification:", escaped_name);
 
                 r = ask_password_auto(text, "drive-harddisk", id, until, false, &passwords2);
                 if (r < 0)
index ca737e3..2e08af2 100644 (file)
@@ -164,7 +164,7 @@ static int add_dbus(const char *path, const char *fname, const char *type) {
         assert(path);
         assert(fname);
 
-        p = strappenda(path, "/", fname);
+        p = strjoina(path, "/", fname);
         r = config_parse(NULL, p, NULL,
                          "D-BUS Service\0",
                          config_item_table_lookup, table,
@@ -250,8 +250,8 @@ fail:
 static int link_busnames_target(const char *units) {
         const char *f, *t;
 
-        f = strappenda(units, "/" SPECIAL_BUSNAMES_TARGET);
-        t = strappenda(arg_dest, "/" SPECIAL_BASIC_TARGET ".wants/" SPECIAL_BUSNAMES_TARGET);
+        f = strjoina(units, "/" SPECIAL_BUSNAMES_TARGET);
+        t = strjoina(arg_dest, "/" SPECIAL_BASIC_TARGET ".wants/" SPECIAL_BUSNAMES_TARGET);
 
         mkdir_parents_label(t, 0755);
         if (symlink(f, t) < 0)
@@ -263,19 +263,19 @@ static int link_busnames_target(const char *units) {
 static int link_compatibility(const char *units) {
         const char *f, *t;
 
-        f = strappenda(units, "/systemd-bus-proxyd.socket");
-        t = strappenda(arg_dest, "/" SPECIAL_DBUS_SOCKET);
+        f = strjoina(units, "/systemd-bus-proxyd.socket");
+        t = strjoina(arg_dest, "/" SPECIAL_DBUS_SOCKET);
         mkdir_parents_label(t, 0755);
         if (symlink(f, t) < 0)
                 return log_error_errno(errno, "Failed to create symlink %s: %m", t);
 
-        f = strappenda(units, "/systemd-bus-proxyd.socket");
-        t = strappenda(arg_dest, "/" SPECIAL_SOCKETS_TARGET ".wants/systemd-bus-proxyd.socket");
+        f = strjoina(units, "/systemd-bus-proxyd.socket");
+        t = strjoina(arg_dest, "/" SPECIAL_SOCKETS_TARGET ".wants/systemd-bus-proxyd.socket");
         mkdir_parents_label(t, 0755);
         if (symlink(f, t) < 0)
                 return log_error_errno(errno, "Failed to create symlink %s: %m", t);
 
-        t = strappenda(arg_dest, "/" SPECIAL_DBUS_SERVICE);
+        t = strjoina(arg_dest, "/" SPECIAL_DBUS_SERVICE);
         if (symlink("/dev/null", t) < 0)
                 return log_error_errno(errno, "Failed to mask %s: %m", t);
 
index 99a819f..b3ff3a8 100644 (file)
@@ -84,7 +84,7 @@ int main(int argc, char *argv[]) {
                 return EXIT_FAILURE;
         }
 
-        name = strappenda(arg_dest, "/boot.mount");
+        name = strjoina(arg_dest, "/boot.mount");
         f = fopen(name, "wxe");
         if (!f) {
                 log_error_errno(errno, "Failed to create mount unit file %s: %m", name);
@@ -124,7 +124,7 @@ int main(int argc, char *argv[]) {
                 return EXIT_FAILURE;
         }
 
-        name = strappenda(arg_dest, "/boot.automount");
+        name = strjoina(arg_dest, "/boot.automount");
         fclose(f);
         f = fopen(name, "wxe");
         if (!f) {
@@ -144,7 +144,7 @@ int main(int argc, char *argv[]) {
                 return EXIT_FAILURE;
         }
 
-        name = strappenda(arg_dest, "/" SPECIAL_LOCAL_FS_TARGET ".wants/boot.automount");
+        name = strjoina(arg_dest, "/" SPECIAL_LOCAL_FS_TARGET ".wants/boot.automount");
         mkdir_parents(name, 0755);
 
         if (symlink("../boot.automount", name) < 0) {
index a160c52..a765d6d 100644 (file)
@@ -50,7 +50,7 @@ static bool arg_copy_locale = false;
 static bool arg_copy_timezone = false;
 static bool arg_copy_root_password = false;
 
-#define prefix_roota(p) (arg_root ? (const char*) strappenda(arg_root, p) : (const char*) p)
+#define prefix_roota(p) (arg_root ? (const char*) strjoina(arg_root, p) : (const char*) p)
 
 static void clear_string(char *x) {
 
@@ -271,9 +271,9 @@ static int process_locale(void) {
                 return r;
 
         if (!isempty(arg_locale))
-                locales[i++] = strappenda("LANG=", arg_locale);
+                locales[i++] = strjoina("LANG=", arg_locale);
         if (!isempty(arg_locale_messages) && !streq(arg_locale_messages, arg_locale))
-                locales[i++] = strappenda("LC_MESSAGES=", arg_locale_messages);
+                locales[i++] = strjoina("LC_MESSAGES=", arg_locale_messages);
 
         if (i == 0)
                 return 0;
@@ -351,7 +351,7 @@ static int process_timezone(void) {
         if (isempty(arg_timezone))
                 return 0;
 
-        e = strappenda("../usr/share/zoneinfo/", arg_timezone);
+        e = strjoina("../usr/share/zoneinfo/", arg_timezone);
 
         mkdir_parents(etc_localtime, 0755);
         if (symlink(e, etc_localtime) < 0)
@@ -460,8 +460,8 @@ static int prompt_root_password(void) {
         print_welcome();
         putchar('\n');
 
-        msg1 = strappenda(draw_special_char(DRAW_TRIANGULAR_BULLET), " Please enter a new root password (empty to skip): ");
-        msg2 = strappenda(draw_special_char(DRAW_TRIANGULAR_BULLET), " Please enter new root password again: ");
+        msg1 = strjoina(draw_special_char(DRAW_TRIANGULAR_BULLET), " Please enter a new root password (empty to skip): ");
+        msg2 = strjoina(draw_special_char(DRAW_TRIANGULAR_BULLET), " Please enter new root password again: ");
 
         for (;;) {
                 _cleanup_free_ char *a = NULL, *b = NULL;
index bc4c155..5662b5f 100644 (file)
@@ -404,7 +404,7 @@ static int add_root_mount(void) {
                 opts = arg_root_rw > 0 ? "rw" : "ro";
         else if (arg_root_rw >= 0 ||
                  !fstab_test_option(arg_root_options, "ro\0" "rw\0"))
-                opts = strappenda(arg_root_options, ",", arg_root_rw > 0 ? "rw" : "ro");
+                opts = strjoina(arg_root_options, ",", arg_root_rw > 0 ? "rw" : "ro");
         else
                 opts = arg_root_options;
 
@@ -461,7 +461,7 @@ static int add_usr_mount(void) {
         if (!arg_usr_options)
                 opts = arg_root_rw > 0 ? "rw" : "ro";
         else if (!fstab_test_option(arg_usr_options, "ro\0" "rw\0"))
-                opts = strappenda(arg_usr_options, ",", arg_root_rw > 0 ? "rw" : "ro");
+                opts = strjoina(arg_usr_options, ",", arg_root_rw > 0 ? "rw" : "ro");
         else
                 opts = arg_usr_options;
 
index 931651e..f8f5fb3 100644 (file)
@@ -41,8 +41,8 @@ static int add_symlink(const char *fservice, const char *tservice) {
         assert(fservice);
         assert(tservice);
 
-        from = strappenda(SYSTEM_DATA_UNIT_PATH "/", fservice);
-        to = strappenda(arg_dest, "/getty.target.wants/", tservice);
+        from = strjoina(SYSTEM_DATA_UNIT_PATH "/", fservice);
+        to = strjoina(arg_dest, "/getty.target.wants/", tservice);
 
         mkdir_parents_label(to, 0755);
 
@@ -97,7 +97,7 @@ static int verify_tty(const char *name) {
          * friends. Let's check that and open the device and run
          * isatty() on it. */
 
-        p = strappenda("/dev/", name);
+        p = strjoina("/dev/", name);
 
         /* O_NONBLOCK is essential here, to make sure we don't wait
          * for DCD */
@@ -218,7 +218,7 @@ int main(int argc, char *argv[]) {
         NULSTR_FOREACH(j, virtualization_consoles) {
                 char *p;
 
-                p = strappenda("/sys/class/tty/", j);
+                p = strjoina("/sys/class/tty/", j);
                 if (access(p, F_OK) < 0)
                         continue;
 
index 909fdda..5c58b58 100644 (file)
@@ -147,7 +147,7 @@ static int add_cryptsetup(const char *id, const char *what, bool rw, char **devi
         if (ferror(f))
                 return log_error_errno(errno, "Failed to write file %s: %m", p);
 
-        from = strappenda("../", n);
+        from = strjoina("../", n);
 
         to = strjoin(arg_dest, "/", d, ".wants/", n, NULL);
         if (!to)
index 313b04b..d390cfb 100644 (file)
@@ -303,7 +303,7 @@ int curl_glue_make(CURL **ret, const char *url, void *userdata) {
                 goto fail;
         }
 
-        useragent = strappenda(program_invocation_short_name, "/" PACKAGE_VERSION);
+        useragent = strjoina(program_invocation_short_name, "/" PACKAGE_VERSION);
         if (curl_easy_setopt(c, CURLOPT_USERAGENT, useragent) != CURLE_OK) {
                 r = -EIO;
                 goto fail;
index e5531b8..2acf380 100644 (file)
@@ -121,7 +121,7 @@ int import_make_local_copy(const char *final, const char *image_root, const char
         if (!image_root)
                 image_root = "/var/lib/machines";
 
-        p = strappenda(image_root, "/", local);
+        p = strjoina(image_root, "/", local);
 
         if (force_local) {
                 (void) btrfs_subvol_remove(p);
@@ -309,7 +309,7 @@ int import_verify(
                 return -EBADMSG;
         }
 
-        line = strappenda(main_job->checksum, " *", fn, "\n");
+        line = strjoina(main_job->checksum, " *", fn, "\n");
 
         p = memmem(checksum_job->payload,
                    checksum_job->payload_size,
index a4ff6f4..fb72f6c 100644 (file)
@@ -399,7 +399,7 @@ static int dkr_import_add_token(DkrImport *i, ImportJob *j) {
         assert(j);
 
         if (i->response_token)
-                t = strappenda("Authorization: Token ", i->response_token);
+                t = strjoina("Authorization: Token ", i->response_token);
         else
                 t = HEADER_TOKEN " true";
 
@@ -480,7 +480,7 @@ static int dkr_import_job_on_open_disk(ImportJob *j) {
         if (base) {
                 const char *base_path;
 
-                base_path = strappenda(i->image_root, "/.dkr-", base);
+                base_path = strjoina(i->image_root, "/.dkr-", base);
                 r = btrfs_subvol_snapshot(base_path, i->temp_path, false, true);
         } else
                 r = btrfs_subvol_make(i->temp_path);
@@ -549,7 +549,7 @@ static int dkr_import_pull_layer(DkrImport *i) {
         i->final_path = path;
         path = NULL;
 
-        url = strappenda(PROTOCOL_PREFIX, i->response_registries[0], "/v1/images/", layer, "/layer");
+        url = strjoina(PROTOCOL_PREFIX, i->response_registries[0], "/v1/images/", layer, "/layer");
         r = import_job_new(&i->layer_job, url, i->glue, i);
         if (r < 0)
                 return log_error_errno(r, "Failed to allocate layer job: %m");
@@ -610,7 +610,7 @@ static void dkr_import_job_on_finished(ImportJob *j) {
                 log_info("Index lookup succeeded, directed to registry %s.", i->response_registries[0]);
                 dkr_import_report_progress(i, DKR_RESOLVING);
 
-                url = strappenda(PROTOCOL_PREFIX, i->response_registries[0], "/v1/repositories/", i->name, "/tags/", i->tag);
+                url = strjoina(PROTOCOL_PREFIX, i->response_registries[0], "/v1/repositories/", i->name, "/tags/", i->tag);
                 r = import_job_new(&i->tags_job, url, i->glue, i);
                 if (r < 0) {
                         log_error_errno(r, "Failed to allocate tags job: %m");
@@ -652,7 +652,7 @@ static void dkr_import_job_on_finished(ImportJob *j) {
                 log_info("Tag lookup succeeded, resolved to layer %s.", i->id);
                 dkr_import_report_progress(i, DKR_METADATA);
 
-                url = strappenda(PROTOCOL_PREFIX, i->response_registries[0], "/v1/images/", i->id, "/ancestry");
+                url = strjoina(PROTOCOL_PREFIX, i->response_registries[0], "/v1/images/", i->id, "/ancestry");
                 r = import_job_new(&i->ancestry_job, url, i->glue, i);
                 if (r < 0) {
                         log_error_errno(r, "Failed to allocate ancestry job: %m");
@@ -668,7 +668,7 @@ static void dkr_import_job_on_finished(ImportJob *j) {
                 i->ancestry_job->on_finished = dkr_import_job_on_finished;
                 i->ancestry_job->on_progress = dkr_import_job_on_progress;
 
-                url = strappenda(PROTOCOL_PREFIX, i->response_registries[0], "/v1/images/", i->id, "/json");
+                url = strjoina(PROTOCOL_PREFIX, i->response_registries[0], "/v1/images/", i->id, "/json");
                 r = import_job_new(&i->json_job, url, i->glue, i);
                 if (r < 0) {
                         log_error_errno(r, "Failed to allocate json job: %m");
@@ -873,7 +873,7 @@ int dkr_import_pull(DkrImport *i, const char *name, const char *tag, const char
         if (r < 0)
                 return r;
 
-        url = strappenda(i->index_url, "/v1/repositories/", name, "/images");
+        url = strjoina(i->index_url, "/v1/repositories/", name, "/images");
 
         r = import_job_new(&i->images_job, url, i->glue, i);
         if (r < 0)
index 5c88cdb..8d99f10 100644 (file)
@@ -270,7 +270,7 @@ static int raw_import_make_local_copy(RawImport *i) {
                         return log_error_errno(errno, "Failed to seek to beginning of vendor image: %m");
         }
 
-        p = strappenda(i->image_root, "/", i->local, ".raw");
+        p = strjoina(i->image_root, "/", i->local, ".raw");
 
         if (i->force_local) {
                 (void) btrfs_subvol_remove(p);
index f1c409c..8f32a9a 100644 (file)
@@ -885,7 +885,7 @@ static int remoteserver_init(RemoteServer *s,
         if (arg_url) {
                 const char *url, *hostname;
 
-                url = strappenda(arg_url, "/entries");
+                url = strjoina(arg_url, "/entries");
 
                 if (arg_getter) {
                         log_info("Spawning getter %s...", url);
index 277e125..34d9337 100644 (file)
@@ -38,7 +38,7 @@
 void microhttpd_logger(void *arg, const char *fmt, va_list ap) {
         char *f;
 
-        f = strappenda("microhttpd: ", fmt);
+        f = strjoina("microhttpd: ", fmt);
 
         DISABLE_WARNING_FORMAT_NONLITERAL;
         log_internalv(LOG_INFO, 0, NULL, 0, NULL, f, ap);
index f6b9514..f7ba019 100644 (file)
@@ -634,11 +634,11 @@ int main(int argc, char* argv[]) {
                         goto finish;
                 }
 
-                core_unit = strappenda("COREDUMP_UNIT=", t);
+                core_unit = strjoina("COREDUMP_UNIT=", t);
                 free(t);
 
         } else if (cg_pid_get_user_unit(pid, &t) >= 0) {
-                core_unit = strappenda("COREDUMP_USER_UNIT=", t);
+                core_unit = strjoina("COREDUMP_USER_UNIT=", t);
                 free(t);
         }
 
@@ -650,20 +650,20 @@ int main(int argc, char* argv[]) {
         log_set_target(LOG_TARGET_JOURNAL_OR_KMSG);
         log_open();
 
-        core_pid = strappenda("COREDUMP_PID=", info[INFO_PID]);
+        core_pid = strjoina("COREDUMP_PID=", info[INFO_PID]);
         IOVEC_SET_STRING(iovec[j++], core_pid);
 
-        core_uid = strappenda("COREDUMP_UID=", info[INFO_UID]);
+        core_uid = strjoina("COREDUMP_UID=", info[INFO_UID]);
         IOVEC_SET_STRING(iovec[j++], core_uid);
 
-        core_gid = strappenda("COREDUMP_GID=", info[INFO_GID]);
+        core_gid = strjoina("COREDUMP_GID=", info[INFO_GID]);
         IOVEC_SET_STRING(iovec[j++], core_gid);
 
-        core_signal = strappenda("COREDUMP_SIGNAL=", info[INFO_SIGNAL]);
+        core_signal = strjoina("COREDUMP_SIGNAL=", info[INFO_SIGNAL]);
         IOVEC_SET_STRING(iovec[j++], core_signal);
 
         if (sd_pid_get_session(pid, &t) >= 0) {
-                core_session = strappenda("COREDUMP_SESSION=", t);
+                core_session = strjoina("COREDUMP_SESSION=", t);
                 free(t);
 
                 IOVEC_SET_STRING(iovec[j++], core_session);
@@ -677,31 +677,31 @@ int main(int argc, char* argv[]) {
         }
 
         if (sd_pid_get_slice(pid, &t) >= 0) {
-                core_slice = strappenda("COREDUMP_SLICE=", t);
+                core_slice = strjoina("COREDUMP_SLICE=", t);
                 free(t);
 
                 IOVEC_SET_STRING(iovec[j++], core_slice);
         }
 
         if (comm) {
-                core_comm = strappenda("COREDUMP_COMM=", comm);
+                core_comm = strjoina("COREDUMP_COMM=", comm);
                 IOVEC_SET_STRING(iovec[j++], core_comm);
         }
 
         if (exe) {
-                core_exe = strappenda("COREDUMP_EXE=", exe);
+                core_exe = strjoina("COREDUMP_EXE=", exe);
                 IOVEC_SET_STRING(iovec[j++], core_exe);
         }
 
         if (get_process_cmdline(pid, 0, false, &t) >= 0) {
-                core_cmdline = strappenda("COREDUMP_CMDLINE=", t);
+                core_cmdline = strjoina("COREDUMP_CMDLINE=", t);
                 free(t);
 
                 IOVEC_SET_STRING(iovec[j++], core_cmdline);
         }
 
         if (cg_pid_get_path_shifted(pid, NULL, &t) >= 0) {
-                core_cgroup = strappenda("COREDUMP_CGROUP=", t);
+                core_cgroup = strjoina("COREDUMP_CGROUP=", t);
                 free(t);
 
                 IOVEC_SET_STRING(iovec[j++], core_cgroup);
@@ -752,14 +752,14 @@ int main(int argc, char* argv[]) {
         }
 
         if (get_process_cwd(pid, &t) >= 0) {
-                core_cwd = strappenda("COREDUMP_CWD=", t);
+                core_cwd = strjoina("COREDUMP_CWD=", t);
                 free(t);
 
                 IOVEC_SET_STRING(iovec[j++], core_cwd);
         }
 
         if (get_process_root(pid, &t) >= 0) {
-                core_root = strappenda("COREDUMP_ROOT=", t);
+                core_root = strjoina("COREDUMP_ROOT=", t);
                 free(t);
 
                 IOVEC_SET_STRING(iovec[j++], core_root);
@@ -799,7 +799,7 @@ int main(int argc, char* argv[]) {
         if (r == 0) {
                 const char *coredump_filename;
 
-                coredump_filename = strappenda("COREDUMP_FILENAME=", filename);
+                coredump_filename = strjoina("COREDUMP_FILENAME=", filename);
                 IOVEC_SET_STRING(iovec[j++], coredump_filename);
         }
 
index c17cf55..55c7786 100644 (file)
@@ -1269,7 +1269,7 @@ static int add_syslog_identifier(sd_journal *j) {
         STRV_FOREACH(i, arg_syslog_identifier) {
                 char *u;
 
-                u = strappenda("SYSLOG_IDENTIFIER=", *i);
+                u = strjoina("SYSLOG_IDENTIFIER=", *i);
                 r = sd_journal_add_match(j, u, 0);
                 if (r < 0)
                         return r;
index aecf859..7ee8174 100644 (file)
@@ -378,7 +378,7 @@ static void do_vacuum(
         if (!f)
                 return;
 
-        p = strappenda(path, id);
+        p = strjoina(path, id);
         r = journal_directory_vacuum(p, metrics->max_use, s->max_retention_usec, &s->oldest_file_usec, false);
         if (r < 0 && r != -ENOENT)
                 log_error_errno(r, "Failed to vacuum %s: %m", p);
@@ -589,28 +589,28 @@ static void dispatch_message_real(
 
                 r = get_process_comm(ucred->pid, &t);
                 if (r >= 0) {
-                        x = strappenda("_COMM=", t);
+                        x = strjoina("_COMM=", t);
                         free(t);
                         IOVEC_SET_STRING(iovec[n++], x);
                 }
 
                 r = get_process_exe(ucred->pid, &t);
                 if (r >= 0) {
-                        x = strappenda("_EXE=", t);
+                        x = strjoina("_EXE=", t);
                         free(t);
                         IOVEC_SET_STRING(iovec[n++], x);
                 }
 
                 r = get_process_cmdline(ucred->pid, 0, false, &t);
                 if (r >= 0) {
-                        x = strappenda("_CMDLINE=", t);
+                        x = strjoina("_CMDLINE=", t);
                         free(t);
                         IOVEC_SET_STRING(iovec[n++], x);
                 }
 
                 r = get_process_capeff(ucred->pid, &t);
                 if (r >= 0) {
-                        x = strappenda("_CAP_EFFECTIVE=", t);
+                        x = strjoina("_CAP_EFFECTIVE=", t);
                         free(t);
                         IOVEC_SET_STRING(iovec[n++], x);
                 }
@@ -633,12 +633,12 @@ static void dispatch_message_real(
                 if (r >= 0) {
                         char *session = NULL;
 
-                        x = strappenda("_SYSTEMD_CGROUP=", c);
+                        x = strjoina("_SYSTEMD_CGROUP=", c);
                         IOVEC_SET_STRING(iovec[n++], x);
 
                         r = cg_path_get_session(c, &t);
                         if (r >= 0) {
-                                session = strappenda("_SYSTEMD_SESSION=", t);
+                                session = strjoina("_SYSTEMD_SESSION=", t);
                                 free(t);
                                 IOVEC_SET_STRING(iovec[n++], session);
                         }
@@ -651,32 +651,32 @@ static void dispatch_message_real(
                         }
 
                         if (cg_path_get_unit(c, &t) >= 0) {
-                                x = strappenda("_SYSTEMD_UNIT=", t);
+                                x = strjoina("_SYSTEMD_UNIT=", t);
                                 free(t);
                                 IOVEC_SET_STRING(iovec[n++], x);
                         } else if (unit_id && !session) {
-                                x = strappenda("_SYSTEMD_UNIT=", unit_id);
+                                x = strjoina("_SYSTEMD_UNIT=", unit_id);
                                 IOVEC_SET_STRING(iovec[n++], x);
                         }
 
                         if (cg_path_get_user_unit(c, &t) >= 0) {
-                                x = strappenda("_SYSTEMD_USER_UNIT=", t);
+                                x = strjoina("_SYSTEMD_USER_UNIT=", t);
                                 free(t);
                                 IOVEC_SET_STRING(iovec[n++], x);
                         } else if (unit_id && session) {
-                                x = strappenda("_SYSTEMD_USER_UNIT=", unit_id);
+                                x = strjoina("_SYSTEMD_USER_UNIT=", unit_id);
                                 IOVEC_SET_STRING(iovec[n++], x);
                         }
 
                         if (cg_path_get_slice(c, &t) >= 0) {
-                                x = strappenda("_SYSTEMD_SLICE=", t);
+                                x = strjoina("_SYSTEMD_SLICE=", t);
                                 free(t);
                                 IOVEC_SET_STRING(iovec[n++], x);
                         }
 
                         free(c);
                 } else if (unit_id) {
-                        x = strappenda("_SYSTEMD_UNIT=", unit_id);
+                        x = strjoina("_SYSTEMD_UNIT=", unit_id);
                         IOVEC_SET_STRING(iovec[n++], x);
                 }
 
@@ -691,7 +691,7 @@ static void dispatch_message_real(
                                 security_context_t con;
 
                                 if (getpidcon(ucred->pid, &con) >= 0) {
-                                        x = strappenda("_SELINUX_CONTEXT=", con);
+                                        x = strjoina("_SELINUX_CONTEXT=", con);
 
                                         freecon(con);
                                         IOVEC_SET_STRING(iovec[n++], x);
@@ -717,21 +717,21 @@ static void dispatch_message_real(
 
                 r = get_process_comm(object_pid, &t);
                 if (r >= 0) {
-                        x = strappenda("OBJECT_COMM=", t);
+                        x = strjoina("OBJECT_COMM=", t);
                         free(t);
                         IOVEC_SET_STRING(iovec[n++], x);
                 }
 
                 r = get_process_exe(object_pid, &t);
                 if (r >= 0) {
-                        x = strappenda("OBJECT_EXE=", t);
+                        x = strjoina("OBJECT_EXE=", t);
                         free(t);
                         IOVEC_SET_STRING(iovec[n++], x);
                 }
 
                 r = get_process_cmdline(object_pid, 0, false, &t);
                 if (r >= 0) {
-                        x = strappenda("OBJECT_CMDLINE=", t);
+                        x = strjoina("OBJECT_CMDLINE=", t);
                         free(t);
                         IOVEC_SET_STRING(iovec[n++], x);
                 }
@@ -752,12 +752,12 @@ static void dispatch_message_real(
 
                 r = cg_pid_get_path_shifted(object_pid, s->cgroup_root, &c);
                 if (r >= 0) {
-                        x = strappenda("OBJECT_SYSTEMD_CGROUP=", c);
+                        x = strjoina("OBJECT_SYSTEMD_CGROUP=", c);
                         IOVEC_SET_STRING(iovec[n++], x);
 
                         r = cg_path_get_session(c, &t);
                         if (r >= 0) {
-                                x = strappenda("OBJECT_SYSTEMD_SESSION=", t);
+                                x = strjoina("OBJECT_SYSTEMD_SESSION=", t);
                                 free(t);
                                 IOVEC_SET_STRING(iovec[n++], x);
                         }
@@ -768,13 +768,13 @@ static void dispatch_message_real(
                         }
 
                         if (cg_path_get_unit(c, &t) >= 0) {
-                                x = strappenda("OBJECT_SYSTEMD_UNIT=", t);
+                                x = strjoina("OBJECT_SYSTEMD_UNIT=", t);
                                 free(t);
                                 IOVEC_SET_STRING(iovec[n++], x);
                         }
 
                         if (cg_path_get_user_unit(c, &t) >= 0) {
-                                x = strappenda("OBJECT_SYSTEMD_USER_UNIT=", t);
+                                x = strjoina("OBJECT_SYSTEMD_USER_UNIT=", t);
                                 free(t);
                                 IOVEC_SET_STRING(iovec[n++], x);
                         }
@@ -944,10 +944,10 @@ static int system_journal_open(Server *s, bool flush_requested) {
                 if (s->storage == STORAGE_PERSISTENT)
                         (void) mkdir("/var/log/journal/", 0755);
 
-                fn = strappenda("/var/log/journal/", ids);
+                fn = strjoina("/var/log/journal/", ids);
                 (void) mkdir(fn, 0755);
 
-                fn = strappenda(fn, "/system.journal");
+                fn = strjoina(fn, "/system.journal");
                 r = journal_file_open_reliably(fn, O_RDWR|O_CREAT, 0640, s->compress, s->seal, &s->system_metrics, s->mmap, NULL, &s->system_journal);
 
                 if (r >= 0)
index ba6e331..355f6e6 100644 (file)
@@ -356,18 +356,18 @@ void server_process_syslog_message(
         }
 
         if (identifier) {
-                syslog_identifier = strappenda("SYSLOG_IDENTIFIER=", identifier);
+                syslog_identifier = strjoina("SYSLOG_IDENTIFIER=", identifier);
                 if (syslog_identifier)
                         IOVEC_SET_STRING(iovec[n++], syslog_identifier);
         }
 
         if (pid) {
-                syslog_pid = strappenda("SYSLOG_PID=", pid);
+                syslog_pid = strjoina("SYSLOG_PID=", pid);
                 if (syslog_pid)
                         IOVEC_SET_STRING(iovec[n++], syslog_pid);
         }
 
-        message = strappenda("MESSAGE=", buf);
+        message = strjoina("MESSAGE=", buf);
         if (message)
                 IOVEC_SET_STRING(iovec[n++], message);
 
index 9dea547..ecf47fd 100644 (file)
@@ -1155,9 +1155,9 @@ static void check_network(sd_journal *j, int fd) {
 static bool file_has_type_prefix(const char *prefix, const char *filename) {
         const char *full, *tilded, *atted;
 
-        full = strappenda(prefix, ".journal");
-        tilded = strappenda(full, "~");
-        atted = strappenda(prefix, "@");
+        full = strjoina(prefix, ".journal");
+        tilded = strjoina(full, "~");
+        atted = strjoina(prefix, "@");
 
         return streq(filename, full) ||
                streq(filename, tilded) ||
@@ -1399,7 +1399,7 @@ static int add_root_directory(sd_journal *j, const char *p) {
                 return -EINVAL;
 
         if (j->prefix)
-                p = strappenda(j->prefix, p);
+                p = strjoina(j->prefix, p);
 
         d = opendir(p);
         if (!d)
@@ -1643,7 +1643,7 @@ _public_ int sd_journal_open_container(sd_journal **ret, const char *machine, in
         assert_return((flags & ~(SD_JOURNAL_LOCAL_ONLY|SD_JOURNAL_SYSTEM)) == 0, -EINVAL);
         assert_return(machine_name_is_valid(machine), -EINVAL);
 
-        p = strappenda("/run/systemd/machines/", machine);
+        p = strjoina("/run/systemd/machines/", machine);
         r = parse_env_file(p, NEWLINE, "ROOT", &root, "CLASS", &class, NULL);
         if (r == -ENOENT)
                 return -EHOSTDOWN;
index def8ea5..6ee3d81 100644 (file)
@@ -631,7 +631,7 @@ idev_device *idev_find_keyboard(idev_session *s, const char *name) {
         assert_return(s, NULL);
         assert_return(name, NULL);
 
-        kname = strappenda("keyboard/", name);
+        kname = strjoina("keyboard/", name);
         return hashmap_get(s->device_map, kname);
 }
 
@@ -793,7 +793,7 @@ int idev_keyboard_new(idev_device **out, idev_session *s, const char *name) {
         if (r < 0)
                 return r;
 
-        kname = strappenda("keyboard/", name);
+        kname = strjoina("keyboard/", name);
         r = idev_device_add(d, kname);
         if (r < 0)
                 return r;
index 8d12c25..ac27df8 100644 (file)
@@ -1359,7 +1359,7 @@ int bus_add_match_internal_kernel(
 
 #define internal_match(bus, m)                                          \
         ((bus)->hello_flags & KDBUS_HELLO_MONITOR                       \
-         ? (isempty(m) ? "eavesdrop='true'" : strappenda((m), ",eavesdrop='true'")) \
+         ? (isempty(m) ? "eavesdrop='true'" : strjoina((m), ",eavesdrop='true'")) \
          : (m))
 
 static int bus_add_match_internal_dbus1(
index e27d802..7181639 100644 (file)
@@ -354,7 +354,7 @@ int bus_creds_dump(sd_bus_creds *c, FILE *f, bool terse) {
                 color = ansi_highlight();
 
                 off = ansi_highlight_off();
-                suffix = strappenda(off, "\n");
+                suffix = strjoina(off, "\n");
         }
 
         if (c->mask & SD_BUS_CREDS_PID)
index f0bc2a7..d3c1772 100644 (file)
@@ -256,8 +256,8 @@ static void print_subtree(const char *prefix, const char *path, char **l) {
                 l++;
         }
 
-        vertical = strappenda(prefix, draw_special_char(DRAW_TREE_VERTICAL));
-        space = strappenda(prefix, draw_special_char(DRAW_TREE_SPACE));
+        vertical = strjoina(prefix, draw_special_char(DRAW_TREE_VERTICAL));
+        space = strjoina(prefix, draw_special_char(DRAW_TREE_SPACE));
 
         for (;;) {
                 bool has_more = false;
index 125b302..1bf77e4 100644 (file)
@@ -1286,7 +1286,7 @@ int bus_set_address_system_remote(sd_bus *b, const char *host) {
                         if (!e)
                                 return -ENOMEM;
 
-                        c = strappenda(",argv4=--machine=", m);
+                        c = strjoina(",argv4=--machine=", m);
                 }
         }
 
index c72d23e..c171405 100644 (file)
@@ -791,7 +791,7 @@ _public_ int sd_machine_get_class(const char *machine, char **class) {
         assert_return(machine_name_is_valid(machine), -EINVAL);
         assert_return(class, -EINVAL);
 
-        p = strappenda("/run/systemd/machines/", machine);
+        p = strjoina("/run/systemd/machines/", machine);
         r = parse_env_file(p, NEWLINE, "CLASS", &c, NULL);
         if (r < 0)
                 return r;
@@ -814,7 +814,7 @@ _public_ int sd_machine_get_ifindices(const char *machine, int **ifindices) {
         assert_return(machine_name_is_valid(machine), -EINVAL);
         assert_return(ifindices, -EINVAL);
 
-        p = strappenda("/run/systemd/machines/", machine);
+        p = strjoina("/run/systemd/machines/", machine);
         r = parse_env_file(p, NEWLINE, "NETIF", &netif, NULL);
         if (r < 0)
                 return r;
index d5206aa..9863901 100644 (file)
@@ -1936,7 +1936,7 @@ int udev_device_rename(struct udev_device *udev_device, const char *name)
         if (!dirname)
                 return -ENOMEM;
 
-        new_syspath = strappenda(dirname, "/", name);
+        new_syspath = strjoina(dirname, "/", name);
 
         r = udev_device_set_syspath(udev_device, new_syspath);
         if (r < 0)
index 529a9ab..ed763c3 100644 (file)
@@ -1011,7 +1011,7 @@ static int method_set_vc_keyboard(sd_bus *bus, sd_bus_message *m, void *userdata
 static void log_xkb(struct xkb_context *ctx, enum xkb_log_level lvl, const char *format, va_list args) {
         const char *fmt;
 
-        fmt = strappenda("libxkbcommon: ", format);
+        fmt = strjoina("libxkbcommon: ", format);
         log_internalv(LOG_DEBUG, 0, __FILE__, __LINE__, __func__, fmt, args);
 }
 
index e22b106..d7211e6 100644 (file)
@@ -247,7 +247,7 @@ int button_open(Button *b) {
                 b->fd = -1;
         }
 
-        p = strappenda("/dev/input/", b->name);
+        p = strjoina("/dev/input/", b->name);
 
         b->fd = open(p, O_RDWR|O_CLOEXEC|O_NOCTTY|O_NONBLOCK);
         if (b->fd < 0)
index c7c1559..8b0bafd 100644 (file)
@@ -1136,7 +1136,7 @@ static int method_set_user_linger(sd_bus *bus, sd_bus_message *message, void *us
         if (!cc)
                 return -ENOMEM;
 
-        path = strappenda("/var/lib/systemd/linger/", cc);
+        path = strjoina("/var/lib/systemd/linger/", cc);
         if (b) {
                 User *u;
 
index 928afd3..7b40ef5 100644 (file)
@@ -659,7 +659,7 @@ int user_check_linger_file(User *u) {
         if (!cc)
                 return -ENOMEM;
 
-        p = strappenda("/var/lib/systemd/linger/", cc);
+        p = strjoina("/var/lib/systemd/linger/", cc);
 
         return access(p, F_OK) >= 0;
 }
index 6c01617..223eb0f 100644 (file)
@@ -211,7 +211,7 @@ int machine_save(Machine *m) {
                 /* Create a symlink from the unit name to the machine
                  * name, so that we can quickly find the machine for
                  * each given unit */
-                sl = strappenda("/run/systemd/machines/unit:", m->unit);
+                sl = strjoina("/run/systemd/machines/unit:", m->unit);
                 symlink(m->name, sl);
         }
 
@@ -232,7 +232,7 @@ static void machine_unlink(Machine *m) {
 
                 char *sl;
 
-                sl = strappenda("/run/systemd/machines/unit:", m->unit);
+                sl = strjoina("/run/systemd/machines/unit:", m->unit);
                 unlink(sl);
         }
 
@@ -340,7 +340,7 @@ static int machine_start_scope(Machine *m, sd_bus_message *properties, sd_bus_er
                 if (!scope)
                         return log_oom();
 
-                description = strappenda(m->class == MACHINE_VM ? "Virtual Machine " : "Container ", m->name);
+                description = strjoina(m->class == MACHINE_VM ? "Virtual Machine " : "Container ", m->name);
 
                 r = manager_start_scope(m->manager, scope, m->leader, SPECIAL_MACHINE_SLICE, description, properties, error, &job);
                 if (r < 0) {
index 06ae8bc..16ce2f4 100644 (file)
@@ -1160,7 +1160,7 @@ static int bind_mount(int argc, char *argv[], void *userdata) {
                 return -EINVAL;
         }
 
-        p = strappenda("/run/systemd/nspawn/propagate/", argv[1], "/");
+        p = strjoina("/run/systemd/nspawn/propagate/", argv[1], "/");
         if (access(p, F_OK) < 0) {
                 log_error("Container does not allow propagation of mount points.");
                 return -ENOTSUP;
@@ -1198,7 +1198,7 @@ static int bind_mount(int argc, char *argv[], void *userdata) {
 
         /* Second, we mount the source directory to a directory inside
            of our MS_SLAVE playground. */
-        mount_tmp = strappenda(mount_slave, "/mount");
+        mount_tmp = strjoina(mount_slave, "/mount");
         if (mkdir(mount_tmp, 0700) < 0) {
                 r = log_error_errno(errno, "Failed to create temporary mount: %m");
                 goto finish;
@@ -1224,7 +1224,7 @@ static int bind_mount(int argc, char *argv[], void *userdata) {
          * directory. This way it will appear there read-only
          * right-away. */
 
-        mount_outside = strappenda("/run/systemd/nspawn/propagate/", argv[1], "/XXXXXX");
+        mount_outside = strjoina("/run/systemd/nspawn/propagate/", argv[1], "/XXXXXX");
         if (!mkdtemp(mount_outside)) {
                 r = log_error_errno(errno, "Cannot create propagation directory: %m");
                 goto finish;
@@ -1276,7 +1276,7 @@ static int bind_mount(int argc, char *argv[], void *userdata) {
                         mkdir_p(dest, 0755);
 
                 /* Fifth, move the mount to the right place inside */
-                mount_inside = strappenda("/run/systemd/nspawn/incoming/", basename(mount_outside));
+                mount_inside = strjoina("/run/systemd/nspawn/incoming/", basename(mount_outside));
                 if (mount(mount_inside, dest, NULL, MS_MOVE, NULL) < 0) {
                         log_error_errno(errno, "Failed to mount: %m");
                         _exit(EXIT_FAILURE);
@@ -1376,7 +1376,7 @@ static int login_machine(int argc, char *argv[], void *userdata) {
         if (r < 0)
                 return log_error_errno(r, "Failed to attach bus to event loop: %m");
 
-        match = strappenda("type='signal',"
+        match = strjoina("type='signal',"
                            "sender='org.freedesktop.machine1',"
                            "path='/org/freedesktop/machine1',",
                            "interface='org.freedesktop.machine1.Manager',"
index acdb486..a8d9bc0 100644 (file)
@@ -1243,7 +1243,7 @@ static int link_set_ipv4_forward(Link *link) {
 
         b = link_ipv4_forward_enabled(link);
 
-        p = strappenda("/proc/sys/net/ipv4/conf/", link->ifname, "/forwarding");
+        p = strjoina("/proc/sys/net/ipv4/conf/", link->ifname, "/forwarding");
         r = write_string_file_no_create(p, one_zero(b));
         if (r < 0)
                 log_link_warning_errno(link, r, "Cannot configure IPv4 forwarding for interface %s: %m", link->ifname);
@@ -1278,7 +1278,7 @@ static int link_set_ipv6_forward(Link *link) {
         const char *p = NULL;
         int r;
 
-        p = strappenda("/proc/sys/net/ipv6/conf/", link->ifname, "/forwarding");
+        p = strjoina("/proc/sys/net/ipv6/conf/", link->ifname, "/forwarding");
         r = write_string_file_no_create(p, one_zero(link_ipv6_forward_enabled(link)));
         if (r < 0)
                 log_link_warning_errno(link, r, "Cannot configure IPv6 forwarding for interface: %m");
index 226c441..1e6e7bf 100644 (file)
@@ -962,7 +962,7 @@ static int mount_cgroup_hierarchy(const char *dest, const char *controller, cons
         char *to;
         int r;
 
-        to = strappenda(dest, "/sys/fs/cgroup/", hierarchy);
+        to = strjoina(dest, "/sys/fs/cgroup/", hierarchy);
 
         r = path_is_mount_point(to, false);
         if (r < 0)
@@ -1004,7 +1004,7 @@ static int mount_cgroup(const char *dest) {
         if (r < 0)
                 return log_error_errno(r, "Failed to determine our own cgroup path: %m");
 
-        cgroup_root = strappenda(dest, "/sys/fs/cgroup");
+        cgroup_root = strjoina(dest, "/sys/fs/cgroup");
         if (mount("tmpfs", cgroup_root, "tmpfs", MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_STRICTATIME, "mode=755") < 0)
                 return log_error_errno(errno, "Failed to mount tmpfs to /sys/fs/cgroup: %m");
 
@@ -1057,12 +1057,12 @@ static int mount_cgroup(const char *dest) {
                 return r;
 
         /* Make our own cgroup a (writable) bind mount */
-        systemd_own = strappenda(dest, "/sys/fs/cgroup/systemd", own_cgroup_path);
+        systemd_own = strjoina(dest, "/sys/fs/cgroup/systemd", own_cgroup_path);
         if (mount(systemd_own, systemd_own,  NULL, MS_BIND, NULL) < 0)
                 return log_error_errno(errno, "Failed to turn %s into a bind mount: %m", own_cgroup_path);
 
         /* And then remount the systemd cgroup root read-only */
-        systemd_root = strappenda(dest, "/sys/fs/cgroup/systemd");
+        systemd_root = strjoina(dest, "/sys/fs/cgroup/systemd");
         if (mount(NULL, systemd_root, NULL, MS_BIND|MS_REMOUNT|MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_RDONLY, NULL) < 0)
                 return log_error_errno(errno, "Failed to mount cgroup root read-only: %m");
 
@@ -1215,7 +1215,7 @@ static int setup_volatile_state(const char *directory) {
         if (r < 0)
                 return log_error_errno(r, "Failed to remount %s read-only: %m", directory);
 
-        p = strappenda(directory, "/var");
+        p = strjoina(directory, "/var");
         r = mkdir(p, 0755);
         if (r < 0 && errno != EEXIST)
                 return log_error_errno(errno, "Failed to create %s: %m", directory);
@@ -1251,8 +1251,8 @@ static int setup_volatile(const char *directory) {
 
         tmpfs_mounted = true;
 
-        f = strappenda(directory, "/usr");
-        t = strappenda(template, "/usr");
+        f = strjoina(directory, "/usr");
+        t = strjoina(template, "/usr");
 
         r = mkdir(t, 0755);
         if (r < 0 && errno != EEXIST) {
@@ -1434,7 +1434,7 @@ static int setup_dev_console(const char *dest, const char *console) {
          * /dev/console. (Note that the major minor doesn't actually
          * matter here, since we mount it over anyway). */
 
-        to = strappenda(dest, "/dev/console");
+        to = strjoina(dest, "/dev/console");
         if (mknod(to, (st.st_mode & ~07777) | 0600, st.st_rdev) < 0)
                 return log_error_errno(errno, "mknod() for /dev/console failed: %m");
 
@@ -2564,10 +2564,10 @@ static int setup_propagate(const char *root) {
 
         (void) mkdir_p("/run/systemd/nspawn/", 0755);
         (void) mkdir_p("/run/systemd/nspawn/propagate", 0600);
-        p = strappenda("/run/systemd/nspawn/propagate/", arg_machine);
+        p = strjoina("/run/systemd/nspawn/propagate/", arg_machine);
         (void) mkdir_p(p, 0600);
 
-        q = strappenda(root, "/run/systemd/nspawn/incoming");
+        q = strjoina(root, "/run/systemd/nspawn/incoming");
         mkdir_parents(q, 0755);
         mkdir_p(q, 0600);
 
@@ -3050,7 +3050,7 @@ static int mount_device(const char *what, const char *where, const char *directo
                 rw = false;
 
         if (directory)
-                p = strappenda(where, directory);
+                p = strjoina(where, directory);
         else
                 p = where;
 
@@ -3685,7 +3685,7 @@ int main(int argc, char *argv[]) {
                 } else {
                         const char *p;
 
-                        p = strappenda(arg_directory,
+                        p = strjoina(arg_directory,
                                        argc > optind && path_is_absolute(argv[optind]) ? argv[optind] : "/usr/bin/");
                         if (access(p, F_OK) < 0) {
                                 log_error("Directory %s lacks the binary to execute or doesn't look like a binary tree. Refusing.", arg_directory);
@@ -4294,7 +4294,7 @@ finish:
         if (arg_machine) {
                 const char *p;
 
-                p = strappenda("/run/systemd/nspawn/propagate/", arg_machine);
+                p = strjoina("/run/systemd/nspawn/propagate/", arg_machine);
                 (void) rm_rf(p, false, true, false);
         }
 
index 8161b53..03c8478 100644 (file)
@@ -76,7 +76,7 @@ static int reply_query_state(DnsQuery *q) {
                                 rc = p;
                         }
 
-                        n = strappenda(_BUS_ERROR_DNS, rc);
+                        n = strjoina(_BUS_ERROR_DNS, rc);
                         sd_bus_error_setf(&error, n, "Could not resolve '%s', server or network returned error %s", name, rc);
                 }
 
index 723e0cb..0661b3b 100644 (file)
@@ -494,7 +494,7 @@ static int transient_service_set_properties(sd_bus_message *m, char **argv, cons
                 if (e) {
                         char *n;
 
-                        n = strappenda("TERM=", e);
+                        n = strjoina("TERM=", e);
                         r = sd_bus_message_append(m,
                                                   "(sv)",
                                                   "Environment", "as", 1, n);
index ea66c76..cbd94e8 100644 (file)
@@ -93,7 +93,7 @@ static int show_cgroup_one_by_path(const char *path, const char *prefix, unsigne
         if (r < 0)
                 return r;
 
-        fn = strappenda(p, "/cgroup.procs");
+        fn = strjoina(p, "/cgroup.procs");
         f = fopen(fn, "re");
         if (!f)
                 return -errno;
index 0d3cc53..b527868 100644 (file)
@@ -510,7 +510,7 @@ static int check_hierarchy(const char *p) {
                 return 0;
 
         /* Check if this controller actually really exists */
-        cc = strappenda("/sys/fs/cgroup/", p);
+        cc = strjoina("/sys/fs/cgroup/", p);
         if (laccess(cc, F_OK) < 0)
                 return -errno;
 
index 4faca2b..da7560f 100644 (file)
@@ -288,7 +288,7 @@ static int condition_test_needs_update(Condition *c) {
         if (!path_is_absolute(c->parameter))
                 return true;
 
-        p = strappenda(c->parameter, "/.updated");
+        p = strjoina(c->parameter, "/.updated");
         if (lstat(p, &other) < 0)
                 return true;
 
index 51f4e01..db4937d 100644 (file)
@@ -44,7 +44,7 @@ static int files_add(Hashmap *h, const char *root, const char *path, const char
         assert(path);
         assert(suffix);
 
-        dirpath = strappenda(root ? root : "", path);
+        dirpath = strjoina(root ? root : "", path);
 
         dir = opendir(dirpath);
         if (!dir) {
index 4140afb..7f16d5c 100644 (file)
@@ -62,7 +62,7 @@ int generator_write_fsck_deps(
         if (streq(where, "/")) {
                 char *lnk;
 
-                lnk = strappenda(dest, "/" SPECIAL_LOCAL_FS_TARGET ".wants/systemd-fsck-root.service");
+                lnk = strjoina(dest, "/" SPECIAL_LOCAL_FS_TARGET ".wants/systemd-fsck-root.service");
 
                 mkdir_parents(lnk, 0755);
                 if (symlink(SYSTEM_DATA_UNIT_PATH "/systemd-fsck-root.service", lnk) < 0)
index 37191a7..65f1c24 100644 (file)
@@ -1048,7 +1048,7 @@ static int unit_file_load(
         assert(path);
 
         if (!isempty(root_dir))
-                path = strappenda(root_dir, "/", path);
+                path = strjoina(root_dir, "/", path);
 
         if (!load) {
                 r = access(path, F_OK) ? -errno : 0;
@@ -1730,7 +1730,7 @@ int unit_file_set_default(
         if (r < 0)
                 return r;
 
-        path = strappenda(config_path, "/" SPECIAL_DEFAULT_TARGET);
+        path = strjoina(config_path, "/" SPECIAL_DEFAULT_TARGET);
 
         r = create_symlink(i->path, path, force, changes, n_changes);
         if (r < 0)
index b7a99d2..45741f9 100644 (file)
@@ -1033,10 +1033,10 @@ int add_matches_for_unit(sd_journal *j, const char *unit) {
         assert(j);
         assert(unit);
 
-        m1 = strappenda("_SYSTEMD_UNIT=", unit);
-        m2 = strappenda("COREDUMP_UNIT=", unit);
-        m3 = strappenda("UNIT=", unit);
-        m4 = strappenda("OBJECT_SYSTEMD_UNIT=", unit);
+        m1 = strjoina("_SYSTEMD_UNIT=", unit);
+        m2 = strjoina("COREDUMP_UNIT=", unit);
+        m3 = strjoina("UNIT=", unit);
+        m4 = strjoina("OBJECT_SYSTEMD_UNIT=", unit);
 
         (void)(
             /* Look for messages from the service itself */
@@ -1080,10 +1080,10 @@ int add_matches_for_user_unit(sd_journal *j, const char *unit, uid_t uid) {
         assert(j);
         assert(unit);
 
-        m1 = strappenda("_SYSTEMD_USER_UNIT=", unit);
-        m2 = strappenda("USER_UNIT=", unit);
-        m3 = strappenda("COREDUMP_USER_UNIT=", unit);
-        m4 = strappenda("OBJECT_SYSTEMD_USER_UNIT=", unit);
+        m1 = strjoina("_SYSTEMD_USER_UNIT=", unit);
+        m2 = strjoina("USER_UNIT=", unit);
+        m3 = strjoina("COREDUMP_USER_UNIT=", unit);
+        m4 = strjoina("OBJECT_SYSTEMD_USER_UNIT=", unit);
         sprintf(muid, "_UID="UID_FMT, uid);
 
         (void) (
index 8ea6105..8d61507 100644 (file)
@@ -425,7 +425,7 @@ int image_rename(Image *i, const char *new_name) {
         case IMAGE_RAW: {
                 const char *fn;
 
-                fn = strappenda(new_name, ".raw");
+                fn = strjoina(new_name, ".raw");
                 new_path = file_in_same_dir(i->path, fn);
                 break;
         }
@@ -486,13 +486,13 @@ int image_clone(Image *i, const char *new_name, bool read_only) {
 
         case IMAGE_SUBVOLUME:
         case IMAGE_DIRECTORY:
-                new_path = strappenda("/var/lib/machines/", new_name);
+                new_path = strjoina("/var/lib/machines/", new_name);
 
                 r = btrfs_subvol_snapshot(i->path, new_path, read_only, true);
                 break;
 
         case IMAGE_RAW:
-                new_path = strappenda("/var/lib/machines/", new_name, ".raw");
+                new_path = strjoina("/var/lib/machines/", new_name, ".raw");
 
                 r = copy_file_atomic(i->path, new_path, read_only ? 0444 : 0644, false, FS_NOCOW_FL);
                 break;
@@ -629,7 +629,7 @@ int image_name_lock(const char *name, int operation, LockFile *ret) {
                 return -EBUSY;
 
         mkdir_p("/run/systemd/nspawn/locks", 0600);
-        p = strappenda("/run/systemd/nspawn/locks/name-", name);
+        p = strjoina("/run/systemd/nspawn/locks/name-", name);
 
         return make_lock_file(p, operation, ret);
 }
index a9f2b7e..8635d9a 100644 (file)
@@ -91,7 +91,7 @@ int pager_open(bool jump_to_end) {
                 if (!less_opts)
                         less_opts = "FRSXMK";
                 if (jump_to_end)
-                        less_opts = strappenda(less_opts, " +G");
+                        less_opts = strjoina(less_opts, " +G");
                 setenv("LESS", less_opts, 1);
 
                 /* Make sure the pager goes away when the parent dies */
index 00d2d44..b9db7f1 100644 (file)
@@ -560,14 +560,14 @@ int path_is_os_tree(const char *path) {
         int r;
 
         /* We use /usr/lib/os-release as flag file if something is an OS */
-        p = strappenda(path, "/usr/lib/os-release");
+        p = strjoina(path, "/usr/lib/os-release");
         r = access(p, F_OK);
 
         if (r >= 0)
                 return 1;
 
         /* Also check for the old location in /etc, just in case. */
-        p = strappenda(path, "/etc/os-release");
+        p = strjoina(path, "/etc/os-release");
         r = access(p, F_OK);
 
         return r >= 0;
@@ -665,7 +665,7 @@ int fsck_exists(const char *fstype) {
         const char *checker;
         int r;
 
-        checker = strappenda("fsck.", fstype);
+        checker = strjoina("fsck.", fstype);
 
         r = find_binary(checker, true, &p);
         if (r < 0)
index e8cedc6..813641a 100644 (file)
@@ -51,7 +51,7 @@ int switch_root(const char *new_root, const char *oldroot, bool detach_oldroot,
         if (path_equal(new_root, "/"))
                 return 0;
 
-        temporary_old_root = strappenda(new_root, oldroot);
+        temporary_old_root = strjoina(new_root, oldroot);
         mkdir_p_label(temporary_old_root, 0755);
 
         old_root_remove = in_initrd();
index d3404af..947ac1f 100644 (file)
@@ -965,7 +965,7 @@ bool timezone_is_valid(const char *name) {
         if (slash)
                 return false;
 
-        t = strappenda("/usr/share/zoneinfo/", name);
+        t = strjoina("/usr/share/zoneinfo/", name);
         if (stat(t, &st) < 0)
                 return false;
 
index 11cab6d..c53f9cd 100644 (file)
@@ -6452,7 +6452,7 @@ int container_get_leader(const char *machine, pid_t *pid) {
         assert(machine);
         assert(pid);
 
-        p = strappenda("/run/systemd/machines/", machine);
+        p = strjoina("/run/systemd/machines/", machine);
         r = parse_env_file(p, NEWLINE, "LEADER", &s, "CLASS", &class, NULL);
         if (r == -ENOENT)
                 return -EHOSTDOWN;
@@ -6691,7 +6691,7 @@ int open_tmpfile(const char *path, int flags) {
 #endif
 
         /* Fall back to unguessable name + unlinking */
-        p = strappenda(path, "/systemd-tmp-XXXXXX");
+        p = strjoina(path, "/systemd-tmp-XXXXXX");
 
         fd = mkostemp_safe(p, flags);
         if (fd < 0)
@@ -7220,7 +7220,7 @@ int take_password_lock(const char *root) {
          * awfully racy, and thus we just won't do them. */
 
         if (root)
-                path = strappenda(root, "/etc/.pwd.lock");
+                path = strjoina(root, "/etc/.pwd.lock");
         else
                 path = "/etc/.pwd.lock";
 
index 410ce65..7dfabbc 100644 (file)
@@ -931,19 +931,19 @@ int unlink_noerrno(const char *path);
                 (void*)memset(_new_, 0, _size_);                        \
         })
 
-#define strappenda(a, ...)                                       \
-        ({                                                       \
-                int _len = strlen(a);                            \
-                unsigned _i;                                     \
-                char *_d_, *_p_;                                 \
-                const char *_appendees_[] = { __VA_ARGS__ };     \
-                for (_i = 0; _i < ELEMENTSOF(_appendees_); _i++) \
-                        _len += strlen(_appendees_[_i]);         \
-                _d_ = alloca(_len + 1);                          \
-                _p_ = stpcpy(_d_, a);                            \
-                for (_i = 0; _i < ELEMENTSOF(_appendees_); _i++) \
-                        _p_ = stpcpy(_p_, _appendees_[_i]);      \
-                _d_;                                             \
+#define strjoina(a, ...)                                                \
+        ({                                                              \
+                const char *_appendees_[] = { a, __VA_ARGS__ };         \
+                char *_d_, *_p_;                                        \
+                int _len_ = 0;                                          \
+                unsigned _i_;                                           \
+                for (_i_ = 0; _i_ < ELEMENTSOF(_appendees_) && _appendees_[_i_]; _i_++) \
+                        _len_ += strlen(_appendees_[_i_]);              \
+                _p_ = _d_ = alloca(_len_ + 1);                          \
+                for (_i_ = 0; _i_ < ELEMENTSOF(_appendees_) && _appendees_[_i_]; _i_++) \
+                        _p_ = stpcpy(_p_, _appendees_[_i_]);            \
+                *_p_ = 0;                                               \
+                _d_;                                                    \
         })
 
 #define procfs_file_alloca(pid, field)                                  \
index 455a841..ad34ef1 100644 (file)
@@ -45,7 +45,7 @@ static int generate_symlink(void) {
                 return -EINVAL;
         }
 
-        p = strappenda(arg_dest, "/default.target");
+        p = strjoina(arg_dest, "/default.target");
         if (symlink(SYSTEM_DATA_UNIT_PATH "/system-update.target", p) < 0)
                 return log_error_errno(errno, "Failed to create symlink %s: %m", p);
 
index 11b0be0..462f7fd 100644 (file)
@@ -4978,8 +4978,8 @@ static int switch_root(sd_bus *bus, char **args) {
         if (init) {
                 const char *root_systemd_path = NULL, *root_init_path = NULL;
 
-                root_systemd_path = strappenda(root, "/" SYSTEMD_BINARY_PATH);
-                root_init_path = strappenda(root, "/", init);
+                root_systemd_path = strjoina(root, "/" SYSTEMD_BINARY_PATH);
+                root_init_path = strjoina(root, "/", init);
 
                 /* If the passed init is actually the same as the
                  * systemd binary, then let's suppress it. */
@@ -5783,7 +5783,7 @@ static int unit_file_create_dropin(const char *unit_name, const char *user_home,
         assert(ret_new_path);
         assert(ret_tmp_path);
 
-        ending = strappenda(unit_name, ".d/override.conf");
+        ending = strjoina(unit_name, ".d/override.conf");
         r = get_file_to_edit(ending, user_home, user_runtime, &tmp_new_path);
         if (r < 0)
                 return r;
index f25ece0..e47bcb4 100644 (file)
@@ -81,7 +81,7 @@ static uid_t search_uid = UID_INVALID;
 static UidRange *uid_range = NULL;
 static unsigned n_uid_range = 0;
 
-#define fix_root(x) (arg_root ? strappenda(arg_root, x) : x)
+#define fix_root(x) (arg_root ? strjoina(arg_root, x) : x)
 
 static int load_user_database(void) {
         _cleanup_fclose_ FILE *f = NULL;
@@ -217,7 +217,7 @@ static int make_backup(const char *target, const char *x) {
         /* Don't fail on chmod() or chown(). If it stays owned by us
          * and/or unreadable by others, then it isn't too bad... */
 
-        backup = strappenda(x, "-");
+        backup = strjoina(x, "-");
 
         /* Copy over the access mask */
         if (fchmod(fileno(dst), st.st_mode & 07777) < 0)
index 71cfc02..894c7f7 100644 (file)
@@ -59,12 +59,12 @@ static void test_conf_files_list(bool use_root) {
                 search_2 = "/dir2";
         } else {
                 root_dir = NULL;
-                search_1 = strappenda(tmp_dir, "/dir1");
-                search_2 = strappenda(tmp_dir, "/dir2");
+                search_1 = strjoina(tmp_dir, "/dir1");
+                search_2 = strjoina(tmp_dir, "/dir2");
         }
 
-        expect_a = strappenda(tmp_dir, "/dir1/a.conf");
-        expect_b = strappenda(tmp_dir, "/dir2/b.conf");
+        expect_a = strjoina(tmp_dir, "/dir1/a.conf");
+        expect_b = strjoina(tmp_dir, "/dir2/b.conf");
 
         assert_se(conf_files_list(&found_files, ".conf", root_dir, search_1, search_2, NULL) == 0);
         strv_print(found_files);
index 3e1607e..5c96f61 100644 (file)
@@ -90,15 +90,15 @@ static void test_copy_tree(void) {
         rm_rf_dangerous(original_dir, false, true, false);
 
         STRV_FOREACH(p, files) {
-                char *f = strappenda(original_dir, *p);
+                char *f = strjoina(original_dir, *p);
 
                 assert_se(mkdir_parents(f, 0755) >= 0);
                 assert_se(write_string_file(f, "file") == 0);
         }
 
         STRV_FOREACH_PAIR(link, p, links) {
-                char *f = strappenda(original_dir, *p);
-                char *l = strappenda(original_dir, *link);
+                char *f = strjoina(original_dir, *p);
+                char *l = strjoina(original_dir, *link);
 
                 assert_se(mkdir_parents(l, 0755) >= 0);
                 assert_se(symlink(f, l) == 0);
@@ -109,7 +109,7 @@ static void test_copy_tree(void) {
         STRV_FOREACH(p, files) {
                 _cleanup_free_ char *buf = NULL;
                 size_t sz = 0;
-                char *f = strappenda(copy_dir, *p);
+                char *f = strjoina(copy_dir, *p);
 
                 assert_se(access(f, F_OK) == 0);
                 assert_se(read_full_file(f, &buf, &sz) == 0);
@@ -118,8 +118,8 @@ static void test_copy_tree(void) {
 
         STRV_FOREACH_PAIR(link, p, links) {
                 _cleanup_free_ char *target = NULL;
-                char *f = strappenda(original_dir, *p);
-                char *l = strappenda(copy_dir, *link);
+                char *f = strjoina(original_dir, *p);
+                char *l = strjoina(copy_dir, *link);
 
                 assert_se(readlink_and_canonicalize(l, &target) == 0);
                 assert_se(path_equal(f, target));
index 084a58f..2397db5 100644 (file)
@@ -42,8 +42,8 @@ static void test_tmpdir(const char *id, const char *A, const char *B) {
         assert_se((x.st_mode & 01777) == 0700);
         assert_se((y.st_mode & 01777) == 0700);
 
-        c = strappenda(a, "/tmp");
-        d = strappenda(b, "/tmp");
+        c = strjoina(a, "/tmp");
+        d = strjoina(b, "/tmp");
 
         assert_se(stat(c, &x) >= 0);
         assert_se(stat(d, &y) >= 0);
index a6ce8c9..38e5c93 100644 (file)
@@ -33,9 +33,9 @@ static void test_paths(SystemdRunningAs running_as, bool personal) {
         char *exists, *not;
 
         assert_se(mkdtemp(template));
-        exists = strappenda(template, "/exists");
+        exists = strjoina(template, "/exists");
         assert_se(mkdir(exists, 0755) == 0);
-        not = strappenda(template, "/not");
+        not = strjoina(template, "/not");
 
         assert_se(lookup_paths_init(&lp, running_as, personal, NULL, exists, not, not) == 0);
 
index 1512ae2..4f9f5c1 100644 (file)
@@ -47,7 +47,7 @@ static int setup_test(Manager **m) {
         assert_se(manager_startup(tmp, NULL, NULL) >= 0);
 
         STRV_FOREACH(test_path, tests_path) {
-               rm_rf_dangerous(strappenda("/tmp/test-path_", *test_path), false, true, false);
+               rm_rf_dangerous(strjoina("/tmp/test-path_", *test_path), false, true, false);
         }
 
         *m = tmp;
@@ -201,7 +201,7 @@ static void test_path_directorynotempty(Manager *m) {
         assert_se(access(test_path, F_OK) < 0);
 
         assert_se(mkdir_p(test_path, 0755) >= 0);
-        assert_se(touch(strappenda(test_path, "test_file")) >= 0);
+        assert_se(touch(strjoina(test_path, "test_file")) >= 0);
 
         check_stop_unlink(m, unit, test_path, NULL);
 }
index 84050c6..4b72c4a 100644 (file)
@@ -30,7 +30,7 @@
 
 int main(int argc, char** argv) {
         const char *p = argv[1] ?: "/tmp";
-        char *pattern = strappenda(p, "/systemd-test-XXXXXX");
+        char *pattern = strjoina(p, "/systemd-test-XXXXXX");
         _cleanup_close_ int fd, fd2;
         _cleanup_free_ char *cmd, *cmd2;
 
index f2b7038..804f522 100644 (file)
@@ -1072,17 +1072,29 @@ static void test_strshorten(void) {
         assert_se(strlen(strshorten(s, 0)) == 0);
 }
 
-static void test_strappenda(void) {
+static void test_strjoina(void) {
         char *actual;
 
-        actual = strappenda("", "foo", "bar");
+        actual = strjoina("", "foo", "bar");
         assert_se(streq(actual, "foobar"));
 
-        actual = strappenda("foo", "bar", "baz");
+        actual = strjoina("foo", "bar", "baz");
         assert_se(streq(actual, "foobarbaz"));
 
-        actual = strappenda("foo", "", "bar", "baz");
+        actual = strjoina("foo", "", "bar", "baz");
         assert_se(streq(actual, "foobarbaz"));
+
+        actual = strjoina("foo");
+        assert_se(streq(actual, "foo"));
+
+        actual = strjoina(NULL);
+        assert_se(streq(actual, ""));
+
+        actual = strjoina(NULL, "foo");
+        assert_se(streq(actual, ""));
+
+        actual = strjoina("foo", NULL, "bar");
+        assert_se(streq(actual, "foo"));
 }
 
 static void test_is_symlink(void) {
@@ -1231,13 +1243,13 @@ static void test_execute_directory(void) {
         assert_se(mkdtemp(template_lo));
         assert_se(mkdtemp(template_hi));
 
-        name = strappenda(template_lo, "/script");
-        name2 = strappenda(template_hi, "/script2");
-        name3 = strappenda(template_lo, "/useless");
-        overridden = strappenda(template_lo, "/overridden");
-        override = strappenda(template_hi, "/overridden");
-        masked = strappenda(template_lo, "/masked");
-        mask = strappenda(template_hi, "/masked");
+        name = strjoina(template_lo, "/script");
+        name2 = strjoina(template_hi, "/script2");
+        name3 = strjoina(template_lo, "/useless");
+        overridden = strjoina(template_lo, "/overridden");
+        override = strjoina(template_hi, "/overridden");
+        masked = strjoina(template_lo, "/masked");
+        mask = strjoina(template_hi, "/masked");
 
         assert_se(write_string_file(name, "#!/bin/sh\necho 'Executing '$0\ntouch $(dirname $0)/it_works") == 0);
         assert_se(write_string_file(name2, "#!/bin/sh\necho 'Executing '$0\ntouch $(dirname $0)/it_works2") == 0);
@@ -1562,7 +1574,7 @@ int main(int argc, char *argv[]) {
         test_read_one_char();
         test_ignore_signals();
         test_strshorten();
-        test_strappenda();
+        test_strjoina();
         test_is_symlink();
         test_pid_is_unwaited();
         test_pid_is_alive();
index b4405ce..bdf6512 100644 (file)
@@ -385,7 +385,7 @@ static bool wall_tty_match(const char *path) {
         _cleanup_free_ char *p = NULL;
 
         if (!path_is_absolute(path))
-                path = strappenda("/dev/", path);
+                path = strjoina("/dev/", path);
 
         r = lstat(path, &st);
         if (r < 0)
index c310111..37ff1b8 100644 (file)
@@ -153,7 +153,7 @@ static bool is_pci_multifunction(struct udev_device *dev) {
         const char *filename;
         uint8_t config[64];
 
-        filename = strappenda(udev_device_get_syspath(dev), "/config");
+        filename = strjoina(udev_device_get_syspath(dev), "/config");
         f = fopen(filename, "re");
         if (!f)
                 return false;
index 37e80c3..3f0e45e 100644 (file)
@@ -25,7 +25,7 @@ struct udev_device *find_device(struct udev *udev,
         assert(id);
 
         if (prefix && !startswith(id, prefix))
-                id = strappenda(prefix, id);
+                id = strjoina(prefix, id);
 
         if (startswith(id, "/dev/")) {
                 struct stat statbuf;