Skip to content
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

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

mjstapp
Copy link
Contributor

@mjstapp mjstapp commented Jan 23, 2025

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.

lib/event.c Outdated
}

cpu_records_fini(old);
frr_mutex_lock_autounlock(&masters_mtx);
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@frrbot frrbot bot added babel bfd eigrp ldp mgmt FRR Management Infra labels Jan 24, 2025
@mjstapp
Copy link
Contributor Author

mjstapp commented Jan 30, 2025

I've folded in David L's change to the mutex wrapper macros (with his permission) and removed some code changes as a result.

Mark Stapp and others added 11 commits January 30, 2025 16:55
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>
@mjstapp
Copy link
Contributor Author

mjstapp commented Jan 30, 2025

pushed a fix for a checkpatch warning

Clean up various variable-shadowing warnings from -Wshadow

Signed-off-by: Mark Stapp <mjs@cisco.com>
@frrbot frrbot bot added the vtysh label Jan 30, 2025
Clean up various variable-shadow warnings from -Wshadow

Signed-off-by: Mark Stapp <mjs@cisco.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants