From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Souptick Joarder <jrdr.linux@gmail.com>,
clm@fb.com, josef@toxicpanda.com, dsterba@suse.com,
nathan@kernel.org, ndesaulniers@google.com
Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org,
llvm@lists.linux.dev, kernel test robot <lkp@intel.com>
Subject: Re: [PATCH] btrfs: Initialize ret to 0 in scrub_simple_mirror()
Date: Mon, 21 Feb 2022 08:15:52 +0800 [thread overview]
Message-ID: <0a2e57ad-2973-ea01-ceda-3262cde1f5aa@gmx.com> (raw)
In-Reply-To: <20220220144606.5695-1-jrdr.linux@gmail.com>
On 2022/2/20 22:46, Souptick Joarder wrote:
> From: "Souptick Joarder (HPE)" <jrdr.linux@gmail.com>
>
> Kernel test robot reported below warning ->
> fs/btrfs/scrub.c:3439:2: warning: Undefined or garbage value
> returned to caller [clang-analyzer-core.uninitialized.UndefReturn]
>
> Initialize ret to 0.
>
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Souptick Joarder (HPE) <jrdr.linux@gmail.com>
Although the patch is not yet merged, but I have to say, it's a false alert.
Firstly, the while loop will always get at least one run.
Secondly, in that loop, we either set ret to some error value and break,
or after at least one find_first_extent_item() and scrub_extent() call,
we increase cur_logical and reached the limit of the while loop and exit.
So there is no possible routine to leave @ret uninitialized and returned
to caller.
Thanks,
Qu
> ---
> 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 4baa8e43d585..5ca7e5ffbc96 100644
> --- a/fs/btrfs/scrub.c
> +++ b/fs/btrfs/scrub.c
> @@ -3325,7 +3325,7 @@ static int scrub_simple_mirror(struct scrub_ctx *sctx,
> const u32 max_length = SZ_64K;
> struct btrfs_path path = {};
> u64 cur_logical = logical_start;
> - int ret;
> + int ret = 0;
>
> /* The range must be inside the bg */
> ASSERT(logical_start >= bg->start &&
next prev parent reply other threads:[~2022-02-21 0:16 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-20 14:46 [PATCH] btrfs: Initialize ret to 0 in scrub_simple_mirror() Souptick Joarder
2022-02-21 0:15 ` Qu Wenruo [this message]
2022-02-22 7:50 ` Souptick Joarder
2022-02-22 8:04 ` Qu Wenruo
2022-02-22 8:09 ` Souptick Joarder
2022-02-24 9:48 ` Yujie Liu
2022-02-24 9:56 ` Qu Wenruo
2022-02-25 9:35 ` Yujie Liu
2022-02-25 5:16 ` Souptick Joarder
2022-02-25 10:02 ` Yujie Liu
2022-03-01 1:55 ` Yujie Liu
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=0a2e57ad-2973-ea01-ceda-3262cde1f5aa@gmx.com \
--to=quwenruo.btrfs@gmx.com \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=josef@toxicpanda.com \
--cc=jrdr.linux@gmail.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=llvm@lists.linux.dev \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.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