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] gfs2_edit: Don't exit prematurely in display_block_type
Date: Tue, 24 Jan 2012 12:34:32 +0000	[thread overview]
Message-ID: <1327408472-18668-1-git-send-email-anprice@redhat.com> (raw)

Turns out my fixes in 34f59b and 7624e9 were a little heavy handed as
the "errors" from gfs2_get_bitmap aren't fatal. We still need to guard
against negative array subscripts though so this patch removes the
exit() calls and adds checks for the negative returns.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 gfs2/edit/hexedit.c |   30 ++++++++++++------------------
 1 files changed, 12 insertions(+), 18 deletions(-)

diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 808ebb1..4b992de 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -699,10 +699,6 @@ int display_block_type(int from_restore)
 				type = 4;
 			else {
 				type = gfs2_get_bitmap(&sbd, block, rgd);
-				if (type < 0) {
-					fprintf(stderr, "Failed to retrieve block state from bitmap\n");
-					exit(-1);
-				}
 			}
 		} else
 			type = 4;
@@ -710,10 +706,12 @@ int display_block_type(int from_restore)
 		if (!screen_chunk_size)
 			screen_chunk_size = 256;
 		pgnum = (offset / screen_chunk_size);
-		print_gfs2("(p.%d of %d--%s)", pgnum + 1,
-			   (sbd.bsize % screen_chunk_size) > 0 ?
-			   sbd.bsize / screen_chunk_size + 1 : sbd.bsize /
-			   screen_chunk_size, allocdesc[sbd.gfs1][type]);
+		if (type >= 0) {
+			print_gfs2("(p.%d of %d--%s)", pgnum + 1,
+				   (sbd.bsize % screen_chunk_size) > 0 ?
+				   sbd.bsize / screen_chunk_size + 1 : sbd.bsize /
+				   screen_chunk_size, allocdesc[sbd.gfs1][type]);
+		}
 		/*eol(9);*/
 		if ((be32_to_cpu(mh->mh_type) == GFS2_METATYPE_RG)) {
 			int ptroffset = edit_row[dmode] * 16 + edit_col[dmode];
@@ -729,12 +727,10 @@ int display_block_type(int from_restore)
 				print_gfs2(" blk ");
 				for (b = blknum; b < blknum + 4; b++) {
 					btype = gfs2_get_bitmap(&sbd, b, rgd);
-					if (btype < 0) {
-						fprintf(stderr, "Failed to retrieve block state from bitmap\n");
-						exit(-1);
+					if (btype >= 0) {
+						print_gfs2("0x%x-%s  ", b,
+							   allocdesc[sbd.gfs1][btype]);
 					}
-					print_gfs2("0x%x-%s  ", b,
-						   allocdesc[sbd.gfs1][btype]);
 				}
 			}
 		} else if ((be32_to_cpu(mh->mh_type) == GFS2_METATYPE_RB)) {
@@ -765,12 +761,10 @@ int display_block_type(int from_restore)
 				print_gfs2(" blk ");
 				for (b = blknum; b < blknum + 4; b++) {
 					btype = gfs2_get_bitmap(&sbd, b, rgd);
-					if (btype < 0) {
-						fprintf(stderr, "Failed to retrieve block state from bitmap\n");
-						exit(-1);
+					if (btype >= 0) {
+						print_gfs2("0x%x-%s  ", b,
+							   allocdesc[sbd.gfs1][btype]);
 					}
-					print_gfs2("0x%x-%s  ", b,
-						   allocdesc[sbd.gfs1][btype]);
 				}
 			}
 		}
-- 
1.7.7.5



                 reply	other threads:[~2012-01-24 12:34 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1327408472-18668-1-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).