From: Anand Jain <anand.jain@oracle.com>
To: linux-btrfs@vger.kernel.org
Cc: dsterba@suse.cz
Subject: [PATCH v2] btrfs-progs: fix uninitialized warining in btrfs_calc_stripe_index
Date: Tue, 7 Oct 2014 06:17:02 +0800 [thread overview]
Message-ID: <1412633822-15952-1-git-send-email-anand.jain@oracle.com> (raw)
In-Reply-To: <20141006171931.GD11436@twin.jikos.cz>
From: Anand Jain <Anand.Jain@oracle.com>
chunk-recover.c: In function ‘btrfs_calc_stripe_index’:
chunk-recover.c:1481: warning: ‘index’ may be used uninitialized in this function
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
v2: Accept David review comment
chunk-recover.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/chunk-recover.c b/chunk-recover.c
index 14c25a7..058a652 100644
--- a/chunk-recover.c
+++ b/chunk-recover.c
@@ -1491,7 +1491,7 @@ static int btrfs_calc_stripe_index(struct chunk_record *chunk, u64 logical)
stripe_nr /= nr_data_stripes;
index = (index + stripe_nr) % chunk->num_stripes;
} else {
- BUG_ON(1);
+ return -1;
}
return index;
}
@@ -1554,6 +1554,7 @@ btrfs_rebuild_ordered_meta_chunk_stripes(struct recover_control *rc,
again:
er = container_of(cache, struct extent_record, cache);
index = btrfs_calc_stripe_index(chunk, er->cache.start);
+ BUG_ON(index == -1);
if (chunk->stripes[index].devid)
goto next;
list_for_each_entry_safe(devext, next, &devexts, chunk_list) {
@@ -1944,6 +1945,7 @@ next_csum:
if (list_is_last(candidates.next, &candidates)) {
index = btrfs_calc_stripe_index(chunk,
key.offset + csum_offset * blocksize);
+ BUG_ON(index == -1);
if (chunk->stripes[index].devid)
goto next_stripe;
ret = insert_stripe(&candidates, rc, chunk, index);
--
2.0.0.153.g79dcccc
next prev parent reply other threads:[~2014-10-07 6:11 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
2014-10-06 22:17 ` Anand Jain [this message]
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=1412633822-15952-1-git-send-email-anand.jain@oracle.com \
--to=anand.jain@oracle.com \
--cc=dsterba@suse.cz \
--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).