cluster: RHEL57 - gfs2_edit: negative block numbers don't jump a negative amount

Bob Peterson rpeterso at fedoraproject.org
Wed Feb 2 21:15:44 UTC 2011


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=958040b30a788f48c0451ca589db4018b4a325af
Commit:        958040b30a788f48c0451ca589db4018b4a325af
Parent:        7c8b325db69186d61a44a0f38c46278ea000b2a6
Author:        Bob Peterson <rpeterso at redhat.com>
AuthorDate:    Mon Dec 13 10:46:17 2010 -0600
Committer:     Bob Peterson <rpeterso at redhat.com>
CommitterDate: Wed Feb 2 14:36:09 2011 -0600

gfs2_edit: negative block numbers don't jump a negative amount

This patch fixes a bug whereby entering a negative block number
in the block address was not jumping the appropriate amount.

rhbz#656371
---
 gfs2/edit/hexedit.c |   17 +++++------------
 1 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 196b324..1c3fafe 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -2242,26 +2242,19 @@ uint64_t check_keywords(const char *kword)
 static uint64_t goto_block(void)
 {
 	char string[256];
-	int ch;
+	int ch, delta;
 
 	memset(string, 0, sizeof(string));
 	sprintf(string,"%"PRId64, block);
 	if (bobgets(string, 1, 7, 16, &ch)) {
 		if (isalnum(string[0]) || string[0] == '/')
 			temp_blk = check_keywords(string);
-		else if (string[0] == '+') {
-			if (string[1] == '0' && string[2] == 'x')
-				sscanf(string, "%"SCNx64, &temp_blk);
-			else
-				sscanf(string, "%" PRIu64, &temp_blk);
-			temp_blk += block;
-		}
-		else if (string[0] == '-') {
+		else if (string[0] == '+' || string[0] == '-') {
 			if (string[1] == '0' && string[2] == 'x')
-				sscanf(string, "%"SCNx64, &temp_blk);
+				sscanf(string, "%x", &delta);
 			else
-				sscanf(string, "%" PRIu64, &temp_blk);
-			temp_blk -= block;
+				sscanf(string, "%d", &delta);
+			temp_blk = block + delta;
 		}
 
 		if (temp_blk == RGLIST_DUMMY_BLOCK || temp_blk < max_block) {


More information about the cluster-commits mailing list