* 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 <egg...@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 <br...@clisp.org> 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