* [PATCH 0/2] btrfs-progs: -Wshadow fixes
@ 2023-09-28 4:06 Qu Wenruo
2023-09-28 4:06 ` [PATCH 1/2] btrfs-progs: remove variable e from cmd_inspect_list_chunks() Qu Wenruo
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Qu Wenruo @ 2023-09-28 4:06 UTC (permalink / raw)
To: linux-btrfs
Since -Wshadow is enabled recently, there are two new warnings:
- @e from cmd_inspect_list_chunks()
- @csum from print_header_info()
This needs experimental features to be enabled
Just fix them all.
Qu Wenruo (2):
btrfs-progs: remove variable e from cmd_inspect_list_chunks()
btrfs-progs: fix a variable shadowing when enabling experimental
features
cmds/inspect.c | 4 +---
kernel-shared/print-tree.c | 4 ++--
2 files changed, 3 insertions(+), 5 deletions(-)
--
2.42.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] btrfs-progs: remove variable e from cmd_inspect_list_chunks()
2023-09-28 4:06 [PATCH 0/2] btrfs-progs: -Wshadow fixes Qu Wenruo
@ 2023-09-28 4:06 ` Qu Wenruo
2023-09-28 4:06 ` [PATCH 2/2] btrfs-progs: fix a variable shadowing when enabling experimental features Qu Wenruo
2023-10-02 15:17 ` [PATCH 0/2] btrfs-progs: -Wshadow fixes David Sterba
2 siblings, 0 replies; 4+ messages in thread
From: Qu Wenruo @ 2023-09-28 4:06 UTC (permalink / raw)
To: linux-btrfs
The variable @e is only utilized to record the errno from ioctl() call,
and is only for the error message.
We can go with "%m" to replace the usage of variable @e, and remove the
variable shadowing, as later we will declare a local variable @e with a
different type.
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
cmds/inspect.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/cmds/inspect.c b/cmds/inspect.c
index ef928895fa08..50f1ddc745a6 100644
--- a/cmds/inspect.c
+++ b/cmds/inspect.c
@@ -1026,7 +1026,6 @@ static int cmd_inspect_list_chunks(const struct cmd_struct *cmd,
int ret;
int fd;
int i;
- int e;
DIR *dirstream = NULL;
unsigned unit_mode;
char *sortmode = NULL;
@@ -1114,9 +1113,8 @@ static int cmd_inspect_list_chunks(const struct cmd_struct *cmd,
while (1) {
sk->nr_items = 1;
ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args);
- e = errno;
if (ret < 0) {
- error("cannot perform the search: %s", strerror(e));
+ error("cannot perform the search: %m");
return 1;
}
if (sk->nr_items == 0)
--
2.42.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] btrfs-progs: fix a variable shadowing when enabling experimental features
2023-09-28 4:06 [PATCH 0/2] btrfs-progs: -Wshadow fixes Qu Wenruo
2023-09-28 4:06 ` [PATCH 1/2] btrfs-progs: remove variable e from cmd_inspect_list_chunks() Qu Wenruo
@ 2023-09-28 4:06 ` Qu Wenruo
2023-10-02 15:17 ` [PATCH 0/2] btrfs-progs: -Wshadow fixes David Sterba
2 siblings, 0 replies; 4+ messages in thread
From: Qu Wenruo @ 2023-09-28 4:06 UTC (permalink / raw)
To: linux-btrfs
There is another variable shadowing problem which can only be exposed
if experimental features are enabled.
Inside the branch of BTRFS_PRINT_TREE_CSUM_HEADERS, we declare another
local variable @csum, shadowing the @csum of print_header_info(), which
is only declared when experimental features are enabled.
Just rename the @csum to @tree_csum to avoid the problem.
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
kernel-shared/print-tree.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel-shared/print-tree.c b/kernel-shared/print-tree.c
index 8511cb1bfd6c..6625b1b6aa80 100644
--- a/kernel-shared/print-tree.c
+++ b/kernel-shared/print-tree.c
@@ -1271,12 +1271,12 @@ static void print_header_info(struct extent_buffer *eb, unsigned int mode)
printf("\n");
if (fs_info && (mode & BTRFS_PRINT_TREE_CSUM_HEADERS)) {
char *tmp = csum_str;
- u8 *csum = (u8 *)(eb->data + offsetof(struct btrfs_header, csum));
+ u8 *tree_csum = (u8 *)(eb->data + offsetof(struct btrfs_header, csum));
strcpy(csum_str, " csum 0x");
tmp = csum_str + strlen(csum_str);
for (i = 0; i < csum_size; i++) {
- sprintf(tmp, "%02x", csum[i]);
+ sprintf(tmp, "%02x", tree_csum[i]);
tmp++;
tmp++;
}
--
2.42.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] btrfs-progs: -Wshadow fixes
2023-09-28 4:06 [PATCH 0/2] btrfs-progs: -Wshadow fixes Qu Wenruo
2023-09-28 4:06 ` [PATCH 1/2] btrfs-progs: remove variable e from cmd_inspect_list_chunks() Qu Wenruo
2023-09-28 4:06 ` [PATCH 2/2] btrfs-progs: fix a variable shadowing when enabling experimental features Qu Wenruo
@ 2023-10-02 15:17 ` David Sterba
2 siblings, 0 replies; 4+ messages in thread
From: David Sterba @ 2023-10-02 15:17 UTC (permalink / raw)
To: Qu Wenruo; +Cc: linux-btrfs
On Thu, Sep 28, 2023 at 01:36:32PM +0930, Qu Wenruo wrote:
> Since -Wshadow is enabled recently, there are two new warnings:
>
> - @e from cmd_inspect_list_chunks()
> - @csum from print_header_info()
> This needs experimental features to be enabled
>
> Just fix them all.
>
> Qu Wenruo (2):
> btrfs-progs: remove variable e from cmd_inspect_list_chunks()
> btrfs-progs: fix a variable shadowing when enabling experimental
> features
Added to devel, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-10-02 15:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-28 4:06 [PATCH 0/2] btrfs-progs: -Wshadow fixes Qu Wenruo
2023-09-28 4:06 ` [PATCH 1/2] btrfs-progs: remove variable e from cmd_inspect_list_chunks() Qu Wenruo
2023-09-28 4:06 ` [PATCH 2/2] btrfs-progs: fix a variable shadowing when enabling experimental features Qu Wenruo
2023-10-02 15:17 ` [PATCH 0/2] btrfs-progs: -Wshadow fixes David Sterba
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).