From: Yu Watanabe Date: Mon, 3 May 2021 14:46:47 +0000 (+0900) Subject: path-util: use path_equal() in empty_or_root() X-Git-Tag: v249-rc1~131^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=15bac3e8fddad0141f0e3992f6caf1ec1500aa82;p=thirdparty%2Fsystemd.git path-util: use path_equal() in empty_or_root() --- diff --git a/src/basic/path-util.c b/src/basic/path-util.c index ef2ba440621..e91a17b398a 100644 --- a/src/basic/path-util.c +++ b/src/basic/path-util.c @@ -1264,15 +1264,15 @@ bool dot_or_dot_dot(const char *path) { return path[2] == 0; } -bool empty_or_root(const char *root) { +bool empty_or_root(const char *path) { /* For operations relative to some root directory, returns true if the specified root directory is redundant, * i.e. either / or NULL or the empty string or any equivalent. */ - if (!root) + if (isempty(path)) return true; - return root[strspn(root, "/")] == 0; + return path_equal(path, "/"); } bool path_strv_contains(char **l, const char *path) { diff --git a/src/basic/path-util.h b/src/basic/path-util.h index fad40bd8b6e..9fa8b5b75cf 100644 --- a/src/basic/path-util.h +++ b/src/basic/path-util.h @@ -190,7 +190,7 @@ static inline const char *skip_dev_prefix(const char *p) { return e ?: p; } -bool empty_or_root(const char *root); +bool empty_or_root(const char *path); static inline const char *empty_to_root(const char *path) { return isempty(path) ? "/" : path; }