summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-02-03 02:05:59 +0100
committerLennart Poettering <lennart@poettering.net>2015-02-03 02:05:59 +0100
commit63c372cb9df3bee01e3bf8cd7f96f336bddda846 (patch)
treebf4d1b6e41f72927a2b58e7dd21daa0c496aaa96 /src/core
parent44de0efc6e406515fc1cf8b95d9655d0d7f7ffff (diff)
util: rework strappenda(), and rename it strjoina()
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.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/busname.c2
-rw-r--r--src/core/dbus-cgroup.c2
-rw-r--r--src/core/execute.c6
-rw-r--r--src/core/machine-id-setup.c8
-rw-r--r--src/core/manager.c3
-rw-r--r--src/core/mount.c2
-rw-r--r--src/core/namespace.c22
-rw-r--r--src/core/service.c8
-rw-r--r--src/core/socket.c4
-rw-r--r--src/core/swap.c2
-rw-r--r--src/core/unit.c2
11 files changed, 30 insertions, 31 deletions
diff --git a/src/core/busname.c b/src/core/busname.c
index ca9ceb8c3c..bc3a2bcb78 100644
--- a/src/core/busname.c
+++ b/src/core/busname.c
@@ -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;
diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c
index db998345eb..4a9df06016 100644
--- a/src/core/dbus-cgroup.c
+++ b/src/core/dbus-cgroup.c
@@ -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);
}
diff --git a/src/core/execute.c b/src/core/execute.c
index 19d3ec0da9..874cdc7efe 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -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,
diff --git a/src/core/machine-id-setup.c b/src/core/machine-id-setup.c
index 7e0aee6a75..d00a53246f 100644
--- a/src/core/machine-id-setup.c
+++ b/src/core/machine-id-setup.c
@@ -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);
}
diff --git a/src/core/manager.c b/src/core/manager.c
index 0b24cddc5f..5fba0043e4 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -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?
diff --git a/src/core/mount.c b/src/core/mount.c
index a0b5fda9cb..f3977e62de 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -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";
diff --git a/src/core/namespace.c b/src/core/namespace.c
index 4b8dbdd0d8..4fecd32363 100644
--- a/src/core/namespace.c
+++ b/src/core/namespace.c
@@ -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);
diff --git a/src/core/service.c b/src/core/service.c
index 15a2ed7f7e..15e29be149 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -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);
}
diff --git a/src/core/socket.c b/src/core/socket.c
index 85f7f16e15..d3dabc85f2 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -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"
diff --git a/src/core/swap.c b/src/core/swap.c
index 4fbabda568..6997921fde 100644
--- a/src/core/swap.c
+++ b/src/core/swap.c
@@ -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)
diff --git a/src/core/unit.c b/src/core/unit.c
index c3433b2c5d..2f95737da0 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -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"