Steps towards enabling -Wshadow=local
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v3 Latest7 patches 2 repliesIn review
- v27 patches 8 repliesSuperseded
- v17 patches 31 repliesSuperseded
Changes in v3 from the cover letter
* PATCH 7: Comment typo [Eric], peel off a pair of parenthesis [Eric], revert accidental line breaks [Kevin]
Patches in v3 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/7 | migration/rdma: Fix save_page method to fail on polling errormigration/ | +4 | 0 replies | |
| 2/7 | migration: Clean up local variable shadowingmigration/ migration/ migration/ +1 more | +11 | 0 replies | |
| 3/7 | ui: Clean up local variable shadowingui/ ui/ ui/ +2 more | +22 | 0 replies | |
| 4/7 | block/dirty-bitmap: Clean up local variable shadowingblock/ block/ | +11 | 0 replies | |
| 5/7 | block/vdi: Clean up local variable shadowingblock/ | +3 | 0 replies | |
| 6/7 | block: Clean up local variable shadowingblock.c block/ block/ +2 more | +27 | 0 replies | |
| 7/7 | qobject atomics osdep: Make a few macros more hygienicinclude/ include/ include/ +1 more | +43 | 1 reply |
Reviews trailers per patch
All 7 patches have a Reviewed-by or Acked-by.
| Patch | Eric Blake | Peter Xu | Li Zhijian | Stefan Hajnoczi | Kevin Wolf | Peter Maydell | Anthony PERARD | Ilya Dryomov | Philippe Mathieu-Daudé |
|---|---|---|---|---|---|---|---|---|---|
| 1/7 | R-b | R-b | R-b | ||||||
| 2/7 | R-b | R-b | |||||||
| 3/7 | R-b | ||||||||
| 4/7 | R-b | ||||||||
| 5/7 | R-b | R-b | |||||||
| 6/7 | R-b | R-b | A-b | A-b | |||||
| 7/7 | R-b | R-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 9 reviewers.
Cover letter [PATCH v3 0/7] Steps towards enabling -Wshadow=local
Local variables shadowing other local variables or parameters make the code needlessly hard to understand. Bugs love to hide in such code.
Evidence: PATCH 1.
Enabling -Wshadow would prevent bugs like this one. But we'd have to clean up all the offenders first. We got a lot of them.
Enabling -Wshadow=local should be less work for almost as much gain. I took a stab at it. There's a small, exciting part, and a large, boring part.
The exciting part is dark preprocessor sorcery to let us nest macro calls without shadowing: PATCH 7.
The boring part is cleaning up all the other warnings. I did some [PATCH 2-6], but ran out of steam long before finishing the job. Some 160 unique warnings remain.
To see them, enable -Wshadow=local like so:
meson.build +3 -0
@@ -466,6 +466,9 @@ warn_flags = [ '-Wno-tautological-type-limit-compare', '-Wno-psabi', '-Wno-gnu-variable-sized-type-not-at-end', + '-Wshadow=local', + '-Wno-error=shadow=local', + '-Wno-error=shadow=compatible-local', ] if targetos != 'darwin'
You may want to drop the -Wno-error lines.
v3:
* PATCH 7: Comment typo [Eric], peel off a pair of parenthesis [Eric], revert accidental line breaks [Kevin]
v2:
* PATCH 3+6: Mollify checkpatch
* PATCH 4: Redo for clearer code, R-bys dropped [Kevin]
* PATCH 5: Rename tweaked [Kevin]
* PATCH 6: Rename local @tran instead of the parameter [Kevin]
* PATCH 7: Drop PASTE(), use glue() instead [Richard]; pass identifiers instead of __COUNTER__ for readability [Eric]; add comments
Markus Armbruster (7):
migration/rdma: Fix save_page method to fail on polling error
migration: Clean up local variable shadowing
ui: Clean up local variable shadowing block/dirty-bitmap: Clean up local variable shadowing block/vdi: Clean up local variable shadowing
block: Clean up local variable shadowing
qobject atomics osdep: Make a few macros more hygienic
include/qapi/qmp/qobject.h | 10 ++++++++-- include/qemu/atomic.h | 17 +++++++++++----- include/qemu/compiler.h | 3 +++ include/qemu/osdep.h | 27 ++++++++++++++++++------- block.c | 9 +++++---- block/monitor/bitmap-qmp-cmds.c | 19 +++++++++--------- block/qcow2-bitmap.c | 3 +-- block/rbd.c | 2 +- block/stream.c | 1 - block/vdi.c | 7 +++---- block/vvfat.c | 35 +++++++++++++++++---------------- hw/block/xen-block.c | 6 +++--- migration/block.c | 4 ++-- migration/ram.c | 8 +++----- migration/rdma.c | 14 ++++++++----- migration/vmstate.c | 2 +- ui/gtk.c | 14 ++++++------- ui/spice-display.c | 9 +++++---- ui/vnc-palette.c | 2 -- ui/vnc.c | 12 +++++------ ui/vnc-enc-zrle.c.inc | 9 ++++----- 21 files changed, 121 insertions(+), 92 deletions(-)
Signature · 1 line
2.41.0