]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
chase: drop CHASE_AT_RESOLVE_IN_ROOT earlier
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 20 Jul 2023 12:17:32 +0000 (21:17 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 29 Jul 2023 12:58:29 +0000 (21:58 +0900)
The flag will be anyway dropped in chaseat(), but let's shortcut.

src/basic/chase.c

index 8f9c361a098d08cebe15e7a18925869d6aac0fe8..e66070b5d11b2062fd9e65df2763ff236a74e4e0 100644 (file)
@@ -511,9 +511,14 @@ int chase(const char *path, const char *root, ChaseFlags flags, char **ret_path,
                 return -EINVAL;
 
         /* A root directory of "/" or "" is identical to "/". */
-        if (empty_or_root(root))
+        if (empty_or_root(root)) {
                 root = "/";
-        else {
+
+                /* When the root directory is "/", we will drop CHASE_AT_RESOLVE_IN_ROOT in chaseat(),
+                 * hence below is not necessary, but let's shortcut. */
+                flags &= ~CHASE_AT_RESOLVE_IN_ROOT;
+
+        } else {
                 r = path_make_absolute_cwd(root, &root_abs);
                 if (r < 0)
                         return r;