Repository navigation
linux/apply, windows/compile: rename locals that shadow (-Wshadow) - #5
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rename two locals that trip -Wshadow
claybin builds with
-Wshadow, and agentty's dev build showed two warningsfrom it. Both are renames only.
src/linux/apply.cpp: the netns-inode parse loop declaredconst char* p, which hid the callback'sPhase p. Renamed tod, thedigit cursor.
src/windows/compile.cpp:native_path'sstd::string outhidcompile()'sCompiled out. Renamed tonative, which is what the stringholds.
Neither was a bug: the loop never reads the phase, and
native_pathcaptures nothing. Renaming keeps a later edit from reaching the wrong
variable, and makes the
-Wshadowbuild quiet again.Base
This is cut from this repo's
master(2843bbc). agentty currently pinsclaybin at a4f876b, four commits earlier. Both lines are the same at both
commits.
Verification
g++ -fsyntax-only -Wall -Wextra -Wshadowwith agentty's flags for thesefiles: no warnings.
on Linux, through its normal compile path.