From patchwork Mon Oct 6 22:17:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 5043521 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 501FE9F295 for ; Tue, 7 Oct 2014 06:12:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 834202015A for ; Tue, 7 Oct 2014 06:12:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A99FB20127 for ; Tue, 7 Oct 2014 06:12:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752918AbaJGGL4 (ORCPT ); Tue, 7 Oct 2014 02:11:56 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:39157 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751223AbaJGGL4 (ORCPT ); Tue, 7 Oct 2014 02:11:56 -0400 Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s976BpPT001170 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 7 Oct 2014 06:11:52 GMT Received: from userz7022.oracle.com (userz7022.oracle.com [156.151.31.86]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s976BpxQ022758 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 7 Oct 2014 06:11:51 GMT Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by userz7022.oracle.com (8.14.5+Sun/8.14.4) with ESMTP id s976Box2022541; Tue, 7 Oct 2014 06:11:50 GMT Received: from OL.sg.oracle.com (/10.186.101.34) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 06 Oct 2014 23:11:49 -0700 From: Anand Jain 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 Message-Id: <1412633822-15952-1-git-send-email-anand.jain@oracle.com> X-Mailer: git-send-email 2.0.0.153.g79dcccc In-Reply-To: <20141006171931.GD11436@twin.jikos.cz> References: <20141006171931.GD11436@twin.jikos.cz> MIME-Version: 1.0 X-Source-IP: ucsinet21.oracle.com [156.151.31.93] Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00, DATE_IN_PAST_06_12, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Anand Jain 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 --- 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);