summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2020-02-11 23:33:00 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2020-02-11 23:33:23 -0800
commit1d7a06644426dddd02efeae1e2a41e9b788c02b2 (patch)
tree3427259eb2d4602d0cc8e4e02ae433a0a79a01ae
parent579213bdb0a2c5e82257c62364d99ad3533f2e2c (diff)
downloadgnulib-1d7a06644426dddd02efeae1e2a41e9b788c02b2.tar.gz
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.
-rw-r--r--ChangeLog7
-rw-r--r--lib/lchmod.c10
2 files changed, 13 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 321477d3de..b5ef9b3a15 100644
--- 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.
diff --git a/lib/lchmod.c b/lib/lchmod.c
index cc260ce4dc..5fc658023c 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
}