]> Savannah Git Hosting - gnulib.git/commitdiff
lchmod: pacify Coverity CID 1491216
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 12 Feb 2020 07:33:00 +0000 (23:33 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 12 Feb 2020 07:33:23 +0000 (23:33 -0800)
* lib/lchmod.c (lchmod): Redo #if nesting so that Coverity does
not complain about unreachable code at the ‘struct stat st;’
declaration.

ChangeLog
lib/lchmod.c

index 321477d3de539ad2bb71f7dd9ea501d7839dbc78..b5ef9b3a15ddcbd8b867c82086a1ddd014383a5b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2020-02-11  Paul Eggert  <eggert@cs.ucla.edu>
+
+       lchmod: pacify Coverity CID 1491216
+       * lib/lchmod.c (lchmod): Redo #if nesting so that Coverity does
+       not complain about unreachable code at the ‘struct stat st;’
+       declaration.
+
 2020-02-10  Bruno Haible  <bruno@clisp.org>
 
        copysignf: Fix link error on HP-UX with cc.
index cc260ce4dc4177f87f8c675f447fc378224488f2..5fc658023ca6c76750b6b48a793bd951cdcf9ad7 100644 (file)
@@ -36,7 +36,8 @@ lchmod (char const *file, mode_t mode)
 {
 #if HAVE_FCHMODAT
   return fchmodat (AT_FDCWD, file, mode, AT_SYMLINK_NOFOLLOW);
-#elif defined O_PATH && defined AT_FDCWD
+#else
+# if defined O_PATH && defined AT_FDCWD
   int fd = openat (AT_FDCWD, file, O_PATH | O_NOFOLLOW | O_CLOEXEC);
   if (fd < 0)
     return fd;
@@ -54,9 +55,9 @@ lchmod (char const *file, mode_t mode)
       return chmod_result;
     }
   /* /proc is not mounted; fall back on racy implementation.  */
-#endif
+# endif
 
-#if HAVE_LSTAT
+# if HAVE_LSTAT
   struct stat st;
   int lstat_result = lstat (file, &st);
   if (lstat_result != 0)
@@ -66,7 +67,8 @@ lchmod (char const *file, mode_t mode)
       errno = EOPNOTSUPP;
       return -1;
     }
-#endif
+# endif
 
   return chmod (file, mode);
+#endif
 }