Commit b7def684 authored by Lennart Poettering's avatar Lennart Poettering

util: rename join() to strjoin()

This is to match strappend() and the other string related functions.
parent 184850e8
......@@ -34,6 +34,10 @@ Bugfixes:
Features:
* logind: wakelock/opportunistic suspend support
* seccomp filters for services
* replace BindTo= by BindsTo=, but keep old name for compat
* switch-root: sockets need relabelling
......
......@@ -310,7 +310,7 @@ static int refresh_one(
if (r <= 0)
goto finish;
p = join(path, "/", fn, NULL);
p = strjoin(path, "/", fn, NULL);
free(fn);
if (!p) {
......
......@@ -120,7 +120,7 @@ int cgroup_bonding_install(CGroupBonding *b, pid_t pid, const char *cgroup_suffi
assert(pid >= 0);
if (cgroup_suffix) {
p = join(b->path, "/", cgroup_suffix, NULL);
p = strjoin(b->path, "/", cgroup_suffix, NULL);
if (!p)
return -ENOMEM;
......@@ -208,7 +208,7 @@ int cgroup_bonding_kill(CGroupBonding *b, int sig, bool sigcont, bool rem, Set *
return 0;
if (cgroup_suffix) {
p = join(b->path, "/", cgroup_suffix, NULL);
p = strjoin(b->path, "/", cgroup_suffix, NULL);
if (!p)
return -ENOMEM;
......
......@@ -1179,7 +1179,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
else {
char *p;
p = join(switch_root, "/", switch_root_init, NULL);
p = strjoin(switch_root, "/", switch_root_init, NULL);
if (!p)
goto oom;
......
......@@ -51,7 +51,7 @@ static int iterate_dir(Unit *u, const char *path, UnitDependency dependency) {
if (ignore_file(de->d_name))
continue;
f = join(path, "/", de->d_name, NULL);
f = strjoin(path, "/", de->d_name, NULL);
if (!f) {
r = -ENOMEM;
goto finish;
......@@ -80,7 +80,7 @@ static int process_dir(Unit *u, const char *unit_path, const char *name, const c
assert(name);
assert(suffix);
path = join(unit_path, "/", name, suffix, NULL);
path = strjoin(unit_path, "/", name, suffix, NULL);
if (!path)
return -ENOMEM;
......@@ -102,7 +102,7 @@ static int process_dir(Unit *u, const char *unit_path, const char *name, const c
if (!template)
return -ENOMEM;
path = join(unit_path, "/", template, suffix, NULL);
path = strjoin(unit_path, "/", template, suffix, NULL);
free(template);
if (!path)
......
......@@ -590,7 +590,7 @@ static void manager_build_unit_path_cache(Manager *m) {
if (ignore_file(de->d_name))
continue;
p = join(streq(*i, "/") ? "" : *i, "/", de->d_name, NULL);
p = strjoin(streq(*i, "/") ? "" : *i, "/", de->d_name, NULL);
if (!p) {
r = -ENOMEM;
goto fail;
......@@ -2085,7 +2085,7 @@ static int create_generator_dir(Manager *m, char **generator, const char *name)
return r;
}
} else {
p = join("/tmp/systemd-", name, ".XXXXXX", NULL);
p = strjoin("/tmp/systemd-", name, ".XXXXXX", NULL);
if (!p) {
log_error("Out of memory");
return -ENOMEM;
......
......@@ -1534,7 +1534,7 @@ static int mount_load_proc_self_mountinfo(Manager *m, bool set_flags) {
goto clean_up;
}
o = join(options, ",", options2, NULL);
o = strjoin(options, ",", options2, NULL);
if (!o) {
r = -ENOMEM;
goto finish;
......
......@@ -722,7 +722,7 @@ static int service_load_sysv_path(Service *s, const char *path) {
char *d = NULL;
if (chkconfig_description)
d = join(chkconfig_description, " ", j, NULL);
d = strjoin(chkconfig_description, " ", j, NULL);
else
d = strdup(j);
......@@ -879,7 +879,7 @@ static int service_load_sysv_path(Service *s, const char *path) {
char *d = NULL;
if (long_description)
d = join(long_description, " ", t, NULL);
d = strjoin(long_description, " ", t, NULL);
else
d = strdup(j);
......@@ -1001,7 +1001,7 @@ static int service_load_sysv_name(Service *s, const char *name) {
char *path;
int r;
path = join(*p, "/", name, NULL);
path = strjoin(*p, "/", name, NULL);
if (!path)
return -ENOMEM;
......@@ -1023,7 +1023,7 @@ static int service_load_sysv_name(Service *s, const char *name) {
if (r >= 0 && UNIT(s)->load_state == UNIT_STUB) {
/* Try SUSE style boot.* init scripts */
path = join(*p, "/boot.", name, NULL);
path = strjoin(*p, "/boot.", name, NULL);
if (!path)
return -ENOMEM;
......@@ -1038,7 +1038,7 @@ static int service_load_sysv_name(Service *s, const char *name) {
if (r >= 0 && UNIT(s)->load_state == UNIT_STUB) {
/* Try Frugalware style rc.* init scripts */
path = join(*p, "/rc.", name, NULL);
path = strjoin(*p, "/rc.", name, NULL);
if (!path)
return -ENOMEM;
......@@ -3407,7 +3407,7 @@ static int service_enumerate(Manager *m) {
struct dirent *de;
free(path);
path = join(*p, "/", rcnd_table[i].path, NULL);
path = strjoin(*p, "/", rcnd_table[i].path, NULL);
if (!path) {
r = -ENOMEM;
goto finish;
......@@ -3442,7 +3442,7 @@ static int service_enumerate(Manager *m) {
continue;
free(fpath);
fpath = join(path, "/", de->d_name, NULL);
fpath = strjoin(path, "/", de->d_name, NULL);
if (!fpath) {
r = -ENOMEM;
goto finish;
......
......@@ -1891,10 +1891,10 @@ static char *default_cgroup_path(Unit *u) {
if (!t)
return NULL;
p = join(u->manager->cgroup_hierarchy, "/", t, "/", u->instance, NULL);
p = strjoin(u->manager->cgroup_hierarchy, "/", t, "/", u->instance, NULL);
free(t);
} else
p = join(u->manager->cgroup_hierarchy, "/", u->id, NULL);
p = strjoin(u->manager->cgroup_hierarchy, "/", u->id, NULL);
return p;
}
......
......@@ -88,7 +88,7 @@ static int create_disk(
goto fail;
}
p = join(arg_dest, "/", n, NULL);
p = strjoin(arg_dest, "/", n, NULL);
if (!p) {
r = -ENOMEM;
log_error("Failed to allocate unit file name.");
......@@ -175,7 +175,7 @@ static int create_disk(
if (!noauto) {
to = join(arg_dest, "/", d, ".wants/", n, NULL);
to = strjoin(arg_dest, "/", d, ".wants/", n, NULL);
if (!to) {
r = -ENOMEM;
goto fail;
......@@ -191,9 +191,9 @@ static int create_disk(
free(to);
if (!nofail)
to = join(arg_dest, "/cryptsetup.target.requires/", n, NULL);
to = strjoin(arg_dest, "/cryptsetup.target.requires/", n, NULL);
else
to = join(arg_dest, "/cryptsetup.target.wants/", n, NULL);
to = strjoin(arg_dest, "/cryptsetup.target.wants/", n, NULL);
if (!to) {
r = -ENOMEM;
goto fail;
......@@ -211,7 +211,7 @@ static int create_disk(
}
e = unit_name_escape(name);
to = join(arg_dest, "/dev-mapper-", e, ".device.requires/", n, NULL);
to = strjoin(arg_dest, "/dev-mapper-", e, ".device.requires/", n, NULL);
if (!to) {
r = -ENOMEM;
goto fail;
......
......@@ -192,7 +192,7 @@ static int enumerate_dir(Hashmap *top, Hashmap *bottom, const char *path) {
if (!dirent_is_file(de))
continue;
p = join(path, "/", de->d_name, NULL);
p = strjoin(path, "/", de->d_name, NULL);
if (!p) {
r = -ENOMEM;
goto finish;
......@@ -254,7 +254,7 @@ static int process_suffix(const char *prefixes, const char *suffix) {
NULSTR_FOREACH(p, prefixes) {
char *t;
t = join(p, "/", suffix, NULL);
t = strjoin(p, "/", suffix, NULL);
if (!t) {
r = -ENOMEM;
goto finish;
......
......@@ -103,7 +103,7 @@ static int add_swap(const char *what, struct mntent *me) {
goto finish;
}
unit = join(arg_dest, "/", name, NULL);
unit = strjoin(arg_dest, "/", name, NULL);
if (!unit) {
log_error("Out of memory");
r = -ENOMEM;
......@@ -146,7 +146,7 @@ static int add_swap(const char *what, struct mntent *me) {
}
if (!noauto) {
lnk = join(arg_dest, "/" SPECIAL_SWAP_TARGET ".wants/", name, NULL);
lnk = strjoin(arg_dest, "/" SPECIAL_SWAP_TARGET ".wants/", name, NULL);
if (!lnk) {
log_error("Out of memory");
r = -ENOMEM;
......@@ -169,7 +169,7 @@ static int add_swap(const char *what, struct mntent *me) {
if (r > 0) {
free(lnk);
lnk = join(arg_dest, "/", device, ".wants/", name, NULL);
lnk = strjoin(arg_dest, "/", device, ".wants/", name, NULL);
if (!lnk) {
log_error("Out of memory");
r = -ENOMEM;
......@@ -261,7 +261,7 @@ static int add_mount(const char *what, const char *where, struct mntent *me) {
goto finish;
}
unit = join(arg_dest, "/", name, NULL);
unit = strjoin(arg_dest, "/", name, NULL);
if (!unit) {
log_error("Out of memory");
r = -ENOMEM;
......@@ -321,7 +321,7 @@ static int add_mount(const char *what, const char *where, struct mntent *me) {
}
if (!noauto) {
lnk = join(arg_dest, "/", post, nofail || automount ? ".wants/" : ".requires/", name, NULL);
lnk = strjoin(arg_dest, "/", post, nofail || automount ? ".wants/" : ".requires/", name, NULL);
if (!lnk) {
log_error("Out of memory");
r = -ENOMEM;
......@@ -347,7 +347,7 @@ static int add_mount(const char *what, const char *where, struct mntent *me) {
if (r > 0) {
free(lnk);
lnk = join(arg_dest, "/", device, ".wants/", name, NULL);
lnk = strjoin(arg_dest, "/", device, ".wants/", name, NULL);
if (!lnk) {
log_error("Out of memory");
r = -ENOMEM;
......@@ -372,7 +372,7 @@ static int add_mount(const char *what, const char *where, struct mntent *me) {
goto finish;
}
automount_unit = join(arg_dest, "/", automount_name, NULL);
automount_unit = strjoin(arg_dest, "/", automount_name, NULL);
if (!automount_unit) {
log_error("Out of memory");
r = -ENOMEM;
......@@ -408,7 +408,7 @@ static int add_mount(const char *what, const char *where, struct mntent *me) {
}
free(lnk);
lnk = join(arg_dest, "/", post, nofail ? ".wants/" : ".requires/", automount_name, NULL);
lnk = strjoin(arg_dest, "/", post, nofail ? ".wants/" : ".requires/", automount_name, NULL);
if (!lnk) {
log_error("Out of memory");
r = -ENOMEM;
......
......@@ -39,7 +39,7 @@ static int add_symlink(const char *fservice, const char *tservice) {
assert(tservice);
from = strappend(SYSTEM_DATA_UNIT_PATH "/", fservice);
to = join(arg_dest,"/getty.target.wants/", tservice, NULL);
to = strjoin(arg_dest,"/getty.target.wants/", tservice, NULL);
if (!from || !to) {
log_error("Out of memory");
......
......@@ -213,14 +213,14 @@ int main(int argc, char* argv[]) {
IOVEC_SET_STRING(iovec[j++], core_cmdline);
}
core_timestamp = join("COREDUMP_TIMESTAMP=", argv[ARG_TIMESTAMP], "000000", NULL);
core_timestamp = strjoin("COREDUMP_TIMESTAMP=", argv[ARG_TIMESTAMP], "000000", NULL);
if (core_timestamp)
IOVEC_SET_STRING(iovec[j++], core_timestamp);
IOVEC_SET_STRING(iovec[j++], "MESSAGE_ID=fc2e22bc6ee647b6b90729ab34a250b1");
IOVEC_SET_STRING(iovec[j++], "PRIORITY=2");
core_message = join("MESSAGE=Process ", argv[ARG_PID], " (", argv[ARG_COMM], ") dumped core.", NULL);
core_message = strjoin("MESSAGE=Process ", argv[ARG_PID], " (", argv[ARG_COMM], ") dumped core.", NULL);
if (core_message)
IOVEC_SET_STRING(iovec[j++], core_message);
......
......@@ -1976,7 +1976,7 @@ static int system_journal_open(Server *s) {
(void) mkdir(fn, 0755);
free(fn);
fn = join("/var/log/journal/", ids, "/system.journal", NULL);
fn = strjoin("/var/log/journal/", ids, "/system.journal", NULL);
if (!fn)
return -ENOMEM;
......@@ -2002,7 +2002,7 @@ static int system_journal_open(Server *s) {
if (!s->runtime_journal &&
(s->storage != STORAGE_NONE)) {
fn = join("/run/log/journal/", ids, "/system.journal", NULL);
fn = strjoin("/run/log/journal/", ids, "/system.journal", NULL);
if (!fn)
return -ENOMEM;
......
......@@ -313,7 +313,7 @@ static char *match_make_string(Match *m) {
}
if (p) {
k = join(p, m->type == MATCH_OR_TERM ? " OR " : " AND ", t, NULL);
k = strjoin(p, m->type == MATCH_OR_TERM ? " OR " : " AND ", t, NULL);
free(p);
free(t);
......@@ -330,7 +330,7 @@ static char *match_make_string(Match *m) {
}
if (enclose) {
r = join("(", p, ")", NULL);
r = strjoin("(", p, ")", NULL);
free(p);
return r;
}
......@@ -1101,7 +1101,7 @@ static int add_file(sd_journal *j, const char *prefix, const char *filename) {
(startswith(filename, "system@") && endswith(filename, ".journal"))))
return 0;
path = join(prefix, "/", filename, NULL);
path = strjoin(prefix, "/", filename, NULL);
if (!path)
return -ENOMEM;
......@@ -1149,7 +1149,7 @@ static int remove_file(sd_journal *j, const char *prefix, const char *filename)
assert(prefix);
assert(filename);
path = join(prefix, "/", filename, NULL);
path = strjoin(prefix, "/", filename, NULL);
if (!path)
return -ENOMEM;
......@@ -1184,7 +1184,7 @@ static int add_directory(sd_journal *j, const char *prefix, const char *dirname)
!sd_id128_equal(id, mid)))
return 0;
path = join(prefix, "/", dirname, NULL);
path = strjoin(prefix, "/", dirname, NULL);
if (!path)
return -ENOMEM;
......
......@@ -522,16 +522,16 @@ static int join_path(const char *controller, const char *path, const char *suffi
if (controller) {
if (path && suffix)
t = join("/sys/fs/cgroup/", controller, "/", path, "/", suffix, NULL);
t = strjoin("/sys/fs/cgroup/", controller, "/", path, "/", suffix, NULL);
else if (path)
t = join("/sys/fs/cgroup/", controller, "/", path, NULL);
t = strjoin("/sys/fs/cgroup/", controller, "/", path, NULL);
else if (suffix)
t = join("/sys/fs/cgroup/", controller, "/", suffix, NULL);
t = strjoin("/sys/fs/cgroup/", controller, "/", suffix, NULL);
else
t = join("/sys/fs/cgroup/", controller, NULL);
t = strjoin("/sys/fs/cgroup/", controller, NULL);
} else {
if (path && suffix)
t = join(path, "/", suffix, NULL);
t = strjoin(path, "/", suffix, NULL);
else if (path)
t = strdup(path);
}
......
......@@ -90,7 +90,7 @@ int config_item_perf_lookup(
else {
char *key;
key = join(section, ".", lvalue, NULL);
key = strjoin(section, ".", lvalue, NULL);
if (!key)
return -ENOMEM;
......
......@@ -74,7 +74,7 @@ static int rtc_open(int flags) {
if (ignore_file(de->d_name))
continue;
p = join("/sys/class/rtc/", de->d_name, "/hctosys", NULL);
p = strjoin("/sys/class/rtc/", de->d_name, "/hctosys", NULL);
if (!p) {
closedir(d);
return -ENOMEM;
......
......@@ -120,7 +120,7 @@ char *path_make_absolute(const char *p, const char *prefix) {
if (path_is_absolute(p) || !prefix)
return strdup(p);
return join(prefix, "/", p, NULL);
return strjoin(prefix, "/", p, NULL);
}
char *path_make_absolute_cwd(const char *p) {
......
......@@ -208,7 +208,7 @@ char *unit_name_build(const char *prefix, const char *instance, const char *suff
if (!instance)
return strappend(prefix, suffix);
return join(prefix, "@", instance, suffix, NULL);
return strjoin(prefix, "@", instance, suffix, NULL);
}
static char *do_escape_char(char c, char *t) {
......@@ -425,7 +425,7 @@ char *unit_name_from_path_instance(const char *prefix, const char *path, const c
if (!p)
return NULL;
r = join(prefix, "@", p, suffix, NULL);
r = strjoin(prefix, "@", p, suffix, NULL);
free(p);
return r;
......
......@@ -1083,7 +1083,7 @@ int get_process_cmdline(pid_t pid, size_t max_length, bool comm_fallback, char *
if (h < 0)
return h;
r = join("[", t, "]", NULL);
r = strjoin("[", t, "]", NULL);
free(t);
if (!r)
......@@ -5145,7 +5145,7 @@ finish:
return r;
}
char *join(const char *x, ...) {
char *strjoin(const char *x, ...) {
va_list ap;
size_t l;
char *r, *p;
......
......@@ -451,7 +451,7 @@ int dirent_ensure_type(DIR *d, struct dirent *de);
int in_search_path(const char *path, char **search);
int get_files_in_directory(const char *path, char ***list);
char *join(const char *x, ...) _sentinel_;
char *strjoin(const char *x, ...) _sentinel_;
bool is_main_thread(void);
......
......@@ -1297,7 +1297,7 @@ static char *resolve_fragment(const char *fragment, const char **search_paths) {
return strdup(fragment);
STRV_FOREACH(p, search_paths) {
resolved_path = join(*p, "/", fragment, NULL);
resolved_path = strjoin(*p, "/", fragment, NULL);
if (resolved_path == NULL) {
log_error("Out of memory");
return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment