cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Andrew Price <anprice@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 6/8] fsck.gfs2: Remove unsigned comparisons with zero
Date: Wed, 11 Jan 2012 18:21:20 +0000	[thread overview]
Message-ID: <1326306082-20381-6-git-send-email-anprice@redhat.com> (raw)
In-Reply-To: <1326306082-20381-1-git-send-email-anprice@redhat.com>

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 <anprice@redhat.com>
---
 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



  parent reply	other threads:[~2012-01-11 18:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-11 18:21 [Cluster-devel] [PATCH 1/8] gfs2_edit: Check more error values from gfs2_get_bitmap Andrew Price
2012-01-11 18:21 ` [Cluster-devel] [PATCH 2/8] gfs2_edit: Fix another resource leak in display_extended Andrew Price
2012-01-11 18:21 ` [Cluster-devel] [PATCH 3/8] mkfs.gfs2: Fix use of uninitialized value in check_dev_content Andrew Price
2012-01-11 18:21 ` [Cluster-devel] [PATCH 4/8] gfs2_convert: Fix null pointer deref in journ_space_to_rg Andrew Price
2012-01-11 18:21 ` [Cluster-devel] [PATCH 5/8] gfs2_convert: Fix null pointer deref in conv_build_jindex Andrew Price
2012-01-11 18:21 ` Andrew Price [this message]
2012-01-11 18:21 ` [Cluster-devel] [PATCH 7/8] fsck.gfs2: Plug a leak in init_system_inodes() Andrew Price
2012-01-11 18:21 ` [Cluster-devel] [PATCH 8/8] libgfs2: Set errno in dirent_alloc and use dir_add consistently Andrew Price
2012-01-11 18:28   ` Bob Peterson
2012-01-11 18:43   ` Abhijith Das

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=1326306082-20381-6-git-send-email-anprice@redhat.com \
    --to=anprice@redhat.com \
    /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).