Skip to content

btrfs-progs: fix all -Wshadow warnings and enable -Wshadow for default builds

Qu Wenruo linux-btrfs 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 1 replyIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3btrfs-progs: pull in the full max/min/clamp implementation from kernelcommon/internal.h kernel-shared/async-thread.c+131 -180 replies
2/3btrfs-progs: fix all variable shadowingcheck/main.c check/mode-lowmem.c check/qgroup-verify.c +6 more+34 -370 replies
3/3btrfs-progs: enable -Wshadow for default buildMakefile Makefile.extrawarn+2 -20 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/3] btrfs-progs: fix all -Wshadow warnings and enable -Wshadow for default builds

Recently David fixes quite some errno usage in kernel code, to avoid overwriting user space @errno variable.

This inspired me that, those problems can be detected by -Wshadow, thus let's enable -Wshadow for default builds.

The biggest cause of -Wshadow warnings is min()/max() which all uses the same __x and __y.
To fix that, pull the kernel version with the usage of __UNIQUE_ID() to address the problem.

The remaining ones are mostly bad namings and harmless, but there is still some bad ones, detailed in the 2nd patch.

Tested with both GCC 13.2.1 and Clang 16.0.6, the first one is fully clean, the latter one has some unrelated warnings, but no -Wshadow warnings.

Qu Wenruo (3):
btrfs-progs: pull in the full max/min/clamp implementation from kernel
btrfs-progs: fix all variable shadowing
btrfs-progs: enable -Wshadow for default build

 Makefile                     |   3 +-
 Makefile.extrawarn           |   1 -
 check/main.c                 |   6 +-
 check/mode-lowmem.c          |   4 +-
 check/qgroup-verify.c        |  23 +++---
 check/repair.c               |   7 +-
 cmds/filesystem-usage.c      |   8 +-
 cmds/subvolume-list.c        |   2 +-
 common/internal.h            | 147 +++++++++++++++++++++++++++++++----
 image/image-restore.c        |  10 +--
 kernel-shared/async-thread.c |   2 +-
 kernel-shared/extent-tree.c  |   1 -
 tune/change-csum.c           |  10 +--
 13 files changed, 167 insertions(+), 57 deletions(-)

--
2.42.0