bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] lchmod: pacify Coverity CID 1491216


From: Paul Eggert
Subject: [PATCH] lchmod: pacify Coverity CID 1491216
Date: Tue, 11 Feb 2020 23:33:37 -0800

* lib/lchmod.c (lchmod): Redo #if nesting so that Coverity does
not complain about unreachable code at the ‘struct stat st;’
declaration.
---
 ChangeLog    |  7 +++++++
 lib/lchmod.c | 10 ++++++----
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 321477d3d..b5ef9b3a1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2020-02-11  Paul Eggert  <address@hidden>
+
+       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  <address@hidden>
 
        copysignf: Fix link error on HP-UX with cc.
diff --git a/lib/lchmod.c b/lib/lchmod.c
index cc260ce4d..5fc658023 100644
--- a/lib/lchmod.c
+++ b/lib/lchmod.c
@@ -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
 }
-- 
2.17.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]