1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-22 13:33:56 +03:00

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.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2016-10-23 11:43:27 -04:00
parent 3c5d7c978c
commit 605405c6cc
89 changed files with 215 additions and 194 deletions

16
coccinelle/strjoin.cocci Normal file
View File

@ -0,0 +1,16 @@
@@
expression list args;
@@
- strjoin(args, NULL);
+ strjoin(args);
@@
expression t;
expression list args;
@@
- t = strjoin(args, NULL);
+ t = strjoin(args);
@@
expression list args;
@@
- return strjoin(args, NULL);
+ return strjoin(args);

View File

@ -357,9 +357,9 @@ int main(int argc, char *argv[]) {
return EXIT_FAILURE;
}
saved = strjoin("/var/lib/systemd/backlight/", escaped_path_id, ":", escaped_ss, ":", escaped_sysname, NULL);
saved = strjoin("/var/lib/systemd/backlight/", escaped_path_id, ":", escaped_ss, ":", escaped_sysname);
} else
saved = strjoin("/var/lib/systemd/backlight/", escaped_ss, ":", escaped_sysname, NULL);
saved = strjoin("/var/lib/systemd/backlight/", escaped_ss, ":", escaped_sysname);
if (!saved) {
log_oom();

View File

@ -1642,7 +1642,7 @@ static int subvol_snapshot_children(int old_fd, int new_fd, const char *subvolum
if (old_child_fd < 0)
return -errno;
np = strjoin(subvolume, "/", ino_args.name, NULL);
np = strjoin(subvolume, "/", ino_args.name);
if (!np)
return -ENOMEM;

View File

@ -345,7 +345,7 @@ int cg_kill_recursive(
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)
return -ENOMEM;
@ -479,7 +479,7 @@ int cg_migrate_recursive(
while ((r = cg_read_subgroup(d, &fn)) > 0) {
_cleanup_free_ char *p = NULL;
p = strjoin(pfrom, "/", fn, NULL);
p = strjoin(pfrom, "/", fn);
free(fn);
if (!p)
return -ENOMEM;
@ -562,11 +562,11 @@ static int join_path_legacy(const char *controller, const char *path, const char
if (isempty(path) && isempty(suffix))
t = strappend("/sys/fs/cgroup/", dn);
else if (isempty(path))
t = strjoin("/sys/fs/cgroup/", dn, "/", suffix, NULL);
t = strjoin("/sys/fs/cgroup/", dn, "/", suffix);
else if (isempty(suffix))
t = strjoin("/sys/fs/cgroup/", dn, "/", path, NULL);
t = strjoin("/sys/fs/cgroup/", dn, "/", path);
else
t = strjoin("/sys/fs/cgroup/", dn, "/", path, "/", suffix, NULL);
t = strjoin("/sys/fs/cgroup/", dn, "/", path, "/", suffix);
if (!t)
return -ENOMEM;
@ -586,7 +586,7 @@ static int join_path_unified(const char *path, const char *suffix, char **fs) {
else if (isempty(suffix))
t = strappend("/sys/fs/cgroup/", path);
else
t = strjoin("/sys/fs/cgroup/", path, "/", suffix, NULL);
t = strjoin("/sys/fs/cgroup/", path, "/", suffix);
if (!t)
return -ENOMEM;
@ -613,7 +613,7 @@ int cg_get_path(const char *controller, const char *path, const char *suffix, ch
else if (!path)
t = strdup(suffix);
else
t = strjoin(path, "/", suffix, NULL);
t = strjoin(path, "/", suffix);
if (!t)
return -ENOMEM;
@ -1145,7 +1145,7 @@ int cg_is_empty_recursive(const char *controller, 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)
return -ENOMEM;

View File

@ -60,7 +60,7 @@ static int files_add(Hashmap *h, const char *root, const char *path, const char
if (!dirent_is_file_with_suffix(de, suffix))
continue;
p = strjoin(dirpath, "/", de->d_name, NULL);
p = strjoin(dirpath, "/", de->d_name);
if (!p)
return -ENOMEM;

View File

@ -676,7 +676,7 @@ static int load_env_file_push(
return -EINVAL;
}
p = strjoin(key, "=", strempty(value), NULL);
p = strjoin(key, "=", strempty(value));
if (!p)
return -ENOMEM;
@ -963,9 +963,9 @@ static int search_and_fopen_internal(const char *path, const char *mode, const c
FILE *f;
if (root)
p = strjoin(root, *i, "/", path, NULL);
p = strjoin(root, *i, "/", path);
else
p = strjoin(*i, "/", path, NULL);
p = strjoin(*i, "/", path);
if (!p)
return -ENOMEM;

View File

@ -742,7 +742,7 @@ int chase_symlinks(const char *path, const char *_root, char **ret) {
/* A relative destination. If so, this is what we'll prefix what's left to do with what
* we just read, and start the loop again, but remain in the current directory. */
joined = strjoin("/", destination, todo, NULL);
joined = strjoin("/", destination, todo);
if (!joined)
return -ENOMEM;

View File

@ -641,7 +641,7 @@ static char* mount_flags_to_string(long unsigned flags) {
FLAG(MS_I_VERSION),
FLAG(MS_STRICTATIME),
FLAG(MS_LAZYTIME),
y, NULL);
y);
if (!x)
return NULL;
if (!y)

View File

@ -83,7 +83,7 @@ char *path_make_absolute(const char *p, const char *prefix) {
if (path_is_absolute(p) || !prefix)
return strdup(p);
return strjoin(prefix, "/", p, NULL);
return strjoin(prefix, "/", p);
}
int path_make_absolute_cwd(const char *p, char **ret) {
@ -104,7 +104,7 @@ int path_make_absolute_cwd(const char *p, char **ret) {
if (!cwd)
return negative_errno();
c = strjoin(cwd, "/", p, NULL);
c = strjoin(cwd, "/", p);
}
if (!c)
return -ENOMEM;
@ -444,13 +444,11 @@ char* path_join(const char *root, const char *path, const char *rest) {
return strjoin(root, endswith(root, "/") ? "" : "/",
path[0] == '/' ? path+1 : path,
rest ? (endswith(path, "/") ? "" : "/") : NULL,
rest && rest[0] == '/' ? rest+1 : rest,
NULL);
rest && rest[0] == '/' ? rest+1 : rest);
else
return strjoin(path,
rest ? (endswith(path, "/") ? "" : "/") : NULL,
rest && rest[0] == '/' ? rest+1 : rest,
NULL);
rest && rest[0] == '/' ? rest+1 : rest);
}
int find_binary(const char *name, char **ret) {
@ -494,7 +492,7 @@ int find_binary(const char *name, char **ret) {
if (!path_is_absolute(element))
continue;
j = strjoin(element, "/", name, NULL);
j = strjoin(element, "/", name);
if (!j)
return -ENOMEM;

View File

@ -236,14 +236,14 @@ int get_process_cmdline(pid_t pid, size_t max_length, bool comm_fallback, char *
return h;
if (max_length == 0)
r = strjoin("[", t, "]", NULL);
r = strjoin("[", t, "]");
else {
size_t l;
l = strlen(t);
if (l + 3 <= max_length)
r = strjoin("[", t, "]", NULL);
r = strjoin("[", t, "]");
else if (max_length <= 6) {
r = new(char, max_length);
@ -263,7 +263,7 @@ int get_process_cmdline(pid_t pid, size_t max_length, bool comm_fallback, char *
e--;
*e = 0;
r = strjoin("[", t, "...]", NULL);
r = strjoin("[", t, "...]");
}
}
if (!r)

View File

@ -218,7 +218,7 @@ char *strappend(const char *s, const char *suffix) {
return strnappend(s, suffix, suffix ? strlen(suffix) : 0);
}
char *strjoin(const char *x, ...) {
char *strjoin_real(const char *x, ...) {
va_list ap;
size_t l;
char *r, *p;

View File

@ -116,7 +116,8 @@ const char* split(const char **state, size_t *l, const char *separator, bool quo
char *strappend(const char *s, const char *suffix);
char *strnappend(const char *s, const char *suffix, size_t length);
char *strjoin(const char *x, ...) _sentinel_;
char *strjoin_real(const char *x, ...) _sentinel_;
#define strjoin(a, ...) strjoin_real((a), __VA_ARGS__, NULL)
#define strjoina(a, ...) \
({ \

View File

@ -273,7 +273,7 @@ int unit_name_build(const char *prefix, const char *instance, const char *suffix
if (!instance)
s = strappend(prefix, suffix);
else
s = strjoin(prefix, "@", instance, suffix, NULL);
s = strjoin(prefix, "@", instance, suffix);
if (!s)
return -ENOMEM;
@ -554,7 +554,7 @@ int unit_name_from_path_instance(const char *prefix, const char *path, const cha
if (r < 0)
return r;
s = strjoin(prefix, "@", p, suffix, NULL);
s = strjoin(prefix, "@", p, suffix);
if (!s)
return -ENOMEM;

View File

@ -131,7 +131,7 @@ static int do_execute(char **directories, usec_t timeout, char *argv[]) {
if (r < 0)
return log_oom();
path = strjoin(*directory, "/", de->d_name, NULL);
path = strjoin(*directory, "/", de->d_name);
if (!path)
return log_oom();

View File

@ -223,7 +223,7 @@ int main(int argc, char *argv[]) {
controller = c ?: SYSTEMD_CGROUP_CONTROLLER;
if (p) {
j = strjoin(root, "/", p, NULL);
j = strjoin(root, "/", p);
if (!j) {
r = log_oom();
goto finish;

View File

@ -431,7 +431,7 @@ static int refresh_one(
if (r == 0)
break;
p = strjoin(path, "/", fn, NULL);
p = strjoin(path, "/", fn);
if (!p)
return -ENOMEM;

View File

@ -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)

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);
}
}

View File

@ -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;

View File

@ -729,7 +729,10 @@ static int submit_coredump(
r = coredump_make_stack_trace(coredump_fd, context[CONTEXT_EXE], &stacktrace);
if (r >= 0)
core_message = strjoin("MESSAGE=Process ", context[CONTEXT_PID], " (", context[CONTEXT_COMM], ") of user ", context[CONTEXT_UID], " dumped core.\n\n", stacktrace, NULL);
core_message = strjoin("MESSAGE=Process ", context[CONTEXT_PID],
" (", context[CONTEXT_COMM], ") of user ",
context[CONTEXT_UID], " dumped core.\n\n",
stacktrace);
else if (r == -EINVAL)
log_warning("Failed to generate stack trace: %s", dwfl_errmsg(dwfl_errno()));
else
@ -741,7 +744,9 @@ static int submit_coredump(
if (!core_message)
#endif
log:
core_message = strjoin("MESSAGE=Process ", context[CONTEXT_PID], " (", context[CONTEXT_COMM], ") of user ", context[CONTEXT_UID], " dumped core.", NULL);
core_message = strjoin("MESSAGE=Process ", context[CONTEXT_PID], " (",
context[CONTEXT_COMM], ") of user ",
context[CONTEXT_UID], " dumped core.");
if (core_message)
IOVEC_SET_STRING(iovec[n_iovec++], core_message);

View File

@ -108,7 +108,7 @@ static int add_match(Set *set, const char *match) {
else
prefix = "COREDUMP_COMM=";
pattern = strjoin(prefix, match, NULL);
pattern = strjoin(prefix, match);
if (!pattern) {
r = -ENOMEM;
goto fail;
@ -667,7 +667,7 @@ static int save_core(sd_journal *j, FILE *file, char **path, bool *unlink_temp)
if (r < 0)
return log_error_errno(r, "Failed to acquire temporary directory path: %m");
temp = strjoin(vt, "/coredump-XXXXXX", NULL);
temp = strjoin(vt, "/coredump-XXXXXX");
if (!temp)
return log_oom();

View File

@ -86,7 +86,7 @@ static int create_disk(
if (r < 0)
return log_error_errno(r, "Failed to generate unit name: %m");
p = strjoin(arg_dest, "/", n, NULL);
p = strjoin(arg_dest, "/", n);
if (!p)
return log_oom();
@ -188,7 +188,7 @@ static int create_disk(
if (!noauto) {
to = strjoin(arg_dest, "/", d, ".wants/", n, NULL);
to = strjoin(arg_dest, "/", d, ".wants/", n);
if (!to)
return log_oom();
@ -198,9 +198,9 @@ static int create_disk(
free(to);
if (!nofail)
to = strjoin(arg_dest, "/cryptsetup.target.requires/", n, NULL);
to = strjoin(arg_dest, "/cryptsetup.target.requires/", n);
else
to = strjoin(arg_dest, "/cryptsetup.target.wants/", n, NULL);
to = strjoin(arg_dest, "/cryptsetup.target.wants/", n);
if (!to)
return log_oom();
@ -210,7 +210,7 @@ static int create_disk(
}
free(to);
to = strjoin(arg_dest, "/dev-mapper-", e, ".device.requires/", n, NULL);
to = strjoin(arg_dest, "/dev-mapper-", e, ".device.requires/", n);
if (!to)
return log_oom();
@ -220,7 +220,7 @@ static int create_disk(
if (!noauto && !nofail) {
_cleanup_free_ char *dmname;
dmname = strjoin("dev-mapper-", e, ".device", NULL);
dmname = strjoin("dev-mapper-", e, ".device");
if (!dmname)
return log_oom();

View File

@ -113,7 +113,7 @@ static int generate_mask_symlinks(void) {
STRV_FOREACH(u, arg_mask) {
_cleanup_free_ char *p = NULL;
p = strjoin(arg_dest, "/", *u, NULL);
p = strjoin(arg_dest, "/", *u);
if (!p)
return log_oom();
@ -136,7 +136,7 @@ static int generate_wants_symlinks(void) {
STRV_FOREACH(u, arg_wants) {
_cleanup_free_ char *p = NULL, *f = NULL;
p = strjoin(arg_dest, "/", arg_default_unit, ".wants/", *u, NULL);
p = strjoin(arg_dest, "/", arg_default_unit, ".wants/", *u);
if (!p)
return log_oom();

View File

@ -214,7 +214,7 @@ static int enumerate_dir_d(Hashmap *top, Hashmap *bottom, Hashmap *drops, const
assert(!endswith(drop, "/"));
path = strjoin(toppath, "/", drop, NULL);
path = strjoin(toppath, "/", drop);
if (!path)
return -ENOMEM;
@ -242,7 +242,7 @@ static int enumerate_dir_d(Hashmap *top, Hashmap *bottom, Hashmap *drops, const
if (!endswith(*file, ".conf"))
continue;
p = strjoin(path, "/", *file, NULL);
p = strjoin(path, "/", *file);
if (!p)
return -ENOMEM;
d = p + strlen(toppath) + 1;
@ -330,7 +330,7 @@ static int enumerate_dir(Hashmap *top, Hashmap *bottom, Hashmap *drops, const ch
if (!dirent_is_file(de))
continue;
p = strjoin(path, "/", de->d_name, NULL);
p = strjoin(path, "/", de->d_name);
if (!p)
return -ENOMEM;
@ -383,7 +383,7 @@ static int process_suffix(const char *suffix, const char *onlyprefix) {
NULSTR_FOREACH(p, prefixes) {
_cleanup_free_ char *t = NULL;
t = strjoin(p, "/", suffix, NULL);
t = strjoin(p, "/", suffix);
if (!t) {
r = -ENOMEM;
goto finish;

View File

@ -191,7 +191,7 @@ int main(int argc, char *argv[]) {
} else if (arg_suffix) {
char *x;
x = strjoin(e, ".", arg_suffix, NULL);
x = strjoin(e, ".", arg_suffix);
if (!x) {
r = log_oom();
goto finish;

View File

@ -80,7 +80,7 @@ static int add_swap(
if (r < 0)
return log_error_errno(r, "Failed to generate unit name: %m");
unit = strjoin(arg_dest, "/", name, NULL);
unit = strjoin(arg_dest, "/", name);
if (!unit)
return log_oom();
@ -275,7 +275,7 @@ static int add_mount(
if (r < 0)
return log_error_errno(r, "Failed to generate unit name: %m");
unit = strjoin(arg_dest, "/", name, NULL);
unit = strjoin(arg_dest, "/", name);
if (!unit)
return log_oom();
@ -335,7 +335,7 @@ static int add_mount(
return log_error_errno(r, "Failed to write unit file %s: %m", unit);
if (!noauto && !automount) {
lnk = strjoin(arg_dest, "/", post, nofail ? ".wants/" : ".requires/", name, NULL);
lnk = strjoin(arg_dest, "/", post, nofail ? ".wants/" : ".requires/", name);
if (!lnk)
return log_oom();
@ -349,7 +349,7 @@ static int add_mount(
if (r < 0)
return log_error_errno(r, "Failed to generate unit name: %m");
automount_unit = strjoin(arg_dest, "/", automount_name, NULL);
automount_unit = strjoin(arg_dest, "/", automount_name);
if (!automount_unit)
return log_oom();
@ -391,7 +391,7 @@ static int add_mount(
return log_error_errno(r, "Failed to write unit file %s: %m", automount_unit);
free(lnk);
lnk = strjoin(arg_dest, "/", post, nofail ? ".wants/" : ".requires/", automount_name, NULL);
lnk = strjoin(arg_dest, "/", post, nofail ? ".wants/" : ".requires/", automount_name);
if (!lnk)
return log_oom();
@ -619,7 +619,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
char *o;
o = arg_root_options ?
strjoin(arg_root_options, ",", value, NULL) :
strjoin(arg_root_options, ",", value) :
strdup(value);
if (!o)
return log_oom();
@ -641,7 +641,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
char *o;
o = arg_usr_options ?
strjoin(arg_usr_options, ",", value, NULL) :
strjoin(arg_usr_options, ",", value) :
strdup(value);
if (!o)
return log_oom();

View File

@ -76,7 +76,7 @@ static int add_cryptsetup(const char *id, const char *what, bool rw, char **devi
if (r < 0)
return log_error_errno(r, "Failed to generate unit name: %m");
p = strjoin(arg_dest, "/", n, NULL);
p = strjoin(arg_dest, "/", n);
if (!p)
return log_oom();
@ -111,7 +111,7 @@ static int add_cryptsetup(const char *id, const char *what, bool rw, char **devi
from = strjoina("../", n);
to = strjoin(arg_dest, "/", d, ".wants/", n, NULL);
to = strjoin(arg_dest, "/", d, ".wants/", n);
if (!to)
return log_oom();
@ -120,7 +120,7 @@ static int add_cryptsetup(const char *id, const char *what, bool rw, char **devi
return log_error_errno(errno, "Failed to create symlink %s: %m", to);
free(to);
to = strjoin(arg_dest, "/cryptsetup.target.requires/", n, NULL);
to = strjoin(arg_dest, "/cryptsetup.target.requires/", n);
if (!to)
return log_oom();
@ -129,7 +129,7 @@ static int add_cryptsetup(const char *id, const char *what, bool rw, char **devi
return log_error_errno(errno, "Failed to create symlink %s: %m", to);
free(to);
to = strjoin(arg_dest, "/dev-mapper-", e, ".device.requires/", n, NULL);
to = strjoin(arg_dest, "/dev-mapper-", e, ".device.requires/", n);
if (!to)
return log_oom();
@ -138,7 +138,7 @@ static int add_cryptsetup(const char *id, const char *what, bool rw, char **devi
return log_error_errno(errno, "Failed to create symlink %s: %m", to);
free(p);
p = strjoin(arg_dest, "/dev-mapper-", e, ".device.d/50-job-timeout-sec-0.conf", NULL);
p = strjoin(arg_dest, "/dev-mapper-", e, ".device.d/50-job-timeout-sec-0.conf");
if (!p)
return log_oom();
@ -194,7 +194,7 @@ static int add_mount(
if (r < 0)
return log_error_errno(r, "Failed to generate unit name: %m");
p = strjoin(arg_dest, "/", unit, NULL);
p = strjoin(arg_dest, "/", unit);
if (!p)
return log_oom();
@ -236,7 +236,7 @@ static int add_mount(
return log_error_errno(r, "Failed to write unit file %s: %m", p);
if (post) {
lnk = strjoin(arg_dest, "/", post, ".requires/", unit, NULL);
lnk = strjoin(arg_dest, "/", post, ".requires/", unit);
if (!lnk)
return log_oom();
@ -340,7 +340,7 @@ static int add_swap(const char *path) {
if (r < 0)
return log_error_errno(r, "Failed to generate unit name: %m");
unit = strjoin(arg_dest, "/", name, NULL);
unit = strjoin(arg_dest, "/", name);
if (!unit)
return log_oom();
@ -361,7 +361,7 @@ static int add_swap(const char *path) {
if (r < 0)
return log_error_errno(r, "Failed to write unit file %s: %m", unit);
lnk = strjoin(arg_dest, "/" SPECIAL_SWAP_TARGET ".wants/", name, NULL);
lnk = strjoin(arg_dest, "/" SPECIAL_SWAP_TARGET ".wants/", name);
if (!lnk)
return log_oom();
@ -393,7 +393,7 @@ static int add_automount(
assert(description);
if (options)
opt = strjoin(options, ",noauto", NULL);
opt = strjoin(options, ",noauto");
else
opt = strdup("noauto");
if (!opt)
@ -414,7 +414,7 @@ static int add_automount(
if (r < 0)
return log_error_errno(r, "Failed to generate unit name: %m");
p = strjoin(arg_dest, "/", unit, NULL);
p = strjoin(arg_dest, "/", unit);
if (!p)
return log_oom();
@ -438,7 +438,7 @@ static int add_automount(
if (r < 0)
return log_error_errno(r, "Failed to write unit file %s: %m", p);
lnk = strjoin(arg_dest, "/" SPECIAL_LOCAL_FS_TARGET ".wants/", unit, NULL);
lnk = strjoin(arg_dest, "/" SPECIAL_LOCAL_FS_TARGET ".wants/", unit);
if (!lnk)
return log_oom();
mkdir_parents_label(lnk, 0755);

View File

@ -56,7 +56,7 @@ static int process_resume(void) {
if (r < 0)
return log_error_errno(r, "Failed to generate unit name: %m");
lnk = strjoin(arg_dest, "/" SPECIAL_SYSINIT_TARGET ".wants/", name, NULL);
lnk = strjoin(arg_dest, "/" SPECIAL_SYSINIT_TARGET ".wants/", name);
if (!lnk)
return log_oom();

View File

@ -335,7 +335,7 @@ static int context_write_data_machine_info(Context *c) {
continue;
}
t = strjoin(name[p], "=", c->data[p], NULL);
t = strjoin(name[p], "=", c->data[p]);
if (!t)
return -ENOMEM;

View File

@ -669,7 +669,7 @@ static int hwdb_update(int argc, char *argv[], void *userdata) {
log_debug("strings dedup'ed: %8zu bytes (%8zu)",
trie->strings->dedup_len, trie->strings->dedup_count);
hwdb_bin = strjoin(arg_root, "/", arg_hwdb_bin_dir, "/hwdb.bin", NULL);
hwdb_bin = strjoin(arg_root, "/", arg_hwdb_bin_dir, "/hwdb.bin");
if (!hwdb_bin)
return -ENOMEM;

View File

@ -267,7 +267,7 @@ static int raw_import_open_disk(RawImport *i) {
assert(!i->temp_path);
assert(i->output_fd < 0);
i->final_path = strjoin(i->image_root, "/", i->local, ".raw", NULL);
i->final_path = strjoin(i->image_root, "/", i->local, ".raw");
if (!i->final_path)
return log_oom();

View File

@ -222,7 +222,7 @@ static int tar_import_fork_tar(TarImport *i) {
assert(!i->temp_path);
assert(i->tar_fd < 0);
i->final_path = strjoin(i->image_root, "/", i->local, NULL);
i->final_path = strjoin(i->image_root, "/", i->local);
if (!i->final_path)
return log_oom();

View File

@ -434,7 +434,7 @@ static int request_parse_arguments_iterator(
return MHD_YES;
}
p = strjoin(key, "=", strempty(value), NULL);
p = strjoin(key, "=", strempty(value));
if (!p) {
m->argument_parse_error = log_oom();
return MHD_NO;

View File

@ -438,7 +438,7 @@ static int setup_uploader(Uploader *u, const char *url, const char *state_file)
}
if (strchr(host, ':'))
u->url = strjoin(proto, url, "/upload", NULL);
u->url = strjoin(proto, url, "/upload");
else {
char *t;
size_t x;
@ -448,7 +448,7 @@ static int setup_uploader(Uploader *u, const char *url, const char *state_file)
while (x > 0 && t[x - 1] == '/')
t[x - 1] = '\0';
u->url = strjoin(proto, t, ":" STRINGIFY(DEFAULT_PORT), "/upload", NULL);
u->url = strjoin(proto, t, ":" STRINGIFY(DEFAULT_PORT), "/upload");
}
if (!u->url)
return log_oom();

View File

@ -192,7 +192,7 @@ static int add_matches_for_device(sd_journal *j, const char *devpath) {
continue;
}
match = strjoin("_KERNEL_DEVICE=+", subsys, ":", sysname, NULL);
match = strjoin("_KERNEL_DEVICE=+", subsys, ":", sysname);
if (!match)
return log_oom();

View File

@ -733,7 +733,7 @@ static int get_invocation_id(const char *cgroup_root, const char *slice, const c
if (!escaped)
return -ENOMEM;
p = strjoin(cgroup_root, "/", slice_path, "/", escaped, NULL);
p = strjoin(cgroup_root, "/", slice_path, "/", escaped);
if (!p)
return -ENOMEM;
@ -2053,8 +2053,8 @@ int server_init(Server *s) {
s->runtime_storage.name = "Runtime journal";
s->system_storage.name = "System journal";
s->runtime_storage.path = strjoin("/run/log/journal/", SERVER_MACHINE_ID(s), NULL);
s->system_storage.path = strjoin("/var/log/journal/", SERVER_MACHINE_ID(s), NULL);
s->runtime_storage.path = strjoin("/run/log/journal/", SERVER_MACHINE_ID(s));
s->system_storage.path = strjoin("/var/log/journal/", SERVER_MACHINE_ID(s));
if (!s->runtime_storage.path || !s->system_storage.path)
return -ENOMEM;

View File

@ -57,7 +57,7 @@ void server_forward_wall(
} else if (identifier) {
l = l_buf = strjoin(identifier, ": ", message, NULL);
l = l_buf = strjoin(identifier, ": ", message);
if (!l_buf) {
log_oom();
return;

View File

@ -405,7 +405,7 @@ static char *match_make_string(Match *m) {
return mfree(p);
if (p) {
k = strjoin(p, m->type == MATCH_OR_TERM ? " OR " : " AND ", t, NULL);
k = strjoin(p, m->type == MATCH_OR_TERM ? " OR " : " AND ", t);
free(p);
free(t);
@ -420,7 +420,7 @@ static char *match_make_string(Match *m) {
}
if (enclose) {
r = strjoin("(", p, ")", NULL);
r = strjoin("(", p, ")");
free(p);
return r;
}
@ -1416,7 +1416,7 @@ static int add_directory(sd_journal *j, const char *prefix, const char *dirname)
* and reenumerates directory contents */
if (dirname)
path = strjoin(prefix, "/", dirname, NULL);
path = strjoin(prefix, "/", dirname);
else
path = strdup(prefix);
if (!path) {

View File

@ -1649,7 +1649,7 @@ int bus_kernel_create_bus(const char *name, bool world, char **s) {
if (s) {
char *p;
p = strjoin("/sys/fs/kdbus/", n->str, "/bus", NULL);
p = strjoin("/sys/fs/kdbus/", n->str, "/bus");
if (!p) {
safe_close(fd);
return -ENOMEM;

View File

@ -285,7 +285,7 @@ static int parse_xml_node(Context *context, const char *prefix, unsigned n_depth
if (endswith(prefix, "/"))
node_path = strappend(prefix, name);
else
node_path = strjoin(prefix, "/", name, NULL);
node_path = strjoin(prefix, "/", name);
if (!node_path)
return log_oom();
}

View File

@ -1102,7 +1102,7 @@ static int monitor(sd_bus *bus, char *argv[], int (*dump)(sd_bus_message *m, FIL
return -EINVAL;
}
m = strjoin("sender='", *i, "'", NULL);
m = strjoin("sender='", *i, "'");
if (!m)
return log_oom();
@ -1111,7 +1111,7 @@ static int monitor(sd_bus *bus, char *argv[], int (*dump)(sd_bus_message *m, FIL
return bus_log_create_error(r);
free(m);
m = strjoin("destination='", *i, "'", NULL);
m = strjoin("destination='", *i, "'");
if (!m)
return log_oom();

View File

@ -1339,7 +1339,7 @@ int bus_set_address_system_remote(sd_bus *b, const char *host) {
return -ENOMEM;
}
b->address = strjoin("unixexec:path=ssh,argv1=-xT,argv2=", e, ",argv3=systemd-stdio-bridge", c, NULL);
b->address = strjoin("unixexec:path=ssh,argv1=-xT,argv2=", e, ",argv3=systemd-stdio-bridge", c);
if (!b->address)
return -ENOMEM;
@ -1387,7 +1387,7 @@ int bus_set_address_system_machine(sd_bus *b, const char *machine) {
if (!e)
return -ENOMEM;
b->address = strjoin("x-machine-kernel:machine=", e, ";x-machine-unix:machine=", e, NULL);
b->address = strjoin("x-machine-kernel:machine=", e, ";x-machine-unix:machine=", e);
if (!b->address)
return -ENOMEM;
@ -3470,7 +3470,7 @@ _public_ int sd_bus_path_encode(const char *prefix, const char *external_id, cha
if (!e)
return -ENOMEM;
ret = strjoin(prefix, "/", e, NULL);
ret = strjoin(prefix, "/", e);
if (!ret)
return -ENOMEM;

View File

@ -49,7 +49,7 @@ static int something_handler(sd_bus_message *m, void *userdata, sd_bus_error *er
r = sd_bus_message_read(m, "s", &s);
assert_se(r > 0);
n = strjoin("<<<", s, ">>>", NULL);
n = strjoin("<<<", s, ">>>");
assert_se(n);
free(c->something);

View File

@ -773,7 +773,7 @@ static int parent_crawl_children(sd_device_enumerator *enumerator, const char *p
if (dent->d_type != DT_DIR)
continue;
child = strjoin(path, "/", dent->d_name, NULL);
child = strjoin(path, "/", dent->d_name);
if (!child)
return -ENOMEM;

View File

@ -77,7 +77,7 @@ static int from_home_dir(const char *envname, const char *suffix, char **buffer,
if (endswith(h, "/"))
cc = strappend(h, suffix);
else
cc = strjoin(h, "/", suffix, NULL);
cc = strjoin(h, "/", suffix);
if (!cc)
return -ENOMEM;
@ -387,7 +387,7 @@ _public_ int sd_path_home(uint64_t type, const char *suffix, char **path) {
if (endswith(ret, "/"))
cc = strappend(ret, suffix);
else
cc = strjoin(ret, "/", suffix, NULL);
cc = strjoin(ret, "/", suffix);
free(buffer);
@ -455,7 +455,7 @@ static int search_from_environment(
if (endswith(e, "/"))
h = strappend(e, home_suffix);
else
h = strjoin(e, "/", home_suffix, NULL);
h = strjoin(e, "/", home_suffix);
if (!h) {
strv_free(l);
@ -621,7 +621,7 @@ _public_ int sd_path_search(uint64_t type, const char *suffix, char ***paths) {
if (endswith(*i, "/"))
*j = strappend(*i, suffix);
else
*j = strjoin(*i, "/", suffix, NULL);
*j = strjoin(*i, "/", suffix);
if (!*j) {
strv_free(l);

View File

@ -519,7 +519,7 @@ int find_converted_keymap(const char *x11_layout, const char *x11_variant, char
_cleanup_free_ char *n;
if (x11_variant)
n = strjoin(x11_layout, "-", x11_variant, NULL);
n = strjoin(x11_layout, "-", x11_variant);
else
n = strdup(x11_layout);
if (!n)
@ -529,8 +529,8 @@ int find_converted_keymap(const char *x11_layout, const char *x11_variant, char
_cleanup_free_ char *p = NULL, *pz = NULL;
bool uncompressed;
p = strjoin(dir, "xkb/", n, ".map", NULL);
pz = strjoin(dir, "xkb/", n, ".map.gz", NULL);
p = strjoin(dir, "xkb/", n, ".map");
pz = strjoin(dir, "xkb/", n, ".map.gz");
if (!p || !pz)
return -ENOMEM;

View File

@ -294,7 +294,7 @@ int inhibitor_create_fifo(Inhibitor *i) {
if (r < 0)
return r;
i->fifo_path = strjoin("/run/systemd/inhibit/", i->id, ".ref", NULL);
i->fifo_path = strjoin("/run/systemd/inhibit/", i->id, ".ref");
if (!i->fifo_path)
return -ENOMEM;

View File

@ -505,7 +505,7 @@ static int session_start_scope(Session *s) {
char *scope, *job = NULL;
const char *description;
scope = strjoin("session-", s->id, ".scope", NULL);
scope = strjoin("session-", s->id, ".scope");
if (!scope)
return log_oom();

View File

@ -186,7 +186,7 @@ static int export_legacy_dbus_address(
* daemons that spawn dbus-daemon, instead of forcing
* DBUS_SESSION_BUS_ADDRESS= here. */
s = strjoin(runtime, "/bus", NULL);
s = strjoin(runtime, "/bus");
if (!s)
goto error;

View File

@ -355,7 +355,7 @@ static int machine_start_scope(Machine *m, sd_bus_message *properties, sd_bus_er
if (!escaped)
return log_oom();
scope = strjoin("machine-", escaped, ".scope", NULL);
scope = strjoin("machine-", escaped, ".scope");
if (!scope)
return log_oom();

View File

@ -697,7 +697,7 @@ static int acquire_mount_where(struct udev_device *d) {
if (!filename_is_valid(escaped))
return 0;
arg_mount_where = strjoin("/run/media/system/", escaped, NULL);
arg_mount_where = strjoin("/run/media/system/", escaped);
} else
arg_mount_where = strdup(v);
@ -721,7 +721,7 @@ static int acquire_description(struct udev_device *d) {
label = udev_device_get_property_value(d, "ID_PART_ENTRY_NUMBER");
if (model && label)
arg_description = strjoin(model, " ", label, NULL);
arg_description = strjoin(model, " ", label);
else if (label)
arg_description = strdup(label);
else if (model)

View File

@ -208,9 +208,9 @@ static int tmpfs_patch_options(
char *t;
if (options)
t = strjoin(options, ",context=\"", selinux_apifs_context, "\"", NULL);
t = strjoin(options, ",context=\"", selinux_apifs_context, "\"");
else
t = strjoin("context=\"", selinux_apifs_context, "\"", NULL);
t = strjoin("context=\"", selinux_apifs_context, "\"");
if (!t) {
free(buf);
return -ENOMEM;

View File

@ -2537,7 +2537,7 @@ static int determine_names(void) {
* search for a machine, but instead create a new one
* in /var/lib/machine. */
arg_directory = strjoin("/var/lib/machines/", arg_machine, NULL);
arg_directory = strjoin("/var/lib/machines/", arg_machine);
if (!arg_directory)
return log_oom();
}
@ -3380,7 +3380,7 @@ static int load_settings(void) {
FOREACH_STRING(i, "/etc/systemd/nspawn", "/run/systemd/nspawn") {
_cleanup_free_ char *j = NULL;
j = strjoin(i, "/", fn, NULL);
j = strjoin(i, "/", fn);
if (!j)
return log_oom();

View File

@ -45,11 +45,11 @@ static int add_symlink(const char *service, const char *where) {
assert(service);
assert(where);
from = strjoin(SYSTEM_DATA_UNIT_PATH, "/", service, NULL);
from = strjoin(SYSTEM_DATA_UNIT_PATH, "/", service);
if (!from)
return log_oom();
to = strjoin(arg_dest, "/", where, ".wants/", service, NULL);
to = strjoin(arg_dest, "/", where, ".wants/", service);
if (!to)
return log_oom();

View File

@ -1303,7 +1303,7 @@ static int nsec3_hashed_domain_format(const uint8_t *hashed, size_t hashed_size,
if (!l)
return -ENOMEM;
j = strjoin(l, ".", zone, NULL);
j = strjoin(l, ".", zone);
if (!j)
return -ENOMEM;

View File

@ -792,7 +792,7 @@ static char *format_types(Bitmap *types) {
if (!str)
return NULL;
return strjoin("( ", str, " )", NULL);
return strjoin("( ", str, " )");
}
static char *format_txt(DnsTxtItem *first) {
@ -861,14 +861,14 @@ const char *dns_resource_record_to_string(DnsResourceRecord *rr) {
case DNS_TYPE_NS:
case DNS_TYPE_CNAME:
case DNS_TYPE_DNAME:
s = strjoin(k, " ", rr->ptr.name, NULL);
s = strjoin(k, " ", rr->ptr.name);
if (!s)
return NULL;
break;
case DNS_TYPE_HINFO:
s = strjoin(k, " ", rr->hinfo.cpu, " ", rr->hinfo.os, NULL);
s = strjoin(k, " ", rr->hinfo.cpu, " ", rr->hinfo.os);
if (!s)
return NULL;
break;
@ -879,7 +879,7 @@ const char *dns_resource_record_to_string(DnsResourceRecord *rr) {
if (!t)
return NULL;
s = strjoin(k, " ", t, NULL);
s = strjoin(k, " ", t);
if (!s)
return NULL;
break;
@ -891,7 +891,7 @@ const char *dns_resource_record_to_string(DnsResourceRecord *rr) {
if (r < 0)
return NULL;
s = strjoin(k, " ", x, NULL);
s = strjoin(k, " ", x);
if (!s)
return NULL;
break;
@ -902,7 +902,7 @@ const char *dns_resource_record_to_string(DnsResourceRecord *rr) {
if (r < 0)
return NULL;
s = strjoin(k, " ", t, NULL);
s = strjoin(k, " ", t);
if (!s)
return NULL;
break;
@ -942,7 +942,7 @@ const char *dns_resource_record_to_string(DnsResourceRecord *rr) {
if (!t)
return NULL;
s = strjoin(k, " ", t, NULL);
s = strjoin(k, " ", t);
if (!s)
return NULL;
break;

View File

@ -42,7 +42,7 @@ static void prefix_random(const char *name, char **ret) {
char *x;
assert_se(asprintf(&b, "x%" PRIu64 "x", random_u64()));
x = strjoin(b, ".", name, NULL);
x = strjoin(b, ".", name);
assert_se(x);
free(m);

View File

@ -184,9 +184,9 @@ static int determine_state_file(
if (!escaped_path_id)
return log_oom();
state_file = strjoin("/var/lib/systemd/rfkill/", escaped_path_id, ":", type, NULL);
state_file = strjoin("/var/lib/systemd/rfkill/", escaped_path_id, ":", type);
} else
state_file = strjoin("/var/lib/systemd/rfkill/", type, NULL);
state_file = strjoin("/var/lib/systemd/rfkill/", type);
if (!state_file)
return log_oom();

View File

@ -747,7 +747,7 @@ static int make_unit_name(sd_bus *bus, UnitType t, char **ret) {
return -EINVAL;
}
p = strjoin("run-u", id, ".", unit_type_to_string(t), NULL);
p = strjoin("run-u", id, ".", unit_type_to_string(t));
if (!p)
return log_oom();

View File

@ -82,7 +82,7 @@ int base_filesystem_create(const char *root, uid_t uid, gid_t gid) {
if (table[i].exists) {
_cleanup_free_ char *p = NULL;
p = strjoin(s, "/", table[i].exists, NULL);
p = strjoin(s, "/", table[i].exists);
if (!p)
return log_oom();

View File

@ -676,7 +676,7 @@ int bus_connect_user_systemd(sd_bus **_bus) {
if (r < 0)
return r;
bus->address = strjoin("unix:path=", ee, "/systemd/private", NULL);
bus->address = strjoin("unix:path=", ee, "/systemd/private");
if (!bus->address)
return -ENOMEM;
@ -1460,7 +1460,7 @@ int bus_path_encode_unique(sd_bus *b, const char *prefix, const char *sender_id,
if (!external_label)
return -ENOMEM;
p = strjoin(prefix, "/", sender_label, "/", external_label, NULL);
p = strjoin(prefix, "/", sender_label, "/", external_label);
if (!p)
return -ENOMEM;

View File

@ -158,7 +158,7 @@ int show_cgroup_by_path(
while ((r = cg_read_subgroup(d, &gn)) > 0) {
_cleanup_free_ char *k = NULL;
k = strjoin(fn, "/", gn, NULL);
k = strjoin(fn, "/", gn);
free(gn);
if (!k)
return -ENOMEM;

View File

@ -101,7 +101,7 @@ int config_item_perf_lookup(
else {
char *key;
key = strjoin(section, ".", lvalue, NULL);
key = strjoin(section, ".", lvalue);
if (!key)
return -ENOMEM;

View File

@ -1076,7 +1076,7 @@ int dns_service_split(const char *joined, char **_name, char **_type, char **_do
if (!name)
return -ENOMEM;
type = strjoin(b, ".", c, NULL);
type = strjoin(b, ".", c);
if (!type)
return -ENOMEM;
@ -1090,7 +1090,7 @@ int dns_service_split(const char *joined, char **_name, char **_type, char **_do
name = NULL;
type = strjoin(a, ".", b, NULL);
type = strjoin(a, ".", b);
if (!type)
return -ENOMEM;

View File

@ -61,11 +61,11 @@ int drop_in_file(const char *dir, const char *unit, unsigned level,
if (!filename_is_valid(b))
return -EINVAL;
p = strjoin(dir, "/", unit, ".d", NULL);
p = strjoin(dir, "/", unit, ".d");
if (!p)
return -ENOMEM;
q = strjoin(p, "/", prefix, "-", b, ".conf", NULL);
q = strjoin(p, "/", prefix, "-", b, ".conf");
if (!q) {
free(p);
return -ENOMEM;
@ -163,7 +163,7 @@ static int iterate_dir(
if (hidden_or_backup_file(de->d_name))
continue;
f = strjoin(path, "/", de->d_name, NULL);
f = strjoin(path, "/", de->d_name);
if (!f)
return log_oom();
@ -192,7 +192,7 @@ int unit_file_process_dir(
assert(name);
assert(suffix);
path = strjoin(unit_path, "/", name, suffix, NULL);
path = strjoin(unit_path, "/", name, suffix);
if (!path)
return log_oom();
@ -207,7 +207,7 @@ int unit_file_process_dir(
if (r < 0)
return log_error_errno(r, "Failed to generate template from unit name: %m");
p = strjoin(unit_path, "/", template, suffix, NULL);
p = strjoin(unit_path, "/", template, suffix);
if (!p)
return log_oom();

View File

@ -241,7 +241,7 @@ static char *tag_to_udev_node(const char *tagvalue, const char *by) {
if (encode_devnode_name(u, t, enc_len) < 0)
return NULL;
return strjoin("/dev/disk/by-", by, "/", t, NULL);
return strjoin("/dev/disk/by-", by, "/", t);
}
char *fstab_node_to_udev_node(const char *p) {

View File

@ -45,7 +45,7 @@ static int specifier_prefix_and_instance(char specifier, void *data, void *userd
if (endswith(prefix, "@") && i->default_instance) {
char *ans;
ans = strjoin(prefix, i->default_instance, NULL);
ans = strjoin(prefix, i->default_instance);
if (!ans)
return -ENOMEM;
*ret = ans;

View File

@ -1303,7 +1303,7 @@ static int unit_file_search(
STRV_FOREACH(p, paths->search_path) {
_cleanup_free_ char *path = NULL;
path = strjoin(*p, "/", info->name, NULL);
path = strjoin(*p, "/", info->name);
if (!path)
return -ENOMEM;
@ -1328,7 +1328,7 @@ static int unit_file_search(
STRV_FOREACH(p, paths->search_path) {
_cleanup_free_ char *path = NULL;
path = strjoin(*p, "/", template, NULL);
path = strjoin(*p, "/", template);
if (!path)
return -ENOMEM;
@ -1608,7 +1608,7 @@ static int install_info_symlink_wants(
continue;
}
path = strjoin(config_path, "/", dst, suffix, n, NULL);
path = strjoin(config_path, "/", dst, suffix, n);
if (!path)
return -ENOMEM;
@ -1642,7 +1642,7 @@ static int install_info_symlink_link(
if (r > 0)
return 0;
path = strjoin(config_path, "/", i->name, NULL);
path = strjoin(config_path, "/", i->name);
if (!path)
return -ENOMEM;
@ -2162,7 +2162,7 @@ int unit_file_revert(
STRV_FOREACH(j, fs) {
_cleanup_free_ char *t = NULL;
t = strjoin(*i, "/", *j, NULL);
t = strjoin(*i, "/", *j);
if (!t)
return -ENOMEM;

View File

@ -131,7 +131,7 @@ static int image_new(
return -ENOMEM;
if (path)
i->path = strjoin(path, "/", filename, NULL);
i->path = strjoin(path, "/", filename);
else
i->path = strdup(filename);

View File

@ -70,7 +70,7 @@ static int user_config_dir(char **ret, const char *suffix) {
if (!home)
return -ENXIO;
j = strjoin(home, "/.config", suffix, NULL);
j = strjoin(home, "/.config", suffix);
}
if (!j)
@ -102,7 +102,7 @@ static int user_data_dir(char **ret, const char *suffix) {
return -ENXIO;
j = strjoin(home, "/.local/share", suffix, NULL);
j = strjoin(home, "/.local/share", suffix);
}
if (!j)
return -ENOMEM;

View File

@ -518,7 +518,7 @@ static int output_units_list(const UnitInfo *unit_infos, unsigned c) {
}
if (u->machine) {
j = strjoin(u->machine, ":", u->id, NULL);
j = strjoin(u->machine, ":", u->id);
if (!j)
return log_oom();
@ -929,7 +929,7 @@ static int output_sockets_list(struct socket_info *socket_infos, unsigned cs) {
char **a;
if (s->machine) {
j = strjoin(s->machine, ":", s->path, NULL);
j = strjoin(s->machine, ":", s->path);
if (!j)
return log_oom();
path = j;
@ -1213,7 +1213,7 @@ static int output_timers_list(struct timer_info *timer_infos, unsigned n) {
format_timestamp_relative(trel2, sizeof(trel2), t->last_trigger);
if (t->machine) {
j = strjoin(t->machine, ":", t->id, NULL);
j = strjoin(t->machine, ":", t->id);
if (!j)
return log_oom();
unit = j;
@ -6418,12 +6418,12 @@ static int get_file_to_edit(
assert(name);
assert(ret_path);
path = strjoin(paths->persistent_config, "/", name, NULL);
path = strjoin(paths->persistent_config, "/", name);
if (!path)
return log_oom();
if (arg_runtime) {
run = strjoin(paths->runtime_config, "/", name, NULL);
run = strjoin(paths->runtime_config, "/", name);
if (!run)
return log_oom();
}

View File

@ -562,7 +562,7 @@ static int load_sysv(SysvStub *s) {
char *d = NULL;
if (chkconfig_description)
d = strjoin(chkconfig_description, " ", j, NULL);
d = strjoin(chkconfig_description, " ", j);
else
d = strdup(j);
if (!d)
@ -624,7 +624,7 @@ static int load_sysv(SysvStub *s) {
char *d = NULL;
if (long_description)
d = strjoin(long_description, " ", t, NULL);
d = strjoin(long_description, " ", t);
else
d = strdup(j);
if (!d)
@ -803,7 +803,7 @@ static int enumerate_sysv(const LookupPaths *lp, Hashmap *all_services) {
continue;
}
fpath = strjoin(*path, "/", de->d_name, NULL);
fpath = strjoin(*path, "/", de->d_name);
if (!fpath)
return log_oom();
@ -849,7 +849,7 @@ static int set_dependencies_from_rcnd(const LookupPaths *lp, Hashmap *all_servic
_cleanup_free_ char *path = NULL;
struct dirent *de;
path = strjoin(*p, "/", rcnd_table[i].path, NULL);
path = strjoin(*p, "/", rcnd_table[i].path);
if (!path) {
r = log_oom();
goto finish;
@ -879,7 +879,7 @@ static int set_dependencies_from_rcnd(const LookupPaths *lp, Hashmap *all_servic
if (a < 0 || b < 0)
continue;
fpath = strjoin(*p, "/", de->d_name, NULL);
fpath = strjoin(*p, "/", de->d_name);
if (!fpath) {
r = log_oom();
goto finish;

View File

@ -141,8 +141,8 @@ static void test_copy_tree(void) {
STRV_FOREACH_PAIR(link, p, links) {
_cleanup_free_ char *target = NULL, *f, *l;
assert_se(f = strjoin(original_dir, *p, NULL));
assert_se(l = strjoin(copy_dir, *link, NULL));
assert_se(f = strjoin(original_dir, *p));
assert_se(l = strjoin(copy_dir, *link));
assert_se(readlink_and_canonicalize(l, &target) == 0);
assert_se(path_equal(f, target));

View File

@ -60,7 +60,7 @@ static void test_one(const char *p) {
_cleanup_free_ char *with_utc;
log_info("Test: %s", p);
with_utc = strjoin(p, " UTC", NULL);
with_utc = strjoin(p, " UTC");
test_should_pass(p);
test_should_pass(with_utc);
}
@ -69,7 +69,7 @@ static void test_one_noutc(const char *p) {
_cleanup_free_ char *with_utc;
log_info("Test: %s", p);
with_utc = strjoin(p, " UTC", NULL);
with_utc = strjoin(p, " UTC");
test_should_pass(p);
test_should_fail(with_utc);
}

View File

@ -367,7 +367,7 @@ static void test_write_string_file_verify(void) {
int r;
assert_se(read_one_line_file("/proc/cmdline", &buf) >= 0);
assert_se((buf2 = strjoin(buf, "\n", NULL)));
assert_se((buf2 = strjoin(buf, "\n")));
r = write_string_file("/proc/cmdline", buf, 0);
assert_se(r == -EACCES || r == -EIO);

View File

@ -132,14 +132,14 @@ int main(int argc, char *argv[]) {
assert_se(sd_id128_get_boot(&bid) >= 0);
sd_id128_to_string(bid, boot_id);
x = strjoin("/tmp/systemd-private-", boot_id, "-abcd.service-", NULL);
y = strjoin("/var/tmp/systemd-private-", boot_id, "-abcd.service-", NULL);
x = strjoin("/tmp/systemd-private-", boot_id, "-abcd.service-");
y = strjoin("/var/tmp/systemd-private-", boot_id, "-abcd.service-");
assert_se(x && y);
test_tmpdir("abcd.service", x, y);
z = strjoin("/tmp/systemd-private-", boot_id, "-sys-devices-pci0000:00-0000:00:1a.0-usb3-3\\x2d1-3\\x2d1:1.0-bluetooth-hci0.device-", NULL);
zz = strjoin("/var/tmp/systemd-private-", boot_id, "-sys-devices-pci0000:00-0000:00:1a.0-usb3-3\\x2d1-3\\x2d1:1.0-bluetooth-hci0.device-", NULL);
z = strjoin("/tmp/systemd-private-", boot_id, "-sys-devices-pci0000:00-0000:00:1a.0-usb3-3\\x2d1-3\\x2d1:1.0-bluetooth-hci0.device-");
zz = strjoin("/var/tmp/systemd-private-", boot_id, "-sys-devices-pci0000:00-0000:00:1a.0-usb3-3\\x2d1-3\\x2d1:1.0-bluetooth-hci0.device-");
assert_se(z && zz);

View File

@ -56,7 +56,7 @@ static int setup_test(Manager **m) {
STRV_FOREACH(test_path, tests_path) {
_cleanup_free_ char *p = NULL;
p = strjoin("/tmp/test-path_", *test_path, NULL);
p = strjoin("/tmp/test-path_", *test_path);
assert_se(p);
(void) rm_rf(p, REMOVE_ROOT|REMOVE_PHYSICAL);

View File

@ -25,7 +25,7 @@
#include "util.h"
static char *lookup(const char *variable, void *userdata) {
return strjoin("<<<", variable, ">>>", NULL);
return strjoin("<<<", variable, ">>>");
}
int main(int argc, char *argv[]) {

View File

@ -422,7 +422,7 @@ static int dir_cleanup(
continue;
}
sub_path = strjoin(p, "/", dent->d_name, NULL);
sub_path = strjoin(p, "/", dent->d_name);
if (!sub_path) {
r = log_oom();
goto finish;
@ -1082,7 +1082,7 @@ static int item_do_children(Item *i, const char *path, action_t action) {
if (STR_IN_SET(de->d_name, ".", ".."))
continue;
p = strjoin(path, "/", de->d_name, NULL);
p = strjoin(path, "/", de->d_name);
if (!p)
return -ENOMEM;

View File

@ -43,7 +43,7 @@ int udev_builtin_hwdb_lookup(struct udev_device *dev,
return -ENOENT;
if (prefix) {
lookup = strjoin(prefix, modalias, NULL);
lookup = strjoin(prefix, modalias);
if (!lookup)
return -ENOMEM;
modalias = lookup;

View File

@ -653,7 +653,7 @@ static int adm_hwdb(struct udev *udev, int argc, char *argv[]) {
log_debug("strings dedup'ed: %8zu bytes (%8zu)",
trie->strings->dedup_len, trie->strings->dedup_count);
hwdb_bin = strjoin(root, "/", hwdb_bin_dir, "/hwdb.bin", NULL);
hwdb_bin = strjoin(root, "/", hwdb_bin_dir, "/hwdb.bin");
if (!hwdb_bin) {
rc = EXIT_FAILURE;
goto out;