LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File gfs2_edit_negative_block_numbers_dont_jump_a_negative_amount.patch of Package cluster (Project home:sschapiro:openstack:upstream)

commit 6a1d315205541d165d7888b84889df12cda5150d
Author: Bob Peterson <bob@ganesha.(none)>
Date:   Thu Sep 30 11:46:42 2010 -0500

    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#634623

diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 95959ad..5a1b08b 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -2229,26 +2229,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) {