]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
chown: Avoid a redundant stat() call.
authorBruno Haible <bruno@clisp.org>
Thu, 14 Aug 2025 20:05:37 +0000 (22:05 +0200)
committerBruno Haible <bruno@clisp.org>
Thu, 14 Aug 2025 22:23:24 +0000 (00:23 +0200)
* lib/chown.c (rpl_chown): Set stat_valid after stat() succeeded.

ChangeLog
lib/chown.c

index b072f949d724e6595d0aee7e79547d863e739f54..b69ff7406ccd4a09b32aab6d10f552764e4fb3f5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2025-08-14  Bruno Haible  <bruno@clisp.org>
+
+       chown: Avoid a redundant stat() call.
+       * lib/chown.c (rpl_chown): Set stat_valid after stat() succeeded.
+
 2025-08-14  Bruno Haible  <bruno@clisp.org>
 
        lchown: Use issymlink.
index 2ad99721005e12bf79e5ad41023b209d0957eacb..97cacb82daadf8a065b0b042b99930ca4772da52 100644 (file)
@@ -75,6 +75,7 @@ rpl_chown (const char *file, uid_t uid, gid_t gid)
       /* Stat file to get id(s) that should remain unchanged.  */
       if (!stat_valid && stat (file, &st))
         return -1;
+      stat_valid = true;
       if (gid == (gid_t) -1)
         gid = st.st_gid;
       if (uid == (uid_t) -1)