From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Price Date: Wed, 11 Jan 2012 18:21:20 +0000 Subject: [Cluster-devel] [PATCH 6/8] fsck.gfs2: Remove unsigned comparisons with zero In-Reply-To: <1326306082-20381-1-git-send-email-anprice@redhat.com> References: <1326306082-20381-1-git-send-email-anprice@redhat.com> Message-ID: <1326306082-20381-6-git-send-email-anprice@redhat.com> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Spotted by coverity: This less-than-zero comparison of an unsigned value is never true. "q < 0". (Fixes 6 occurrences) Signed-off-by: Andrew Price --- gfs2/fsck/metawalk.c | 9 +++------ gfs2/fsck/pass1b.c | 2 +- gfs2/fsck/pass2.c | 2 +- gfs2/fsck/pass5.c | 6 ------ 4 files changed, 5 insertions(+), 14 deletions(-) diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c index d78df72..eb80ccf 100644 --- a/gfs2/fsck/metawalk.c +++ b/gfs2/fsck/metawalk.c @@ -1530,8 +1530,7 @@ static int alloc_metalist(struct gfs2_inode *ip, uint64_t block, after the bitmap has been set but before the blockmap has. */ *bh = bread(ip->i_sbd, block); q = block_type(block); - if (q < 0 || - blockmap_to_bitmap(q, ip->i_sbd->gfs1) == GFS2_BLKST_FREE) { + if (blockmap_to_bitmap(q, ip->i_sbd->gfs1) == GFS2_BLKST_FREE) { log_debug(_("%s reference to new metadata block " "%lld (0x%llx) is now marked as indirect.\n"), desc, (unsigned long long)block, @@ -1550,8 +1549,7 @@ static int alloc_data(struct gfs2_inode *ip, uint64_t block, void *private) /* We can't check the bitmap here because this function is called after the bitmap has been set but before the blockmap has. */ q = block_type(block); - if (q < 0 || - blockmap_to_bitmap(q, ip->i_sbd->gfs1) == GFS2_BLKST_FREE) { + if (blockmap_to_bitmap(q, ip->i_sbd->gfs1) == GFS2_BLKST_FREE) { log_debug(_("%s reference to new data block " "%lld (0x%llx) is now marked as data.\n"), desc, (unsigned long long)block, @@ -1569,8 +1567,7 @@ static int alloc_leaf(struct gfs2_inode *ip, uint64_t block, void *private) /* We can't check the bitmap here because this function is called after the bitmap has been set but before the blockmap has. */ q = block_type(block); - if (q < 0 || - blockmap_to_bitmap(q, ip->i_sbd->gfs1) == GFS2_BLKST_FREE) + if (blockmap_to_bitmap(q, ip->i_sbd->gfs1) == GFS2_BLKST_FREE) fsck_blockmap_set(ip, block, _("newly allocated leaf"), gfs2_leaf_blk); return 0; diff --git a/gfs2/fsck/pass1b.c b/gfs2/fsck/pass1b.c index 1879cc4..ae6d45c 100644 --- a/gfs2/fsck/pass1b.c +++ b/gfs2/fsck/pass1b.c @@ -701,7 +701,7 @@ static int handle_dup_blk(struct gfs2_sbd *sdp, struct duptree *b) ip = fsck_load_inode(sdp, id->block_no); q = block_type(id->block_no); - if (q < 0 || q == gfs2_inode_invalid) { + if (q == gfs2_inode_invalid) { log_debug( _("The remaining reference inode %lld " "(0x%llx) is marked invalid: Marking " "the block as free.\n"), diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c index 8562b6a..d89dd4f 100644 --- a/gfs2/fsck/pass2.c +++ b/gfs2/fsck/pass2.c @@ -328,7 +328,7 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent, * 2. Blocks marked "bad" need to have their entire * metadata tree deleted. */ - if (q < 0 || q == gfs2_inode_invalid || q == gfs2_bad_block) { + if (q == gfs2_inode_invalid || q == gfs2_bad_block) { /* This entry's inode has bad blocks in it */ /* Handle bad blocks */ diff --git a/gfs2/fsck/pass5.c b/gfs2/fsck/pass5.c index cb18b5a..6c08e13 100644 --- a/gfs2/fsck/pass5.c +++ b/gfs2/fsck/pass5.c @@ -123,12 +123,6 @@ static int check_block_status(struct gfs2_sbd *sdp, char *buffer, return 0; q = block_type(block); - if (q < 0) { - log_err( _("Invalid block type for block #%llu " - "(0x%llx)\n"), (unsigned long long)block, - (unsigned long long)block); - return q; - } if (sdp->gfs1) block_status = gfs1_convert_mark(q, count); -- 1.7.6.5