]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
stat-util: drop unnecessary call of xopenat() in xstatfsat()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 4 Apr 2025 11:24:40 +0000 (20:24 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 4 Apr 2025 15:13:01 +0000 (00:13 +0900)
src/basic/stat-util.c

index f328f4a78c856f93b4263d8ef52914ef988739bc..afe9e25bbd9340f933686e93e07a50206c52f698 100644 (file)
@@ -488,11 +488,14 @@ int xstatfsat(int dir_fd, const char *path, struct statfs *ret) {
         assert(dir_fd >= 0 || dir_fd == AT_FDCWD);
         assert(ret);
 
-        fd = xopenat(dir_fd, path, O_PATH|O_CLOEXEC|O_NOCTTY);
-        if (fd < 0)
-                return fd;
+        if (!isempty(path)) {
+                fd = xopenat(dir_fd, path, O_PATH|O_CLOEXEC|O_NOCTTY);
+                if (fd < 0)
+                        return fd;
+                dir_fd = fd;
+        }
 
-        return RET_NERRNO(fstatfs(fd, ret));
+        return RET_NERRNO(fstatfs(dir_fd, ret));
 }
 
 void inode_hash_func(const struct stat *q, struct siphash *state) {