linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 2/2] btrfs-progs: fix a variable shadowing when enabling experimental features
Date: Thu, 28 Sep 2023 13:36:34 +0930	[thread overview]
Message-ID: <415b7f162cc3135d53e28d7cccdf3a08380ae4b9.1695873867.git.wqu@suse.com> (raw)
In-Reply-To: <cover.1695873867.git.wqu@suse.com>

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


  parent reply	other threads:[~2023-09-28  4:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2023-10-02 15:17 ` [PATCH 0/2] btrfs-progs: -Wshadow fixes David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=415b7f162cc3135d53e28d7cccdf3a08380ae4b9.1695873867.git.wqu@suse.com \
    --to=wqu@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).