diff mbox series

[PULL,2/2] meson: Enable -Wshadow=local

Message ID 20231113093621.750115-3-armbru@redhat.com
State New
Headers show
Series [PULL,1/2] block/snapshot: Fix compiler warning with -Wshadow=local | expand

Commit Message

Markus Armbruster Nov. 13, 2023, 9:36 a.m. UTC
Local variables shadowing other local variables or parameters make the
code needlessly hard to understand.  Bugs love to hide in such code.
Evidence: commit bbde656263d (migration/rdma: Fix save_page method to
fail on polling error).

Enable -Wshadow=local to prevent such issues.  Possible thanks to
recent cleanups.  Enabling -Wshadow would prevent more issues, but
we're not yet ready for that.

As usual, the warning is only enabled when the compiler recognizes it.
GCC does, Clang doesn't.

Some shadowed locals remain in bsd-user.  Since BSD prefers Clang,
let's not wait for its cleanup.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-ID: <20231026053115.2066744-2-armbru@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 meson.build | 1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

diff --git a/meson.build b/meson.build
index d7d841e71e..ec01f8b138 100644
--- a/meson.build
+++ b/meson.build
@@ -462,6 +462,7 @@  warn_flags = [
   '-Wno-tautological-type-limit-compare',
   '-Wno-psabi',
   '-Wno-gnu-variable-sized-type-not-at-end',
+  '-Wshadow=local',
 ]
 
 if targetos != 'darwin'