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 3/3] gfs2_edit: Clean up some magic offsets
Date: Fri, 25 May 2012 11:07:04 +0100	[thread overview]
Message-ID: <1337940424-20662-3-git-send-email-anprice@redhat.com> (raw)
In-Reply-To: <1337940424-20662-1-git-send-email-anprice@redhat.com>

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

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 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 8311534..b4e6d15 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -838,6 +838,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;
@@ -935,7 +936,7 @@ static int hexdump(uint64_t startaddr, int len)
 		}
 		print_gfs2("] ");
 		if (print_field >= 0) {
-			const struct lgfs2_metadata *m = find_mtype(get_block_type(bh), sbd.gfs1);
+			const struct lgfs2_metadata *m = find_mtype(block_type, sbd.gfs1);
 			if (m) {
 				const struct lgfs2_metafield *f;
 				unsigned n;
@@ -951,9 +952,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];
 
-- 
1.7.7.6



  parent reply	other threads:[~2012-05-25 10:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-25 10:07 [Cluster-devel] [PATCH 1/3] gfs2-utils: Remove references to unlinked file tag Andrew Price
2012-05-25 10:07 ` [Cluster-devel] [PATCH 2/3] gfs2_edit: Fix find_mtype and support gfs1 structures Andrew Price
2012-05-25 10:27   ` Andrew Price
2012-05-25 10:40     ` Steven Whitehouse
2012-05-25 10:07 ` Andrew Price [this message]
2012-05-25 10:19   ` [Cluster-devel] [PATCH 3/3] gfs2_edit: Clean up some magic offsets Steven Whitehouse

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=1337940424-20662-3-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).