summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-10-23 11:43:27 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-10-23 11:43:27 -0400
commit605405c6cc934466951b0c6bad5a9553620bcb08 (patch)
treeaf4eb757a0508374d581f746e3ce6a3ca5606dbb /src/core
parent3c5d7c978c5f5e6fcc1d3175bb22dd1b3477f4b4 (diff)
tree-wide: drop NULL sentinel from strjoin
This makes strjoin and strjoina more similar and avoids the useless final argument. spatch -I . -I ./src -I ./src/basic -I ./src/basic -I ./src/shared -I ./src/shared -I ./src/network -I ./src/locale -I ./src/login -I ./src/journal -I ./src/journal -I ./src/timedate -I ./src/timesync -I ./src/nspawn -I ./src/resolve -I ./src/resolve -I ./src/systemd -I ./src/core -I ./src/core -I ./src/libudev -I ./src/udev -I ./src/udev/net -I ./src/udev -I ./src/libsystemd/sd-bus -I ./src/libsystemd/sd-event -I ./src/libsystemd/sd-login -I ./src/libsystemd/sd-netlink -I ./src/libsystemd/sd-network -I ./src/libsystemd/sd-hwdb -I ./src/libsystemd/sd-device -I ./src/libsystemd/sd-id128 -I ./src/libsystemd-network --sp-file coccinelle/strjoin.cocci --in-place $(git ls-files src/*.c) git grep -e '\bstrjoin\b.*NULL' -l|xargs sed -i -r 's/strjoin\((.*), NULL\)/strjoin(\1)/' This might have missed a few cases (spatch has a really hard time dealing with _cleanup_ macros), but that's no big issue, they can always be fixed later.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/cgroup.c7
-rw-r--r--src/core/dbus-execute.c2
-rw-r--r--src/core/dbus-unit.c6
-rw-r--r--src/core/device.c2
-rw-r--r--src/core/execute.c10
-rw-r--r--src/core/locale-setup.c2
-rw-r--r--src/core/manager.c2
-rw-r--r--src/core/namespace.c2
-rw-r--r--src/core/service.c2
-rw-r--r--src/core/timer.c4
-rw-r--r--src/core/unit.c4
11 files changed, 22 insertions, 21 deletions
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
index 09bbe038e9..bd6248406f 100644
--- a/src/core/cgroup.c
+++ b/src/core/cgroup.c
@@ -1201,9 +1201,10 @@ char *unit_default_cgroup_path(Unit *u) {
return NULL;
if (slice)
- return strjoin(u->manager->cgroup_root, "/", slice, "/", escaped, NULL);
+ return strjoin(u->manager->cgroup_root, "/", slice, "/",
+ escaped);
else
- return strjoin(u->manager->cgroup_root, "/", escaped, NULL);
+ return strjoin(u->manager->cgroup_root, "/", escaped);
}
int unit_set_cgroup_path(Unit *u, const char *path) {
@@ -1643,7 +1644,7 @@ static int unit_watch_pids_in_path(Unit *u, const char *path) {
while ((r = cg_read_subgroup(d, &fn)) > 0) {
_cleanup_free_ char *p = NULL;
- p = strjoin(path, "/", fn, NULL);
+ p = strjoin(path, "/", fn);
free(fn);
if (!p)
diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c
index 1a7f770db1..03f23780c1 100644
--- a/src/core/dbus-execute.c
+++ b/src/core/dbus-execute.c
@@ -1368,7 +1368,7 @@ int bus_exec_context_set_transient_property(
if (mode != UNIT_CHECK) {
char *buf = NULL;
- buf = strjoin(b ? "-" : "", path, NULL);
+ buf = strjoin(b ? "-" : "", path);
if (!buf)
return -ENOMEM;
diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c
index 245912fc0f..6948daf682 100644
--- a/src/core/dbus-unit.c
+++ b/src/core/dbus-unit.c
@@ -484,7 +484,7 @@ int bus_unit_method_start_generic(
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Job mode %s invalid", smode);
if (reload_if_possible)
- verb = strjoin("reload-or-", job_type_to_string(job_type), NULL);
+ verb = strjoin("reload-or-", job_type_to_string(job_type));
else
verb = strdup(job_type_to_string(job_type));
if (!verb)
@@ -986,7 +986,7 @@ static int append_cgroup(sd_bus_message *reply, const char *p, Set *pids) {
if (r == 0)
break;
- j = strjoin(p, "/", g, NULL);
+ j = strjoin(p, "/", g);
if (!j)
return -ENOMEM;
@@ -1365,7 +1365,7 @@ static int bus_unit_set_transient_property(
if (r < 0)
return r;
- label = strjoin(name, "-", other, NULL);
+ label = strjoin(name, "-", other);
if (!label)
return -ENOMEM;
diff --git a/src/core/device.c b/src/core/device.c
index 8a3e888e5e..bb10148223 100644
--- a/src/core/device.c
+++ b/src/core/device.c
@@ -239,7 +239,7 @@ static int device_update_description(Unit *u, struct udev_device *dev, const cha
if (label) {
_cleanup_free_ char *j;
- j = strjoin(model, " ", label, NULL);
+ j = strjoin(model, " ", label);
if (j)
r = unit_set_description(u, j);
else
diff --git a/src/core/execute.c b/src/core/execute.c
index 1b7b4a928d..23a702e93e 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -1630,7 +1630,7 @@ static int build_environment(
if (!joined)
return -ENOMEM;
- x = strjoin("LISTEN_FDNAMES=", joined, NULL);
+ x = strjoin("LISTEN_FDNAMES=", joined);
if (!x)
return -ENOMEM;
our_env[n_env++] = x;
@@ -1737,7 +1737,7 @@ static int build_pass_environment(const ExecContext *c, char ***ret) {
v = getenv(*i);
if (!v)
continue;
- x = strjoin(*i, "=", v, NULL);
+ x = strjoin(*i, "=", v);
if (!x)
return -ENOMEM;
if (!GREEDY_REALLOC(pass_env, n_bufsize, n_env + 2))
@@ -1951,7 +1951,7 @@ static int setup_runtime_directory(
STRV_FOREACH(rt, context->runtime_directory) {
_cleanup_free_ char *p;
- p = strjoin(params->runtime_prefix, "/", *rt, NULL);
+ p = strjoin(params->runtime_prefix, "/", *rt);
if (!p)
return -ENOMEM;
@@ -2027,7 +2027,7 @@ static int compile_read_write_paths(
STRV_FOREACH(rt, context->runtime_directory) {
char *s;
- s = strjoin(params->runtime_prefix, "/", *rt, NULL);
+ s = strjoin(params->runtime_prefix, "/", *rt);
if (!s)
return -ENOMEM;
@@ -3006,7 +3006,7 @@ int exec_context_destroy_runtime_directory(ExecContext *c, const char *runtime_p
STRV_FOREACH(i, c->runtime_directory) {
_cleanup_free_ char *p;
- p = strjoin(runtime_prefix, "/", *i, NULL);
+ p = strjoin(runtime_prefix, "/", *i);
if (!p)
return -ENOMEM;
diff --git a/src/core/locale-setup.c b/src/core/locale-setup.c
index ccf61d29fb..fdd847ee8b 100644
--- a/src/core/locale-setup.c
+++ b/src/core/locale-setup.c
@@ -87,7 +87,7 @@ int locale_setup(char ***environment) {
if (!variables[i])
continue;
- s = strjoin(locale_variable_to_string(i), "=", variables[i], NULL);
+ s = strjoin(locale_variable_to_string(i), "=", variables[i]);
if (!s) {
r = -ENOMEM;
goto finish;
diff --git a/src/core/manager.c b/src/core/manager.c
index 0549f5ef1b..fa02389167 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -1196,7 +1196,7 @@ static void manager_build_unit_path_cache(Manager *m) {
FOREACH_DIRENT(de, d, r = -errno; goto fail) {
char *p;
- p = strjoin(streq(*i, "/") ? "" : *i, "/", de->d_name, NULL);
+ p = strjoin(streq(*i, "/") ? "" : *i, "/", de->d_name);
if (!p) {
r = -ENOMEM;
goto fail;
diff --git a/src/core/namespace.c b/src/core/namespace.c
index 1195e9a854..db9a7aa5e7 100644
--- a/src/core/namespace.c
+++ b/src/core/namespace.c
@@ -909,7 +909,7 @@ static int setup_one_tmp_dir(const char *id, const char *prefix, char **path) {
if (r < 0)
return r;
- x = strjoin(prefix, "/systemd-private-", sd_id128_to_string(boot_id, bid), "-", id, "-XXXXXX", NULL);
+ x = strjoin(prefix, "/systemd-private-", sd_id128_to_string(boot_id, bid), "-", id, "-XXXXXX");
if (!x)
return -ENOMEM;
diff --git a/src/core/service.c b/src/core/service.c
index 53c26984ca..5a9b01dadb 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -3260,7 +3260,7 @@ int service_set_socket_fd(Service *s, int fd, Socket *sock, bool selinux_context
if (UNIT(s)->description) {
_cleanup_free_ char *a;
- a = strjoin(UNIT(s)->description, " (", peer, ")", NULL);
+ a = strjoin(UNIT(s)->description, " (", peer, ")");
if (!a)
return -ENOMEM;
diff --git a/src/core/timer.c b/src/core/timer.c
index 2469a517ea..c6b28dd9c5 100644
--- a/src/core/timer.c
+++ b/src/core/timer.c
@@ -147,7 +147,7 @@ static int timer_setup_persistent(Timer *t) {
e = getenv("XDG_DATA_HOME");
if (e)
- t->stamp_path = strjoin(e, "/systemd/timers/stamp-", UNIT(t)->id, NULL);
+ t->stamp_path = strjoin(e, "/systemd/timers/stamp-", UNIT(t)->id);
else {
_cleanup_free_ char *h = NULL;
@@ -156,7 +156,7 @@ static int timer_setup_persistent(Timer *t) {
if (r < 0)
return log_unit_error_errno(UNIT(t), r, "Failed to determine home directory: %m");
- t->stamp_path = strjoin(h, "/.local/share/systemd/timers/stamp-", UNIT(t)->id, NULL);
+ t->stamp_path = strjoin(h, "/.local/share/systemd/timers/stamp-", UNIT(t)->id);
}
}
diff --git a/src/core/unit.c b/src/core/unit.c
index 2fa397bd41..14e1d7d20d 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -2469,7 +2469,7 @@ int unit_set_default_slice(Unit *u) {
return -ENOMEM;
if (MANAGER_IS_SYSTEM(u->manager))
- b = strjoin("system-", escaped, ".slice", NULL);
+ b = strjoin("system-", escaped, ".slice");
else
b = strappend(escaped, ".slice");
if (!b)
@@ -3629,7 +3629,7 @@ int unit_make_transient(Unit *u) {
if (!UNIT_VTABLE(u)->can_transient)
return -EOPNOTSUPP;
- path = strjoin(u->manager->lookup_paths.transient, "/", u->id, NULL);
+ path = strjoin(u->manager->lookup_paths.transient, "/", u->id);
if (!path)
return -ENOMEM;