From 7b16872eff0317d7498de13da6d0bf3513adbb35 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 24 Jul 2026 16:01:48 +1000 Subject: [PATCH] syscall: silence scan-build dead-store in do_fchmodat_nofollow fallback When neither AT_FDCWD nor AT_SYMLINK_NOFOLLOW is available, the function body is a no-op warning that never reads mode or dfd, so the leading 'mode &= CHMOD_BITS' became a dead store and dfd an unused parameter -- which the pinned clang-18 scan-build gate flags (deadcode.DeadStores). Move the mask inside the AT_SYMLINK_NOFOLLOW guard where mode is actually used, and mark dfd/mode used in the fallback. No behavior change on any platform that has the symlink-safe primitive. --- syscall.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/syscall.c b/syscall.c index 73fddf00..44016dfa 100644 --- a/syscall.c +++ b/syscall.c @@ -1485,8 +1485,8 @@ int do_chmod(const char *path, mode_t mode) * exists we skip with a warning rather than follow the leaf. */ static int do_fchmodat_nofollow(int dfd, const char *name, mode_t mode) { - mode &= CHMOD_BITS; #if defined AT_FDCWD && defined AT_SYMLINK_NOFOLLOW + mode &= CHMOD_BITS; # if defined __linux__ { STRUCT_STAT st; @@ -1532,6 +1532,8 @@ static int do_fchmodat_nofollow(int dfd, const char *name, mode_t mode) return fchmodat(dfd, name, mode, AT_SYMLINK_NOFOLLOW); # endif #else + (void)dfd; + (void)mode; /* No symlink-safe chmod primitive here: skip rather than follow the leaf. */ rprintf(FWARNING, "do_chmod: no symlink-safe chmod for \"%s\"; mode not set\n", name); return 1;