Merge pull request #4510 from keszybz/tree-wide-cleanups
Tree wide cleanups
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
+3
-3
@@ -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;
|
||||
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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, ...) \
|
||||
({ \
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
+1
-1
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user