From 2c0f302b0fe5c0c5144554d0ac02c5514403fbb1 Mon Sep 17 00:00:00 2001 From: sail3r <82087684+sail3r@users.noreply.github.com> Date: Sun, 15 Nov 2026 18:24:46 +1300 Subject: [PATCH] linux/apply, windows/compile: rename locals that shadow (-Wshadow) claybin builds with -Wshadow, and two locals tripped it: - linux/apply.cpp: the netns-inode parse loop declared `const char* p` inside the for_each callback, which already has `Phase p` for the op's phase. The loop never needed the phase, but a later edit in that case block reading `p` would get whichever was closest. Renamed to `d` (digit cursor). - windows/compile.cpp: native_path's `std::string out` shadowed compile()'s `Compiled out`. native_path captures nothing ([]), so it could not touch the outer one, but the shared name made the two easy to mix up when reading compile(). Renamed to `native`, which is what the string holds. Names only, no behaviour change. -fsyntax-only with -Wall -Wextra -Wshadow is clean for both TUs. --- src/linux/apply.cpp | 4 ++-- src/windows/compile.cpp | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/linux/apply.cpp b/src/linux/apply.cpp index ee2e64b..5514302 100644 --- a/src/linux/apply.cpp +++ b/src/linux/apply.cpp @@ -1441,8 +1441,8 @@ Status Plan::apply_range(Phase first, Phase last, ApplyFds& fds) const { if (nf > 0) { buf[nf] = '\0'; std::uint64_t ino = 0; - for (const char* p = buf; *p; ++p) - if (*p >= '0' && *p <= '9') ino = ino * 10 + std::uint64_t(*p - '0'); + for (const char* d = buf; *d; ++d) + if (*d >= '0' && *d <= '9') ino = ino * 10 + std::uint64_t(*d - '0'); fds.proxy_netns_ino = ino; } } diff --git a/src/windows/compile.cpp b/src/windows/compile.cpp index 8367b1c..536fdb4 100644 --- a/src/windows/compile.cpp +++ b/src/windows/compile.cpp @@ -203,30 +203,30 @@ Result compile(const Policy& policy, const HostCapabilities& h // past the policy-vocabulary roots: native forms only, with the // drive prefix already stripped above. anything else starting with // "/" failed the root table and never reaches here. - std::string out; - out.reserve(s.size()); + std::string native; + native.reserve(s.size()); bool prev_sep = false; for (const char c : s) { if (c == '/' || c == '\\') { - if (!prev_sep && !out.empty()) out.push_back('\\'); + if (!prev_sep && !native.empty()) native.push_back('\\'); prev_sep = true; } else { - out.push_back(c); + native.push_back(c); prev_sep = false; } } - while (!out.empty() && out.back() == '\\') out.pop_back(); - if (out.empty()) + while (!native.empty() && native.back() == '\\') native.pop_back(); + if (native.empty()) return std::unexpected(Error{Errc::invalid_policy, "path normalizes to nothing"}); - const bool drive = out.size() >= 2 && out[1] == ':' && - ((out[0] >= 'A' && out[0] <= 'Z') || - (out[0] >= 'a' && out[0] <= 'z')); - const bool unc = out.size() >= 2 && out[0] == '\\' && out[1] == '\\'; + const bool drive = native.size() >= 2 && native[1] == ':' && + ((native[0] >= 'A' && native[0] <= 'Z') || + (native[0] >= 'a' && native[0] <= 'z')); + const bool unc = native.size() >= 2 && native[0] == '\\' && native[1] == '\\'; if (!drive && !unc) return std::unexpected(Error{Errc::invalid_policy, "path has no drive prefix (need C:\\... or \\\\server\\\\share)"}); - return out; + return native; }; for (const auto& g : effective.grants()) {