Skip to content

minmax: don't nest min/max in clamp to avoid -Wshadow warnings#98

Open
kuba-moo wants to merge 1 commit into
rustyrussell:masterfrom
kuba-moo:master
Open

minmax: don't nest min/max in clamp to avoid -Wshadow warnings#98
kuba-moo wants to merge 1 commit into
rustyrussell:masterfrom
kuba-moo:master

Conversation

@kuba-moo

@kuba-moo kuba-moo commented Dec 9, 2021

Copy link
Copy Markdown

Using clamp from minmax.h with -Wshadow (GCC 11 and 8, haven't tested others)
generates a bunch of warnings because min and max both declare _a, _b vars.
Store the result of min to a temporary variable instead of nesting the calls
this way min's variables are not in scope of max.

Signed-off-by: Jakub Kicinski kuba@kernel.org

Using clamp from minmax.h with -Wshadow (GCC 11 and 8, haven't tested others)
generates a bunch of warnings because min and max both declare _a, _b vars.
Store the result of min to a temporary variable instead of nesting the calls
this way min's variables are not in scope of max.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>

@vincenzopalazzo vincenzopalazzo left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants