tree-wide: always drop unnecessary dot in path

This commit is contained in:
Yu Watanabe
2021-05-28 13:44:38 +09:00
parent 0195046449
commit 4ff361cc86
41 changed files with 91 additions and 98 deletions
+5 -5
View File
@@ -506,7 +506,7 @@ int cg_get_path(const char *controller, const char *path, const char *suffix, ch
if (!t)
return -ENOMEM;
*fs = path_simplify(t, false);
*fs = path_simplify(t);
return 0;
}
@@ -523,7 +523,7 @@ int cg_get_path(const char *controller, const char *path, const char *suffix, ch
if (r < 0)
return r;
path_simplify(*fs, false);
path_simplify(*fs);
return 0;
}
@@ -919,7 +919,7 @@ int cg_split_spec(const char *spec, char **ret_controller, char **ret_path) {
if (!path)
return -ENOMEM;
path_simplify(path, false);
path_simplify(path);
}
} else {
@@ -942,7 +942,7 @@ int cg_split_spec(const char *spec, char **ret_controller, char **ret_path) {
!path_is_absolute(path))
return -EINVAL;
path_simplify(path, false);
path_simplify(path);
}
} else {
@@ -979,7 +979,7 @@ int cg_mangle_path(const char *path, char **result) {
if (!t)
return -ENOMEM;
*result = path_simplify(t, false);
*result = path_simplify(t);
return 0;
}
+3 -3
View File
@@ -972,7 +972,7 @@ static int search_and_fopen_internal(
f = fopen(p, mode);
if (f) {
if (ret_path)
*ret_path = path_simplify(TAKE_PTR(p), true);
*ret_path = path_simplify(TAKE_PTR(p));
*ret = f;
return 0;
@@ -1013,7 +1013,7 @@ int search_and_fopen(
if (!p)
return -ENOMEM;
*ret_path = path_simplify(p, true);
*ret_path = path_simplify(p);
}
*ret = TAKE_PTR(f);
@@ -1051,7 +1051,7 @@ int search_and_fopen_nulstr(
if (!p)
return -ENOMEM;
*ret_path = path_simplify(p, true);
*ret_path = path_simplify(p);
}
*ret = TAKE_PTR(f);
+1 -1
View File
@@ -866,7 +866,7 @@ int chase_symlinks(const char *path, const char *original_root, unsigned flags,
* anyway. Moreover at the end of this function after processing everything we'll always turn
* the empty string back to "/". */
delete_trailing_chars(root, "/");
path_simplify(root, true);
path_simplify(root);
if (flags & CHASE_PREFIX_ROOT) {
/* We don't support relative paths in combination with a root directory */
+9 -9
View File
@@ -145,7 +145,7 @@ int path_make_relative(const char *from, const char *to, char **ret) {
if (!result)
return -ENOMEM;
path_simplify(result, true);
path_simplify(result);
if (!path_is_valid(result))
return -EINVAL;
@@ -191,7 +191,7 @@ int path_make_relative(const char *from, const char *to, char **ret) {
strcpy(p, t);
path_simplify(result, true);
path_simplify(result);
if (!path_is_valid(result))
return -EINVAL;
@@ -227,7 +227,7 @@ int path_strv_make_absolute_cwd(char **l) {
if (r < 0)
return r;
path_simplify(t, false);
path_simplify(t);
free_and_replace(*s, t);
}
@@ -327,7 +327,7 @@ char **path_strv_resolve_uniq(char **l, const char *root) {
return strv_uniq(l);
}
char *path_simplify(char *path, bool kill_dots) {
char *path_simplify(char *path) {
char *f, *t;
bool slash = false, ignore_slash = false, absolute;
@@ -348,7 +348,7 @@ char *path_simplify(char *path, bool kill_dots) {
absolute = path_is_absolute(path);
f = path;
if (kill_dots && *f == '.' && IN_SET(f[1], 0, '/')) {
if (*f == '.' && IN_SET(f[1], 0, '/')) {
ignore_slash = true;
f++;
}
@@ -361,7 +361,7 @@ char *path_simplify(char *path, bool kill_dots) {
}
if (slash) {
if (kill_dots && *f == '.' && IN_SET(f[1], 0, '/'))
if (*f == '.' && IN_SET(f[1], 0, '/'))
continue;
slash = false;
@@ -418,7 +418,7 @@ int path_simplify_and_warn(
lvalue, fatal ? "" : ", ignoring", path);
}
path_simplify(path, true);
path_simplify(path);
if (!path_is_valid(path))
return log_syntax(unit, LOG_ERR, filename, line, SYNTHETIC_ERRNO(EINVAL),
@@ -711,7 +711,7 @@ int find_executable_full(const char *name, bool use_path_envvar, char **ret_file
/* Found it! */
if (ret_filename)
*ret_filename = path_simplify(TAKE_PTR(element), false);
*ret_filename = path_simplify(TAKE_PTR(element));
if (ret_fd)
*ret_fd = TAKE_FD(fd);
@@ -1116,7 +1116,7 @@ int path_extract_directory(const char *path, char **ret) {
if (!a)
return -ENOMEM;
path_simplify(a, true);
path_simplify(a);
if (!path_is_valid(a))
return -EINVAL;
+3 -3
View File
@@ -71,7 +71,7 @@ char* path_extend_internal(char **x, ...);
#define path_extend(x, ...) path_extend_internal(x, __VA_ARGS__, POINTER_MAX)
#define path_join(...) path_extend_internal(NULL, __VA_ARGS__, POINTER_MAX)
char* path_simplify(char *path, bool kill_dots);
char* path_simplify(char *path);
enum {
PATH_CHECK_FATAL = 1 << 0, /* If not set, then error message is appended with 'ignoring'. */
@@ -109,7 +109,7 @@ int fsck_exists(const char *fstype);
* directory. Excludes the specified directory itself */
#define PATH_FOREACH_PREFIX(prefix, path) \
for (char *_slash = ({ \
path_simplify(strcpy(prefix, path), false); \
path_simplify(strcpy(prefix, path)); \
streq(prefix, "/") ? NULL : strrchr(prefix, '/'); \
}); \
_slash && ((*_slash = 0), true); \
@@ -118,7 +118,7 @@ int fsck_exists(const char *fstype);
/* Same as PATH_FOREACH_PREFIX but also includes the specified path itself */
#define PATH_FOREACH_PREFIX_MORE(prefix, path) \
for (char *_slash = ({ \
path_simplify(strcpy(prefix, path), false); \
path_simplify(strcpy(prefix, path)); \
if (streq(prefix, "/")) \
prefix[0] = 0; \
strrchr(prefix, 0); \
+1 -1
View File
@@ -33,7 +33,7 @@ char *sysctl_normalize(char *s) {
n = strpbrk(n + 1, "/.");
} while (n);
path_simplify(s, true);
path_simplify(s);
/* Kill the leading slash, but keep the first character of the string in the same place. */
if (*s == '/' && *(s+1))
+3 -3
View File
@@ -126,7 +126,7 @@ int tempfn_xxxxxx(const char *p, const char *extra, char **ret) {
if (!path_extend(&d, nf))
return -ENOMEM;
*ret = path_simplify(TAKE_PTR(d), false);
*ret = path_simplify(TAKE_PTR(d));
} else
*ret = TAKE_PTR(nf);
@@ -168,7 +168,7 @@ int tempfn_random(const char *p, const char *extra, char **ret) {
if (!path_extend(&d, nf))
return -ENOMEM;
*ret = path_simplify(TAKE_PTR(d), false);
*ret = path_simplify(TAKE_PTR(d));
} else
*ret = TAKE_PTR(nf);
@@ -213,7 +213,7 @@ int tempfn_random_child(const char *p, const char *extra, char **ret) {
*x = 0;
*ret = path_simplify(t, false);
*ret = path_simplify(t);
return 0;
}
+1 -1
View File
@@ -387,7 +387,7 @@ int unit_name_path_escape(const char *f, char **ret) {
if (!p)
return -ENOMEM;
path_simplify(p, false);
path_simplify(p);
if (empty_or_root(p))
s = strdup("-");
+4 -4
View File
@@ -571,7 +571,7 @@ int get_home_dir(char **_h) {
if (!h)
return -ENOMEM;
*_h = path_simplify(h, true);
*_h = path_simplify(h);
return 0;
}
@@ -609,7 +609,7 @@ int get_home_dir(char **_h) {
if (!h)
return -ENOMEM;
*_h = path_simplify(h, true);
*_h = path_simplify(h);
return 0;
}
@@ -628,7 +628,7 @@ int get_shell(char **_s) {
if (!s)
return -ENOMEM;
*_s = path_simplify(s, true);
*_s = path_simplify(s);
return 0;
}
@@ -666,7 +666,7 @@ int get_shell(char **_s) {
if (!s)
return -ENOMEM;
*_s = path_simplify(s, true);
*_s = path_simplify(s);
return 0;
}