From patchwork Mon Oct 6 22:27:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 5043601 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 EA6B49F30B for ; Tue, 7 Oct 2014 06:22:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2ED5520166 for ; Tue, 7 Oct 2014 06:22:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 375642012F for ; Tue, 7 Oct 2014 06:22:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751380AbaJGGWM (ORCPT ); Tue, 7 Oct 2014 02:22:12 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:42279 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750713AbaJGGWL (ORCPT ); Tue, 7 Oct 2014 02:22:11 -0400 Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s976M8uu010547 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 7 Oct 2014 06:22:09 GMT Received: from userz7021.oracle.com (userz7021.oracle.com [156.151.31.85]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s976M67n022438 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Tue, 7 Oct 2014 06:22:07 GMT Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by userz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s976M55s014786; Tue, 7 Oct 2014 06:22:06 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:22:05 -0700 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.cz Subject: [PATCH v4] btrfs-progs: fix uninitialized warning in btrfs_calc_stripe_index Date: Tue, 7 Oct 2014 06:27:16 +0800 Message-Id: <1412634436-16698-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> X-Source-IP: acsinet21.oracle.com [141.146.126.237] 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 --- v4: remove some unintended char in commit, sorry v3: fix typo in commit 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);