tree-wide: get rid of strappend()

It's a special case of strjoin(), so no need to keep both. In particular
as typing strjoin() is even shoert than strappend().
This commit is contained in:
Lennart Poettering 2019-07-11 19:14:16 +02:00 committed by Yu Watanabe
parent 6fa0524133
commit b910cc72c0
68 changed files with 115 additions and 146 deletions

View File

@ -151,7 +151,7 @@ static int exec_process(const char *name, char **argv, char **env, int start_fd,
_cleanup_free_ char *p;
const char *n;
p = strappend(*s, "=");
p = strjoin(*s, "=");
if (!p)
return log_oom();
@ -226,7 +226,7 @@ static int exec_process(const char *name, char **argv, char **env, int start_fd,
if (!names)
return log_oom();
e = strappend("LISTEN_FDNAMES=", names);
e = strjoin("LISTEN_FDNAMES=", names);
if (!e)
return log_oom();

View File

@ -1517,12 +1517,7 @@ static int subvol_snapshot_children(
if (ioctl(old_fd, BTRFS_IOC_INO_LOOKUP, &ino_args) < 0)
return -errno;
/* The kernel returns an empty name if the
* subvolume is in the top-level directory,
* and otherwise appends a slash, so that we
* can just concatenate easily here, without
* adding a slash. */
c = strappend(ino_args.name, p);
c = path_join(ino_args.name, p);
if (!c)
return -ENOMEM;

View File

@ -1922,7 +1922,7 @@ char *cg_escape(const char *p) {
}
if (need_prefix)
return strappend("_", p);
return strjoin("_", p);
return strdup(p);
}

View File

@ -567,7 +567,7 @@ char *replace_env_n(const char *format, size_t n, char **env, unsigned flags) {
t = strv_env_get_n(env, word+2, e-word-2, flags);
k = strappend(r, t);
k = strjoin(r, t);
if (!k)
return NULL;
@ -623,7 +623,7 @@ char *replace_env_n(const char *format, size_t n, char **env, unsigned flags) {
else if (!t && state == DEFAULT_VALUE)
t = v = replace_env_n(test_value, e-test_value, env, flags);
k = strappend(r, t);
k = strjoin(r, t);
if (!k)
return NULL;
@ -642,7 +642,7 @@ char *replace_env_n(const char *format, size_t n, char **env, unsigned flags) {
t = strv_env_get_n(env, word+1, e-word-1, flags);
k = strappend(r, t);
k = strjoin(r, t);
if (!k)
return NULL;
@ -661,7 +661,7 @@ char *replace_env_n(const char *format, size_t n, char **env, unsigned flags) {
assert(flags & REPLACE_ENV_ALLOW_BRACELESS);
t = strv_env_get_n(env, word+1, e-word-1, flags);
return strappend(r, t);
return strjoin(r, t);
} else
return strnappend(r, word, e-word);
}

View File

@ -257,7 +257,7 @@ ssize_t sparse_write(int fd, const void *p, size_t sz, size_t run_length) {
char* set_iovec_string_field(struct iovec *iovec, size_t *n_iovec, const char *field, const char *value) {
char *x;
x = strappend(field, value);
x = strjoin(field, value);
if (x)
iovec[(*n_iovec)++] = IOVEC_MAKE_STRING(x);
return x;
@ -312,7 +312,7 @@ int iovw_put_string_field(struct iovec_wrapper *iovw, const char *field, const c
_cleanup_free_ char *x = NULL;
int r;
x = strappend(field, value);
x = strjoin(field, value);
if (!x)
return log_oom();

View File

@ -41,7 +41,7 @@ int memfd_new(const char *name) {
if (!e)
return -ENOMEM;
g = strappend("sd-", e);
g = strjoin("sd-", e);
if (!g)
return -ENOMEM;

View File

@ -206,10 +206,6 @@ char *strnappend(const char *s, const char *suffix, size_t b) {
return r;
}
char *strappend(const char *s, const char *suffix) {
return strnappend(s, suffix, strlen_ptr(suffix));
}
char *strjoin_real(const char *x, ...) {
va_list ap;
size_t l;

View File

@ -108,7 +108,6 @@ const char* split(const char **state, size_t *l, const char *separator, SplitFla
#define _FOREACH_WORD(word, length, s, separator, flags, state) \
for ((state) = (s), (word) = split(&(state), &(length), (separator), (flags)); (word); (word) = split(&(state), &(length), (separator), (flags)))
char *strappend(const char *s, const char *suffix);
char *strnappend(const char *s, const char *suffix, size_t length);
char *strjoin_real(const char *x, ...) _sentinel_;

View File

@ -233,7 +233,7 @@ int strv_extend_strv_concat(char ***a, char **b, const char *suffix) {
STRV_FOREACH(s, b) {
char *v;
v = strappend(*s, suffix);
v = strjoin(*s, suffix);
if (!v)
return -ENOMEM;

View File

@ -15,7 +15,7 @@ char *unit_dbus_path_from_name(const char *name) {
if (!e)
return NULL;
return strappend("/org/freedesktop/systemd1/unit/", e);
return strjoin("/org/freedesktop/systemd1/unit/", e);
}
int unit_name_from_dbus_path(const char *path, char **name) {

View File

@ -402,7 +402,7 @@ int unit_name_path_escape(const char *f, char **ret) {
}
int unit_name_path_unescape(const char *f, char **ret) {
char *s;
_cleanup_free_ char *s = NULL;
int r;
assert(f);
@ -415,34 +415,27 @@ int unit_name_path_unescape(const char *f, char **ret) {
if (!s)
return -ENOMEM;
} else {
char *w;
_cleanup_free_ char *w = NULL;
r = unit_name_unescape(f, &w);
if (r < 0)
return r;
/* Don't accept trailing or leading slashes */
if (startswith(w, "/") || endswith(w, "/")) {
free(w);
if (startswith(w, "/") || endswith(w, "/"))
return -EINVAL;
}
/* Prefix a slash again */
s = strappend("/", w);
free(w);
s = strjoin("/", w);
if (!s)
return -ENOMEM;
if (!path_is_normalized(s)) {
free(s);
if (!path_is_normalized(s))
return -EINVAL;
}
}
if (ret)
*ret = s;
else
free(s);
*ret = TAKE_PTR(s);
return 0;
}
@ -519,7 +512,7 @@ int unit_name_from_path(const char *path, const char *suffix, char **ret) {
if (r < 0)
return r;
s = strappend(p, suffix);
s = strjoin(p, suffix);
if (!s)
return -ENOMEM;
@ -719,7 +712,7 @@ int slice_build_subslice(const char *slice, const char *name, char **ret) {
return -EINVAL;
if (streq(slice, SPECIAL_ROOT_SLICE))
subslice = strappend(name, ".slice");
subslice = strjoin(name, ".slice");
else {
char *e;

View File

@ -44,7 +44,7 @@ static int delete_rule(const char *rule) {
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"Rule file name '%s' is not valid, refusing.", x + 1);
fn = strappend("/proc/sys/fs/binfmt_misc/", x+1);
fn = path_join("/proc/sys/fs/binfmt_misc", x+1);
if (!fn)
return log_oom();

View File

@ -1700,7 +1700,7 @@ static int build_environment(
}
if (home) {
x = strappend("HOME=", home);
x = strjoin("HOME=", home);
if (!x)
return -ENOMEM;
@ -1709,19 +1709,19 @@ static int build_environment(
}
if (username) {
x = strappend("LOGNAME=", username);
x = strjoin("LOGNAME=", username);
if (!x)
return -ENOMEM;
our_env[n_env++] = x;
x = strappend("USER=", username);
x = strjoin("USER=", username);
if (!x)
return -ENOMEM;
our_env[n_env++] = x;
}
if (shell) {
x = strappend("SHELL=", shell);
x = strjoin("SHELL=", shell);
if (!x)
return -ENOMEM;
@ -1750,7 +1750,7 @@ static int build_environment(
if (!term)
term = default_term_for_tty(tty_path);
x = strappend("TERM=", term);
x = strjoin("TERM=", term);
if (!x)
return -ENOMEM;
our_env[n_env++] = x;

View File

@ -893,7 +893,7 @@ static int manager_setup_notify(Manager *m) {
fd_inc_rcvbuf(fd, NOTIFY_RCVBUF_SIZE);
m->notify_socket = strappend(m->prefix[EXEC_DIRECTORY_RUNTIME], "/systemd/notify");
m->notify_socket = path_join(m->prefix[EXEC_DIRECTORY_RUNTIME], "systemd/notify");
if (!m->notify_socket)
return log_oom();

View File

@ -332,7 +332,7 @@ int mount_cgroup_controllers(void) {
if (!options)
options = TAKE_PTR(controller);
where = strappend("/sys/fs/cgroup/", options);
where = path_join("/sys/fs/cgroup", options);
if (!where)
return log_oom();

View File

@ -1532,7 +1532,7 @@ static int service_spawn(
if (r < 0)
return r;
t = strappend("REMOTE_ADDR=", addr);
t = strjoin("REMOTE_ADDR=", addr);
if (!t)
return -ENOMEM;
our_env[n_env++] = t;

View File

@ -146,7 +146,7 @@ static int timer_setup_persistent(Timer *t) {
if (r < 0)
return r;
t->stamp_path = strappend("/var/lib/systemd/timers/stamp-", UNIT(t)->id);
t->stamp_path = strjoin("/var/lib/systemd/timers/stamp-", UNIT(t)->id);
} else {
const char *e;

View File

@ -396,7 +396,7 @@ static int save_external_coredump(
_cleanup_free_ char *fn_compressed = NULL, *tmp_compressed = NULL;
_cleanup_close_ int fd_compressed = -1;
fn_compressed = strappend(fn, COMPRESSED_EXT);
fn_compressed = strjoin(fn, COMPRESSED_EXT);
if (!fn_compressed) {
log_oom();
goto uncompressed;

View File

@ -583,12 +583,12 @@ static int add_proc_cmdline_devices(void) {
continue;
if (!d->name) {
d->name = strappend("luks-", d->uuid);
d->name = strjoin("luks-", d->uuid);
if (!d->name)
return log_oom();
}
device = strappend("UUID=", d->uuid);
device = strjoin("UUID=", d->uuid);
if (!device)
return log_oom();

View File

@ -131,7 +131,7 @@ static int generate_wants_symlinks(void) {
if (!p)
return log_oom();
f = strappend(SYSTEM_DATA_UNIT_PATH "/", *u);
f = path_join(SYSTEM_DATA_UNIT_PATH, *u);
if (!f)
return log_oom();

View File

@ -132,7 +132,7 @@ static int add_cryptsetup(const char *id, const char *what, bool rw, bool requir
if (device) {
char *ret;
ret = strappend("/dev/mapper/", id);
ret = path_join("/dev/mapper", id);
if (!ret)
return log_oom();

View File

@ -253,11 +253,11 @@ static char* context_fallback_icon_name(Context *c) {
assert(c);
if (!isempty(c->data[PROP_CHASSIS]))
return strappend("computer-", c->data[PROP_CHASSIS]);
return strjoin("computer-", c->data[PROP_CHASSIS]);
chassis = fallback_chassis();
if (chassis)
return strappend("computer-", chassis);
return strjoin("computer-", chassis);
return strdup("computer");
}

View File

@ -584,7 +584,7 @@ int pull_job_begin(PullJob *j) {
if (!cc)
return -ENOMEM;
hdr = strappend("If-None-Match: ", cc);
hdr = strjoin("If-None-Match: ", cc);
if (!hdr)
return -ENOMEM;

View File

@ -1101,19 +1101,19 @@ static int add_matches(sd_journal *j, char **args) {
if (!comm)
return log_oom();
t = strappend("_COMM=", comm);
t = strjoin("_COMM=", comm);
if (!t)
return log_oom();
/* Append _EXE only if the interpreter is not a link.
Otherwise, it might be outdated often. */
if (lstat(interpreter, &st) == 0 && !S_ISLNK(st.st_mode)) {
t2 = strappend("_EXE=", interpreter);
t2 = strjoin("_EXE=", interpreter);
if (!t2)
return log_oom();
}
} else {
t = strappend("_EXE=", p);
t = strjoin("_EXE=", p);
if (!t)
return log_oom();
}

View File

@ -217,7 +217,7 @@ void dev_kmsg_record(Server *s, char *p, size_t l) {
char *b;
if (sd_device_get_devname(d, &g) >= 0) {
b = strappend("_UDEV_DEVNODE=", g);
b = strjoin("_UDEV_DEVNODE=", g);
if (b) {
iovec[n++] = IOVEC_MAKE_STRING(b);
z++;
@ -225,7 +225,7 @@ void dev_kmsg_record(Server *s, char *p, size_t l) {
}
if (sd_device_get_sysname(d, &g) >= 0) {
b = strappend("_UDEV_SYSNAME=", g);
b = strjoin("_UDEV_SYSNAME=", g);
if (b) {
iovec[n++] = IOVEC_MAKE_STRING(b);
z++;
@ -238,7 +238,7 @@ void dev_kmsg_record(Server *s, char *p, size_t l) {
if (j >= N_IOVEC_UDEV_FIELDS)
break;
b = strappend("_UDEV_DEVLINK=", g);
b = strjoin("_UDEV_DEVLINK=", g);
if (b) {
iovec[n++] = IOVEC_MAKE_STRING(b);
z++;
@ -271,13 +271,13 @@ void dev_kmsg_record(Server *s, char *p, size_t l) {
goto finish;
if (identifier) {
syslog_identifier = strappend("SYSLOG_IDENTIFIER=", identifier);
syslog_identifier = strjoin("SYSLOG_IDENTIFIER=", identifier);
if (syslog_identifier)
iovec[n++] = IOVEC_MAKE_STRING(syslog_identifier);
}
if (pid) {
syslog_pid = strappend("SYSLOG_PID=", pid);
syslog_pid = strjoin("SYSLOG_PID=", pid);
if (syslog_pid)
iovec[n++] = IOVEC_MAKE_STRING(syslog_pid);
}

View File

@ -737,7 +737,7 @@ static void server_cache_hostname(Server *s) {
if (!t)
return;
x = strappend("_HOSTNAME=", t);
x = strjoin("_HOSTNAME=", t);
if (!x)
return;

View File

@ -294,7 +294,7 @@ static int stdout_stream_log(StdoutStream *s, const char *p, LineBreak line_brea
}
if (s->identifier) {
syslog_identifier = strappend("SYSLOG_IDENTIFIER=", s->identifier);
syslog_identifier = strjoin("SYSLOG_IDENTIFIER=", s->identifier);
if (syslog_identifier)
iovec[n++] = IOVEC_MAKE_STRING(syslog_identifier);
}
@ -311,7 +311,7 @@ static int stdout_stream_log(StdoutStream *s, const char *p, LineBreak line_brea
iovec[n++] = IOVEC_MAKE_STRING(c);
}
message = strappend("MESSAGE=", p);
message = strjoin("MESSAGE=", p);
if (message)
iovec[n++] = IOVEC_MAKE_STRING(message);
@ -649,7 +649,7 @@ static int stdout_stream_load(StdoutStream *stream, const char *fname) {
assert(fname);
if (!stream->state_file) {
stream->state_file = strappend("/run/systemd/journal/streams/", fname);
stream->state_file = path_join("/run/systemd/journal/streams", fname);
if (!stream->state_file)
return log_oom();
}

View File

@ -10,6 +10,7 @@
#include "journal-file.h"
#include "journal-internal.h"
#include "macro.h"
#include "path-util.h"
#include "string-util.h"
int main(int argc, char *argv[]) {
@ -23,7 +24,7 @@ int main(int argc, char *argv[]) {
assert_se(mkdtemp(dn));
(void) chattr_path(dn, FS_NOCOW_FL, FS_NOCOW_FL, NULL);
fn = strappend(dn, "/test.journal");
fn = path_join(dn, "test.journal");
r = journal_file_open(-1, fn, O_CREAT|O_RDWR, 0644, false, 0, false, NULL, NULL, NULL, NULL, &new_journal);
assert_se(r >= 0);

View File

@ -180,7 +180,7 @@ static int errno_to_bus_error_name_new(int error, char **ret) {
if (!name)
return 0;
n = strappend("System.Error.", name);
n = strjoin("System.Error.", name);
if (!n)
return -ENOMEM;

View File

@ -314,7 +314,7 @@ static int file_of_seat(const char *seat, char **_p) {
if (!filename_is_valid(seat))
return -EINVAL;
p = strappend("/run/systemd/seats/", seat);
p = path_join("/run/systemd/seats", seat);
} else {
_cleanup_free_ char *buf = NULL;
@ -322,9 +322,8 @@ static int file_of_seat(const char *seat, char **_p) {
if (r < 0)
return r;
p = strappend("/run/systemd/seats/", buf);
p = path_join("/run/systemd/seats", buf);
}
if (!p)
return -ENOMEM;
@ -427,7 +426,7 @@ static int file_of_session(const char *session, char **_p) {
if (!session_id_valid(session))
return -EINVAL;
p = strappend("/run/systemd/sessions/", session);
p = path_join("/run/systemd/sessions", session);
} else {
_cleanup_free_ char *buf = NULL;
@ -435,7 +434,7 @@ static int file_of_session(const char *session, char **_p) {
if (r < 0)
return r;
p = strappend("/run/systemd/sessions/", buf);
p = path_join("/run/systemd/sessions", buf);
}
if (!p)

View File

@ -83,7 +83,7 @@ static int from_user_dir(const char *field, char **buffer, const char **ret) {
if (r < 0)
return r;
fn = strappend(c, "/user-dirs.dirs");
fn = path_join(c, "user-dirs.dirs");
if (!fn)
return -ENOMEM;
@ -141,7 +141,7 @@ static int from_user_dir(const char *field, char **buffer, const char **ret) {
if (r < 0)
return r;
cc = strappend(h, p+5);
cc = path_join(h, p+5);
if (!cc)
return -ENOMEM;
@ -179,7 +179,7 @@ fallback:
if (r < 0)
return r;
cc = strappend(h, "/Desktop");
cc = path_join(h, "Desktop");
if (!cc)
return -ENOMEM;

View File

@ -353,7 +353,7 @@ int vconsole_write_data(Context *c) {
_cleanup_free_ char *s = NULL;
char **u;
s = strappend("KEYMAP=", c->vc_keymap);
s = strjoin("KEYMAP=", c->vc_keymap);
if (!s)
return -ENOMEM;
@ -370,7 +370,7 @@ int vconsole_write_data(Context *c) {
_cleanup_free_ char *s = NULL;
char **u;
s = strappend("KEYMAP_TOGGLE=", c->vc_keymap_toggle);
s = strjoin("KEYMAP_TOGGLE=", c->vc_keymap_toggle);
if (!s)
return -ENOMEM;

View File

@ -222,7 +222,7 @@ int devnode_acl_all(const char *seat,
if (cunescape(dent->d_name, UNESCAPE_RELAX, &unescaped_devname) < 0)
return -ENOMEM;
n = strappend("/dev/", unescaped_devname);
n = path_join("/dev", unescaped_devname);
if (!n)
return -ENOMEM;

View File

@ -1322,7 +1322,7 @@ static int trigger_device(Manager *m, sd_device *d) {
if (r < 0)
return r;
t = strappend(p, "/uevent");
t = path_join(p, "uevent");
if (!t)
return -ENOMEM;

View File

@ -17,6 +17,7 @@
#include "logind-inhibit.h"
#include "mkdir.h"
#include "parse-util.h"
#include "path-util.h"
#include "string-table.h"
#include "string-util.h"
#include "tmpfile-util.h"
@ -32,7 +33,7 @@ Inhibitor* inhibitor_new(Manager *m, const char* id) {
if (!i)
return NULL;
i->state_file = strappend("/run/systemd/inhibit/", id);
i->state_file = path_join("/run/systemd/inhibit", id);
if (!i->state_file)
return mfree(i);

View File

@ -304,7 +304,7 @@ char *seat_bus_path(Seat *s) {
if (!t)
return NULL;
return strappend("/org/freedesktop/login1/seat/", t);
return strjoin("/org/freedesktop/login1/seat/", t);
}
int seat_node_enumerator(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *error) {

View File

@ -19,6 +19,7 @@
#include "logind-session-dbus.h"
#include "mkdir.h"
#include "parse-util.h"
#include "path-util.h"
#include "stdio-util.h"
#include "string-util.h"
#include "terminal-util.h"
@ -44,7 +45,7 @@ int seat_new(Seat** ret, Manager *m, const char *id) {
.manager = m,
};
s->state_file = strappend("/run/systemd/seats/", id);
s->state_file = path_join("/run/systemd/seats", id);
if (!s->state_file)
return -ENOMEM;

View File

@ -634,7 +634,7 @@ char *session_bus_path(Session *s) {
if (!t)
return NULL;
return strappend("/org/freedesktop/login1/session/", t);
return strjoin("/org/freedesktop/login1/session/", t);
}
int session_node_enumerator(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *error) {

View File

@ -67,7 +67,7 @@ int session_new(Session **ret, Manager *m, const char *id) {
.tty_validity = _TTY_VALIDITY_INVALID,
};
s->state_file = strappend("/run/systemd/sessions/", id);
s->state_file = path_join("/run/systemd/sessions", id);
if (!s->state_file)
return -ENOMEM;
@ -899,7 +899,7 @@ static int get_tty_atime(const char *tty, usec_t *atime) {
assert(atime);
if (!path_is_absolute(tty)) {
p = strappend("/dev/", tty);
p = path_join("/dev", tty);
if (!p)
return -ENOMEM;

View File

@ -109,7 +109,7 @@ static int show_sysfs_one(
if (++(*i_dev) < n_dev) {
_cleanup_free_ char *p = NULL;
p = strappend(prefix, lookahead < n_dev ? special_glyph(SPECIAL_GLYPH_TREE_VERTICAL) : " ");
p = strjoin(prefix, lookahead < n_dev ? special_glyph(SPECIAL_GLYPH_TREE_VERTICAL) : " ");
if (!p)
return -ENOMEM;

View File

@ -458,7 +458,7 @@ char *image_bus_path(const char *name) {
if (!e)
return NULL;
return strappend("/org/freedesktop/machine1/image/", e);
return strjoin("/org/freedesktop/machine1/image/", e);
}
int image_node_enumerator(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *error) {

View File

@ -1383,7 +1383,7 @@ char *machine_bus_path(Machine *m) {
if (!e)
return NULL;
return strappend("/org/freedesktop/machine1/machine/", e);
return strjoin("/org/freedesktop/machine1/machine/", e);
}
int machine_node_enumerator(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *error) {

View File

@ -22,6 +22,7 @@
#include "machine.h"
#include "mkdir.h"
#include "parse-util.h"
#include "path-util.h"
#include "process-util.h"
#include "serialize.h"
#include "special.h"
@ -53,7 +54,7 @@ Machine* machine_new(Manager *manager, MachineClass class, const char *name) {
goto fail;
if (class != MACHINE_HOST) {
m->state_file = strappend("/run/systemd/machines/", m->name);
m->state_file = path_join("/run/systemd/machines", m->name);
if (!m->state_file)
goto fail;
}

View File

@ -166,7 +166,7 @@ static int run(int argc, char* argv[]) {
our_env[i++] = (char*) "READY=1";
if (arg_status) {
status = strappend("STATUS=", arg_status);
status = strjoin("STATUS=", arg_status);
if (!status)
return log_oom();

View File

@ -489,7 +489,7 @@ int setup_macvlan(const char *machine_name, pid_t pid, char **ifaces) {
if (r < 0)
return log_error_errno(r, "Failed to add netlink interface index: %m");
n = strappend("mv-", *i);
n = strjoin("mv-", *i);
if (!n)
return log_oom();
@ -564,7 +564,7 @@ int setup_ipvlan(const char *machine_name, pid_t pid, char **ifaces) {
if (r < 0)
return log_error_errno(r, "Failed to add netlink interface index: %m");
n = strappend("iv-", *i);
n = strjoin("iv-", *i);
if (!n)
return log_oom();

View File

@ -505,7 +505,7 @@ int config_parse_network_zone(
assert(lvalue);
assert(rvalue);
j = strappend("vz-", rvalue);
j = strjoin("vz-", rvalue);
if (!ifname_valid(j)) {
log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid network zone name, ignoring: %s", rvalue);
return 0;

View File

@ -725,7 +725,7 @@ static int parse_argv(int argc, char *argv[]) {
case ARG_NETWORK_ZONE: {
char *j;
j = strappend("vz-", optarg);
j = strjoin("vz-", optarg);
if (!j)
return log_oom();

View File

@ -1281,7 +1281,7 @@ static int read_domain_one(sd_bus_message *m, bool with_ifindex, char **ret) {
}
if (route_only)
str = strappend("~", domain);
str = strjoin("~", domain);
else
str = strdup(domain);
if (!str)

View File

@ -161,7 +161,7 @@ int dns_answer_add_soa(DnsAnswer *a, const char *name, uint32_t ttl, int ifindex
if (!soa->soa.mname)
return -ENOMEM;
soa->soa.rname = strappend("root.", name);
soa->soa.rname = strjoin("root.", name);
if (!soa->soa.rname)
return -ENOMEM;

View File

@ -2182,7 +2182,7 @@ static int dnssec_test_positive_wildcard_nsec(
return -EBADMSG;
/* Replace the label we stripped off with an asterisk */
wc = strappend("*.", name);
wc = strjoin("*.", name);
if (!wc)
return -ENOMEM;

View File

@ -1500,7 +1500,7 @@ void manager_cleanup_saved_user(Manager *m) {
continue;
rm:
p = strappend("/run/systemd/resolve/netif/", de->d_name);
p = path_join("/run/systemd/resolve/netif", de->d_name);
if (!p) {
log_oom();
return;

View File

@ -241,7 +241,7 @@ static int dump_processes(
special = special_glyph(more ? SPECIAL_GLYPH_TREE_VERTICAL : SPECIAL_GLYPH_TREE_SPACE);
pp = strappend(prefix, special);
pp = strjoin(prefix, special);
if (!pp)
return -ENOMEM;

View File

@ -313,7 +313,7 @@ static int bus_append_exec_command(sd_bus_message *m, const char *field, const c
if (!is_ex_prop && (flags & (EXEC_COMMAND_NO_ENV_EXPAND|EXEC_COMMAND_FULLY_PRIVILEGED|EXEC_COMMAND_NO_SETUID|EXEC_COMMAND_AMBIENT_MAGIC))) {
/* Upgrade the ExecXYZ= property to ExecXYZEx= for convenience */
is_ex_prop = true;
upgraded_name = strappend(field, "Ex");
upgraded_name = strjoin(field, "Ex");
if (!upgraded_name)
return log_oom();
}

View File

@ -990,7 +990,7 @@ int bus_message_print_all_properties(
return log_oom();
}
name_with_equal = strappend(name, "=");
name_with_equal = strjoin(name, "=");
if (!name_with_equal)
return log_oom();

View File

@ -165,7 +165,7 @@ int show_cgroup_by_path(
printf("%s%s%s\n", prefix, special_glyph(SPECIAL_GLYPH_TREE_BRANCH), cg_unescape(basename(last)));
if (!p1) {
p1 = strappend(prefix, special_glyph(SPECIAL_GLYPH_TREE_VERTICAL));
p1 = strjoin(prefix, special_glyph(SPECIAL_GLYPH_TREE_VERTICAL));
if (!p1)
return -ENOMEM;
}
@ -187,7 +187,7 @@ int show_cgroup_by_path(
printf("%s%s%s\n", prefix, special_glyph(SPECIAL_GLYPH_TREE_RIGHT), cg_unescape(basename(last)));
if (!p2) {
p2 = strappend(prefix, " ");
p2 = strjoin(prefix, " ");
if (!p2)
return -ENOMEM;
}

View File

@ -2308,7 +2308,7 @@ int unit_file_revert(
has_vendor = true;
}
dropin = strappend(path, ".d");
dropin = strjoin(path, ".d");
if (!dropin)
return -ENOMEM;

View File

@ -87,8 +87,8 @@ static char **image_settings_path(Image *image) {
fn = strjoina(image->name, ".nspawn");
FOREACH_STRING(s, "/etc/systemd/nspawn/", "/run/systemd/nspawn/") {
l[i] = strappend(s, fn);
FOREACH_STRING(s, "/etc/systemd/nspawn", "/run/systemd/nspawn") {
l[i] = path_join(s, fn);
if (!l[i])
return NULL;
@ -441,7 +441,7 @@ int image_find(ImageClass class, const char *name, Image **ret) {
if (errno != ENOENT)
return -errno;
raw = strappend(name, ".raw");
raw = strjoin(name, ".raw");
if (!raw)
return -ENOMEM;

View File

@ -32,7 +32,7 @@ int xdg_user_runtime_dir(char **ret, const char *suffix) {
if (!e)
return -ENXIO;
j = strappend(e, suffix);
j = strjoin(e, suffix);
if (!j)
return -ENOMEM;
@ -49,7 +49,7 @@ int xdg_user_config_dir(char **ret, const char *suffix) {
e = getenv("XDG_CONFIG_HOME");
if (e)
j = strappend(e, suffix);
j = strjoin(e, suffix);
else {
_cleanup_free_ char *home = NULL;
@ -81,7 +81,7 @@ int xdg_user_data_dir(char **ret, const char *suffix) {
e = getenv("XDG_DATA_HOME");
if (e)
j = strappend(e, suffix);
j = strjoin(e, suffix);
else {
_cleanup_free_ char *home = NULL;
@ -270,15 +270,15 @@ static int acquire_generator_dirs(
prefix = strjoina(e, "/systemd");
}
x = strappend(prefix, "/generator");
x = path_join(prefix, "generator");
if (!x)
return -ENOMEM;
y = strappend(prefix, "/generator.early");
y = path_join(prefix, "generator.early");
if (!y)
return -ENOMEM;
z = strappend(prefix, "/generator.late");
z = path_join(prefix, "generator.late");
if (!z)
return -ENOMEM;

View File

@ -236,7 +236,7 @@ static int parse_argv(int argc, char *argv[]) {
if (path_startswith(optarg, "/proc/sys"))
p = strdup(optarg);
else
p = strappend("/proc/sys/", optarg);
p = path_join("/proc/sys", optarg);
if (!p)
return log_oom();

View File

@ -6459,7 +6459,7 @@ static int enable_sysv_units(const char *verb, char **args) {
}
if (!isempty(arg_root)) {
q = strappend("--root=", arg_root);
q = strjoin("--root=", arg_root);
if (!q)
return log_oom();

View File

@ -642,7 +642,7 @@ static int load_sysv(SysvStub *s) {
if (description) {
char *d;
d = strappend(s->has_lsb ? "LSB: " : "SYSV: ", description);
d = strjoin(s->has_lsb ? "LSB: " : "SYSV: ", description);
if (!d)
return log_oom();

View File

@ -30,7 +30,7 @@ static void setup_test_dir(char *tmp_dir, const char *files, ...) {
while (files) {
_cleanup_free_ char *path;
assert_se(path = strappend(tmp_dir, files));
assert_se(path = path_join(tmp_dir, files));
(void) mkdir_parents(path, 0755);
assert_se(write_string_file(path, "foobar", WRITE_STRING_FILE_CREATE) >= 0);

View File

@ -92,7 +92,7 @@ static void test_copy_tree(void) {
STRV_FOREACH(p, files) {
_cleanup_free_ char *f;
assert_se(f = strappend(original_dir, *p));
assert_se(f = path_join(original_dir, *p));
assert_se(mkdir_parents(f, 0755) >= 0);
assert_se(write_string_file(f, "file", WRITE_STRING_FILE_CREATE) == 0);
@ -101,8 +101,8 @@ static void test_copy_tree(void) {
STRV_FOREACH_PAIR(link, p, links) {
_cleanup_free_ char *f, *l;
assert_se(f = strappend(original_dir, *p));
assert_se(l = strappend(original_dir, *link));
assert_se(f = path_join(original_dir, *p));
assert_se(l = path_join(original_dir, *link));
assert_se(mkdir_parents(l, 0755) >= 0);
assert_se(symlink(f, l) == 0);
@ -117,7 +117,7 @@ static void test_copy_tree(void) {
_cleanup_free_ char *buf, *f;
size_t sz;
assert_se(f = strappend(copy_dir, *p));
assert_se(f = path_join(copy_dir, *p));
assert_se(access(f, F_OK) == 0);
assert_se(read_full_file(f, &buf, &sz) == 0);

View File

@ -327,7 +327,7 @@ static void test_strv_resolve(void) {
search_dirs = strv_new("/dir1", "/dir2", "/dir3");
assert_se(search_dirs);
STRV_FOREACH(d, search_dirs) {
char *p = strappend(tmp_dir, *d);
char *p = path_join(tmp_dir, *d);
assert_se(p);
assert_se(strv_push(&absolute_dirs, p) == 0);
}

View File

@ -250,22 +250,6 @@ static void test_strrep(void) {
assert_se(streq(zero, ""));
}
static void test_strappend(void) {
_cleanup_free_ char *t1, *t2, *t3, *t4;
t1 = strappend(NULL, NULL);
assert_se(streq(t1, ""));
t2 = strappend(NULL, "suf");
assert_se(streq(t2, "suf"));
t3 = strappend("pre", NULL);
assert_se(streq(t3, "pre"));
t4 = strappend("pre", "suf");
assert_se(streq(t4, "presuf"));
}
static void test_string_has_cc(void) {
assert_se(string_has_cc("abc\1", NULL));
assert_se(string_has_cc("abc\x7f", NULL));
@ -568,7 +552,6 @@ int main(int argc, char *argv[]) {
test_strextend();
test_strextend_with_separator();
test_strrep();
test_strappend();
test_string_has_cc();
test_ascii_strlower();
test_strshorten();

View File

@ -227,7 +227,7 @@ static int context_write_data_timezone(Context *c) {
return r;
}
p = strappend("../usr/share/zoneinfo/", c->zone);
p = path_join("../usr/share/zoneinfo", c->zone);
if (!p)
return log_oom();

View File

@ -2597,7 +2597,7 @@ static int parse_line(const char *fname, unsigned line, const char *buffer, bool
case CREATE_SYMLINK:
if (!i.argument) {
i.argument = path_join("/usr/share/factory/", i.path);
i.argument = path_join("/usr/share/factory", i.path);
if (!i.argument)
return log_oom();
}
@ -2613,7 +2613,7 @@ static int parse_line(const char *fname, unsigned line, const char *buffer, bool
case COPY_FILES:
if (!i.argument) {
i.argument = path_join(arg_root, "/usr/share/factory/", i.path);
i.argument = path_join(arg_root, "/usr/share/factory", i.path);
if (!i.argument)
return log_oom();

View File

@ -480,7 +480,7 @@ static int show_passwords(void) {
if (!startswith(de->d_name, "ask."))
continue;
p = strappend("/run/systemd/ask-password/", de->d_name);
p = path_join("/run/systemd/ask-password", de->d_name);
if (!p)
return log_oom();