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

Eliminate variable shadowing in local.c #611

Closed
msporcich opened this issue Oct 19, 2020 · 4 comments
Closed

Eliminate variable shadowing in local.c #611

msporcich opened this issue Oct 19, 2020 · 4 comments

Comments

@msporcich
Copy link

In local.c, there are two instances of variable shadowing which cause the build to fail when compiling with flag
-Werror=shadow

In local_close()
error: declaration of ‘i’ shadows a previous local [-Werror=shadow]
In get_short_attr_name()
error: declaration of ‘len’ shadows a previous local [-Werror=shadow]

msporcich pushed a commit to msporcich/libiio that referenced this issue Oct 20, 2020
@msporcich
Copy link
Author

Forked with a proposed resolution. I'm interested in getting any comments and then signoff so that I may issue a pull request. Thanks.

@commodo
Copy link
Contributor

commodo commented Oct 20, 2020

the change looks reasonable to me
feel free do a PR targeting our master;

thanks
Alex

msporcich pushed a commit to msporcich/libiio that referenced this issue Oct 20, 2020
Resolves build problems when compiling with -Werror=shadow.

Signed-off-by: Marc Sporcich <[email protected]>
commodo pushed a commit that referenced this issue Oct 21, 2020
Resolves build problems when compiling with -Werror=shadow.

Signed-off-by: Marc Sporcich <[email protected]>
@rgetz
Copy link
Contributor

rgetz commented Nov 7, 2020

Only question is should we add -Werror=shadow all the time? (for gcc)

Nominally it's -Wall -Wextra -Wno-unused-parameter -Wpedantic -std=c99

rgetz added a commit that referenced this issue Nov 10, 2020
Warn whenever a local variable or type declaration shadows another variable,
parameter, or type. This will make sure (hopefully) that #611 don't come
back.

tested with:
 - cmake 3.13.4 & gcc 8.3.0 (debian)
 - cmake 3.13.4 & gcc 8.3.0 (Raspbian)
 - cmake 2.8.12.2 & gcc 4.8.2 (Zynq)

Signed-off-by: Robin Getz <[email protected]>
@rgetz
Copy link
Contributor

rgetz commented Nov 10, 2020

closing this.

@rgetz rgetz closed this as completed Nov 10, 2020
dNechita pushed a commit that referenced this issue Nov 11, 2020
Warn whenever a local variable or type declaration shadows another variable,
parameter, or type. This will make sure (hopefully) that #611 don't come
back.

tested with:
 - cmake 3.13.4 & gcc 8.3.0 (debian)
 - cmake 3.13.4 & gcc 8.3.0 (Raspbian)
 - cmake 2.8.12.2 & gcc 4.8.2 (Zynq)

Signed-off-by: Robin Getz <[email protected]>
mhennerich pushed a commit that referenced this issue Mar 30, 2021
Warn whenever a local variable or type declaration shadows another variable,
parameter, or type. This will make sure (hopefully) that #611 don't come
back.

tested with:
 - cmake 3.13.4 & gcc 8.3.0 (debian)
 - cmake 3.13.4 & gcc 8.3.0 (Raspbian)
 - cmake 2.8.12.2 & gcc 4.8.2 (Zynq)

Signed-off-by: Robin Getz <[email protected]>
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

No branches or pull requests

3 participants