cluster: RHEL6 - gfs2_edit: Clean up some magic offsets

Bob Peterson rpeterso at fedoraproject.org
Wed Jul 24 15:56:08 UTC 2013


Gitweb:        http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=06e931e14d958ca0b38c202ad09b6e6f4943a5df
Commit:        06e931e14d958ca0b38c202ad09b6e6f4943a5df
Parent:        d019d4a3697fa9d5e055d86e6b40f02a3f22cd60
Author:        Andrew Price <anprice at redhat.com>
AuthorDate:    Fri May 25 10:36:07 2012 +0100
Committer:     Bob Peterson <rpeterso at redhat.com>
CommitterDate: Wed Jul 24 10:39:04 2013 -0500

gfs2_edit: Clean up some magic offsets

Replace some uses of magic offsets with equivalent struct member
accesses.

rhbz#987508
---
 gfs2/edit/hexedit.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index aec0944..cd3ed63 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -1275,6 +1275,7 @@ static int hexdump(uint64_t startaddr, int len)
 	uint64_t l;
 	const char *lpBuffer = bh->b_data;
 	int print_field, cursor_line;
+	const uint32_t block_type = get_block_type(bh);
 
 	strcpy(edit_fmt,"%02x");
 	pointer = (unsigned char *)lpBuffer + offset;
@@ -1372,7 +1373,7 @@ static int hexdump(uint64_t startaddr, int len)
 		}
 		print_gfs2("] ");
 		if (print_field >= 0) {
-			switch (get_block_type(bh)) {
+			switch (block_type) {
 			case GFS2_METATYPE_SB:   /* 1 */
 				print_gfs2(which_fieldname_sb(print_field));
 				break;
@@ -1413,9 +1414,9 @@ static int hexdump(uint64_t startaddr, int len)
 			}
 		}
 		if (cursor_line) {
-			if (((*(bh->b_data + 7) == GFS2_METATYPE_IN) ||
-			   (*(bh->b_data + 7) == GFS2_METATYPE_DI &&
-			    (*(bh->b_data + 0x8b) || *(bh->b_data + 0x8a))))) {
+			if (block_type == GFS2_METATYPE_IN ||
+			    ((block_type == GFS2_METATYPE_DI) &&
+			     ((struct gfs2_dinode*)bh->b_data)->di_height)) {
 				int ptroffset = edit_row[dmode] * 16 +
 					edit_col[dmode];
 


More information about the cluster-commits mailing list