summaryrefslogtreecommitdiff
path: root/src/basic
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-11-03 13:59:20 -0600
committerGitHub <noreply@github.com>2016-11-03 13:59:20 -0600
commit493fd52f1ada36bfe63301d4bb50f7fd2b38c670 (patch)
tree19864f5568a2fe48181c1b3f33c46b4db36dd768 /src/basic
parenta1e2ef7ec912902d8142e7cb5830cbfb47dba86c (diff)
parent9aa2169eaeb20994fb2b0196c051cff52f57a93d (diff)
Merge pull request #4510 from keszybz/tree-wide-cleanups
Tree wide cleanups
Diffstat (limited to 'src/basic')
-rw-r--r--src/basic/btrfs-util.c2
-rw-r--r--src/basic/cgroup-util.c16
-rw-r--r--src/basic/conf-files.c2
-rw-r--r--src/basic/fileio.c6
-rw-r--r--src/basic/fs-util.c2
-rw-r--r--src/basic/mount-util.c2
-rw-r--r--src/basic/path-util.c12
-rw-r--r--src/basic/process-util.c6
-rw-r--r--src/basic/string-util.c2
-rw-r--r--src/basic/string-util.h3
-rw-r--r--src/basic/unit-name.c4
-rw-r--r--src/basic/util.c2
12 files changed, 29 insertions, 30 deletions
diff --git a/src/basic/btrfs-util.c b/src/basic/btrfs-util.c
index 359d85f2e8..656bb13719 100644
--- a/src/basic/btrfs-util.c
+++ b/src/basic/btrfs-util.c
@@ -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;
diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c
index cede835920..5fce32f769 100644
--- a/src/basic/cgroup-util.c
+++ b/src/basic/cgroup-util.c
@@ -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;
diff --git a/src/basic/conf-files.c b/src/basic/conf-files.c
index c781610e14..c0c22610d7 100644
--- a/src/basic/conf-files.c
+++ b/src/basic/conf-files.c
@@ -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;
diff --git a/src/basic/fileio.c b/src/basic/fileio.c
index 1cfb7a98f5..1615456659 100644
--- a/src/basic/fileio.c
+++ b/src/basic/fileio.c
@@ -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;
diff --git a/src/basic/fs-util.c b/src/basic/fs-util.c
index 48952a1c26..d2c322a0de 100644
--- a/src/basic/fs-util.c
+++ b/src/basic/fs-util.c
@@ -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;
diff --git a/src/basic/mount-util.c b/src/basic/mount-util.c
index c8f8022578..5d37fb48be 100644
--- a/src/basic/mount-util.c
+++ b/src/basic/mount-util.c
@@ -642,7 +642,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)
diff --git a/src/basic/path-util.c b/src/basic/path-util.c
index fd38f51c4c..5cdac50c68 100644
--- a/src/basic/path-util.c
+++ b/src/basic/path-util.c
@@ -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;
@@ -454,13 +454,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) {
@@ -504,7 +502,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;
diff --git a/src/basic/process-util.c b/src/basic/process-util.c
index 54b644ad56..48a5c719af 100644
--- a/src/basic/process-util.c
+++ b/src/basic/process-util.c
@@ -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)
diff --git a/src/basic/string-util.c b/src/basic/string-util.c
index 6b06e643c9..2ba3604ba0 100644
--- a/src/basic/string-util.c
+++ b/src/basic/string-util.c
@@ -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;
diff --git a/src/basic/string-util.h b/src/basic/string-util.h
index d029d538bd..0175803302 100644
--- a/src/basic/string-util.h
+++ b/src/basic/string-util.h
@@ -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, ...) \
({ \
diff --git a/src/basic/unit-name.c b/src/basic/unit-name.c
index fe883b95c7..0a6efa449a 100644
--- a/src/basic/unit-name.c
+++ b/src/basic/unit-name.c
@@ -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;
diff --git a/src/basic/util.c b/src/basic/util.c
index ec7939dc83..0f65e4839c 100644
--- a/src/basic/util.c
+++ b/src/basic/util.c
@@ -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();