-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
*: expose and fix variable shadowing warnings #17915
base: master
Are you sure you want to change the base?
Conversation
lib/event.c
Outdated
} | ||
|
||
cpu_records_fini(old); | ||
frr_mutex_lock_autounlock(&masters_mtx); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any changes in this chunk? What am I missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, this is one of the patterns that was a little awkward. note that the original had a with_mutex
block, and then an inner with_mutex
block. with_mutex
is a macro, and it uses ... a local variable - so the inner block's variable shadows the outer block's. so the conversion replace the outer block, and that resolves the warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ooooooh yeah, the variable's inside the macro… (it's warning about _once
?) - that should be fixable in the header
also note frr_with_mutex
accepts multiple mutexes and locks them in left-to-right order, albeit tbh I never quite felt comfortable using that since it's very implicit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
565b853
to
8e5b7d4
Compare
I've folded in David L's change to the mutex wrapper macros (with his permission) and removed some code changes as a result. |
Start exposing variable-shadowing warnings in all builds. Signed-off-by: Mark Stapp <mjs@cisco.com>
The `_once` loop variable will result in a `-Wshadow` warning when that is turned on. Use `__COUNTER__` to give these variables distinct names, like is already done with `_mtx_`. (and because I touched it, clang-format wants it reformatted... ohwell.) Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Fix various "shadow" warnings in lib. Signed-off-by: Mark Stapp <mjs@cisco.com>
Clean up various "shadow" warnings. Signed-off-by: Mark Stapp <mjs@cisco.com>
Clean up various "shadow" warnings. Signed-off-by: Mark Stapp <mjs@cisco.com>
Clean up various "shadow" warnings.
Clean up various "shadow" warnings in babeld. Signed-off-by: Mark Stapp <mjs@cisco.com>
Clean up various variable-shadow warnings in bfdd. Signed-off-by: Mark Stapp <mjs@cisco.com>
Clean up various warnings from -Wshadow in eigrp. Signed-off-by: Mark Stapp <mjs@cisco.com>
Clean up various variable-shadow warnings in ldpd. Signed-off-by: Mark Stapp <mjs@cisco.com>
Clean up various variable-shadow warnings in mgmtd. Signed-off-by: Mark Stapp <mjs@cisco.com>
8e5b7d4
to
90be062
Compare
pushed a fix for a checkpatch warning |
Clean up various variable-shadowing warnings from -Wshadow Signed-off-by: Mark Stapp <mjs@cisco.com>
Clean up various variable-shadow warnings from -Wshadow Signed-off-by: Mark Stapp <mjs@cisco.com>
Add the -Wshadow warning option for builds; this exposes variable-shadowing issues. I've cleaned up several components, but some of the choices might be controversial (or ... awkward, or ... wrong), so I'm opening this as a draft to get some feedback before continuing with more components.