Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Cluster Development (http://www.linux-archive.org/cluster-development/)
-   -   gfs2_edit: Clean up some magic offsets (http://www.linux-archive.org/cluster-development/670896-gfs2_edit-clean-up-some-magic-offsets.html)

Andrew Price 05-25-2012 10:07 AM

gfs2_edit: Clean up some magic offsets
 
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

Steven Whitehouse 05-25-2012 10:19 AM

gfs2_edit: Clean up some magic offsets
 
Hi,

Those all look ok to me,

Steve.

On Fri, 2012-05-25 at 11:07 +0100, Andrew Price wrote:
> 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];
>


All times are GMT. The time now is 01:50 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.