]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
fd-util: minor shortcut
authorLennart Poettering <lennart@amutable.com>
Wed, 25 Feb 2026 12:08:34 +0000 (13:08 +0100)
committerLennart Poettering <lennart@amutable.com>
Tue, 3 Mar 2026 07:48:01 +0000 (08:48 +0100)
src/basic/fd-util.c

index 4d720e014eef93f818f44f4401d26ced6ee48389..e032bb62ac11009fd9bf8decbb55b0bce39b6705 100644 (file)
@@ -1085,6 +1085,9 @@ int fds_inode_and_mount_same(int fd1, int fd2) {
         if (r < 0)
                 return r;
 
+        if (fd1 == fd2) /* Shortcut things if fds are the same (only after validating the fd) */
+                return true;
+
         r = xstatx(fd2, /* path = */ NULL, AT_EMPTY_PATH,
                    STATX_TYPE|STATX_INO|STATX_MNT_ID,
                    &sx2);