From: David Sterba <dsterba@suse.cz>
To: Anand Jain <anand.jain@oracle.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs-progs: fix uninitialized warining in btrfs_calc_stripe_index
Date: Mon, 6 Oct 2014 19:19:31 +0200 [thread overview]
Message-ID: <20141006171931.GD11436@twin.jikos.cz> (raw)
In-Reply-To: <1412209921-21002-1-git-send-email-anand.jain@oracle.com>
On Thu, Oct 02, 2014 at 08:32:01AM +0800, Anand Jain wrote:
> chunk-recover.c: In function ‘btrfs_calc_stripe_index’:
> chunk-recover.c:1481: warning: ‘index’ may be used uninitialized in this function
> --- a/chunk-recover.c
> +++ b/chunk-recover.c
> @@ -1478,7 +1478,7 @@ static int btrfs_calc_stripe_index(struct chunk_record *chunk, u64 logical)
> u64 offset = logical - chunk->offset;
> int stripe_nr;
> int nr_data_stripes;
> - int index;
> + int index = 0;
>
> stripe_nr = offset / chunk->stripe_len;
> if (chunk->type_flags & BTRFS_BLOCK_GROUP_RAID0) {
The catch-all branch does BUG_ON so the compiler probably misses that
for some reason, otherwise the index value is always defined. It would
be better to replace the BUG_ON with "return -1" and handle the error in
the callers.
The BUG_ON happens if there's an unknown block group type, these are
well known and any error here means there's a corruption or unsupported
type. Both condition could be handled in a better way.
next prev parent reply other threads:[~2014-10-06 17:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-02 0:32 [PATCH] btrfs-progs: fix uninitialized warining in btrfs_calc_stripe_index Anand Jain
2014-10-06 17:19 ` David Sterba [this message]
2014-10-06 22:17 ` [PATCH v2] " Anand Jain
2014-10-06 22:20 ` [PATCH v3] btrfs-progs: fix uninitialized warning " Anand Jain
2014-10-06 22:27 ` [PATCH v4] " Anand Jain
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=20141006171931.GD11436@twin.jikos.cz \
--to=dsterba@suse.cz \
--cc=anand.jain@oracle.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).