From patchwork Wed Aug 24 02:24:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 9296731 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7A397608A7 for ; Wed, 24 Aug 2016 02:25:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6BC5C28D10 for ; Wed, 24 Aug 2016 02:25:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6077128DCB; Wed, 24 Aug 2016 02:25:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from oss.sgi.com (oss.sgi.com [192.48.182.195]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C6B9B28DBF for ; Wed, 24 Aug 2016 02:25:05 +0000 (UTC) Received: from oss.sgi.com (localhost [IPv6:::1]) by oss.sgi.com (Postfix) with ESMTP id B3F067CA6; Tue, 23 Aug 2016 21:25:03 -0500 (CDT) X-Original-To: xfs@oss.sgi.com Delivered-To: xfs@oss.sgi.com Received: from relay.sgi.com (relay1.corp.sgi.com [137.38.102.111]) by oss.sgi.com (Postfix) with ESMTP id 212DE7CA6 for ; Tue, 23 Aug 2016 21:25:02 -0500 (CDT) Received: from cuda.sgi.com (cuda1.sgi.com [192.48.157.11]) by relay1.corp.sgi.com (Postfix) with ESMTP id CA3518F8035 for ; Tue, 23 Aug 2016 19:25:01 -0700 (PDT) X-ASG-Debug-ID: 1472005499-0bf81509b0123920001-NocioJ Received: from userp1040.oracle.com (userp1040.oracle.com [156.151.31.81]) by cuda.sgi.com with ESMTP id rcBDPqxXmNnFBb6q (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Tue, 23 Aug 2016 19:24:59 -0700 (PDT) X-Barracuda-Envelope-From: darrick.wong@oracle.com X-Barracuda-Effective-Source-IP: userp1040.oracle.com[156.151.31.81] X-Barracuda-Apparent-Source-IP: 156.151.31.81 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u7O2OwlD023592 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Aug 2016 02:24:58 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0022.oracle.com (8.14.4/8.13.8) with ESMTP id u7O2OwZv004699 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Aug 2016 02:24:58 GMT Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id u7O2OvZj015478; Wed, 24 Aug 2016 02:24:57 GMT Received: from localhost (/24.21.211.40) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 23 Aug 2016 19:24:57 -0700 Subject: [PATCH 5/7] misc: fix Coverity errors From: "Darrick J. Wong" X-ASG-Orig-Subj: [PATCH 5/7] misc: fix Coverity errors To: david@fromorbit.com, darrick.wong@oracle.com Date: Tue, 23 Aug 2016 19:24:56 -0700 Message-ID: <147200549633.15538.18051281375686885659.stgit@birch.djwong.org> In-Reply-To: <147200546481.15538.12724000421579716885.stgit@birch.djwong.org> References: <147200546481.15538.12724000421579716885.stgit@birch.djwong.org> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Source-IP: userv0022.oracle.com [156.151.31.74] X-Barracuda-Connect: userp1040.oracle.com[156.151.31.81] X-Barracuda-Start-Time: 1472005499 X-Barracuda-Encrypted: ECDHE-RSA-AES256-GCM-SHA384 X-Barracuda-URL: https://192.48.157.11:443/cgi-mod/mark.cgi X-Barracuda-Scan-Msg-Size: 3962 X-Virus-Scanned: by bsmtpd at sgi.com X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using per-user scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=2.7 tests=BSF_SC0_MISMATCH_TO, UNPARSEABLE_RELAY X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.32272 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.00 BSF_SC0_MISMATCH_TO Envelope rcpt doesn't match header 0.00 UNPARSEABLE_RELAY Informational: message has unparseable relay lines Cc: linux-xfs@vger.kernel.org, xfs@oss.sgi.com X-BeenThere: xfs@oss.sgi.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: XFS Filesystem from SGI List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: xfs-bounces@oss.sgi.com Sender: xfs-bounces@oss.sgi.com X-Virus-Scanned: ClamAV using ClamSMTP Fix various code sloppinesses pointed out by Coverity. Coverity-id: 1371628 - 1371638 Signed-off-by: Darrick J. Wong --- db/fsmap.c | 1 + repair/phase5.c | 12 ++++++++---- repair/rmap.c | 5 +++-- repair/scan.c | 1 + 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/db/fsmap.c b/db/fsmap.c index b2ba55d..4b245b9 100644 --- a/db/fsmap.c +++ b/db/fsmap.c @@ -75,6 +75,7 @@ fsmap( high.rm_owner = ULLONG_MAX; high.rm_offset = ULLONG_MAX; high.rm_flags = XFS_RMAP_ATTR_FORK | XFS_RMAP_BMBT_BLOCK | XFS_RMAP_UNWRITTEN; + high.rm_blockcount = low.rm_blockcount = 0; start_ag = XFS_FSB_TO_AGNO(mp, start_fsb); end_ag = XFS_FSB_TO_AGNO(mp, end_fsb); diff --git a/repair/phase5.c b/repair/phase5.c index e583879..5a7185c 100644 --- a/repair/phase5.c +++ b/repair/phase5.c @@ -1464,7 +1464,7 @@ prop_rmap_cursor( * and set the rightsib pointer of current block */ #ifdef XR_BLD_INO_TRACE - fprintf(stderr, " ino prop agbno %d ", lptr->prev_agbno); + fprintf(stderr, " rmap prop agbno %d ", lptr->prev_agbno); #endif if (lptr->prev_agbno != NULLAGBLOCK) { ASSERT(lptr->prev_buf_p != NULL); @@ -1502,7 +1502,7 @@ prop_rmap_cursor( prop_rmap_cursor(mp, agno, btree_curs, rm_rec, level); } /* - * add inode info to current block + * add rmap info to current block */ be16_add_cpu(&bt_hdr->bb_numrecs, 1); @@ -1548,6 +1548,7 @@ prop_rmap_highkey( bt_key->rm_offset = cpu_to_be64( libxfs_rmap_irec_offset_pack(&high_key)); + key.rm_blockcount = 0; for (i = 1; i < numrecs - 1; i++) { bt_key = XFS_RMAP_HIGH_KEY_ADDR(bt_hdr, i); key.rm_startblock = be32_to_cpu(bt_key->rm_startblock); @@ -1621,7 +1622,7 @@ _("Insufficient memory to construct reverse-map cursor.")); rm_rec = pop_slab_cursor(rmap_cur); lptr = &btree_curs->level[0]; - for (i = 0; i < lptr->num_blocks; i++) { + for (i = 0; i < lptr->num_blocks && rm_rec != NULL; i++) { /* * block initialization, lay in block header */ @@ -1639,14 +1640,17 @@ _("Insufficient memory to construct reverse-map cursor.")); if (lptr->modulo > 0) lptr->modulo--; - if (lptr->num_recs_pb > 0) + if (lptr->num_recs_pb > 0) { + ASSERT(rm_rec != NULL); prop_rmap_cursor(mp, agno, btree_curs, rm_rec, 0); + } bt_rec = (struct xfs_rmap_rec *) ((char *)bt_hdr + XFS_RMAP_BLOCK_LEN); highest_key.rm_startblock = 0; highest_key.rm_owner = 0; highest_key.rm_offset = 0; + highest_key.rm_blockcount = 0; for (j = 0; j < be16_to_cpu(bt_hdr->bb_numrecs); j++) { ASSERT(rm_rec != NULL); bt_rec[j].rm_startblock = diff --git a/repair/rmap.c b/repair/rmap.c index f22f4f0..b3d4c25 100644 --- a/repair/rmap.c +++ b/repair/rmap.c @@ -316,7 +316,7 @@ fold_raw_rmaps( struct xfs_slab_cursor *cur = NULL; struct xfs_rmap_irec *prev, *rec; size_t old_sz; - int error; + int error = 0; old_sz = slab_count(ag_rmaps[agno].ar_rmaps); if (slab_count(ag_rmaps[agno].ar_raw_rmaps) == 0) @@ -329,7 +329,7 @@ fold_raw_rmaps( prev = pop_slab_cursor(cur); rec = pop_slab_cursor(cur); - while (rec) { + while (prev && rec) { if (mergeable_rmaps(prev, rec)) { prev->rm_blockcount += rec->rm_blockcount; rec = pop_slab_cursor(cur); @@ -843,6 +843,7 @@ rmap_high_key_from_rec( (rec->rm_flags & XFS_RMAP_BMBT_BLOCK)) return; key->rm_offset += adj; + key->rm_blockcount = 0; } /* diff --git a/repair/scan.c b/repair/scan.c index 9a46dd0..253e3de 100644 --- a/repair/scan.c +++ b/repair/scan.c @@ -1109,6 +1109,7 @@ advance: key.rm_flags = 0; key.rm_startblock = be32_to_cpu(kp->rm_startblock); key.rm_owner = be64_to_cpu(kp->rm_owner); + key.rm_blockcount = 0; if (libxfs_rmap_irec_offset_unpack(be64_to_cpu(kp->rm_offset), &key)) { /* Look for impossible flags. */