From: 'Guanjun' <guanjun@linux.alibaba.com>
To: wqu@suse.com, dsterba@suse.com, clm@fb.com, josef@toxicpanda.com,
linux-btrfs@vger.kernel.org
Subject: [PATCH 1/1] btrfs: scrub: Fix use of uninitialized variable
Date: Sat, 9 Dec 2023 16:21:32 +0800 [thread overview]
Message-ID: <20231209082132.2690130-1-guanjun@linux.alibaba.com> (raw)
From: Guanjun <guanjun@linux.alibaba.com>
'ret' will be uninitialized in case that the logical_length
is 0. Even if the caller has already ensured that logical_length
is greater than 0, we still need to fix this issue. Due to the
compiler may complain like this:
fs/btrfs/scrub.c: In function ‘scrub_simple_mirror.constprop’:
fs/btrfs/scrub.c:2123:9: error: ‘ret’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
2123 | return ret;
| ^~~
Fixes: 09022b14fafc (btrfs: scrub: introduce dedicated helper to scrub simple-mirror based range)
Signed-off-by: Guanjun <guanjun@linux.alibaba.com>
---
fs/btrfs/scrub.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index a01807cbd4d4..13024131f77d 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -2071,7 +2071,7 @@ static int scrub_simple_mirror(struct scrub_ctx *sctx,
struct btrfs_fs_info *fs_info = sctx->fs_info;
const u64 logical_end = logical_start + logical_length;
u64 cur_logical = logical_start;
- int ret;
+ int ret = 0;
/* The range must be inside the bg */
ASSERT(logical_start >= bg->start && logical_end <= bg->start + bg->length);
--
2.39.3
next reply other threads:[~2023-12-09 8:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-09 8:21 'Guanjun' [this message]
2023-12-09 21:09 ` [PATCH 1/1] btrfs: scrub: Fix use of uninitialized variable Qu Wenruo
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=20231209082132.2690130-1-guanjun@linux.alibaba.com \
--to=guanjun@linux.alibaba.com \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=josef@toxicpanda.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=wqu@suse.com \
/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