Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=86f318445da... Commit: 86f318445da6e2ef0c38db105ece990a13b93ea2 Parent: 5375e2b9b5032ae3c08fefc10f067762ca2db19b Author: Andrew Price anprice@redhat.com AuthorDate: Thu Feb 4 10:51:03 2016 +0000 Committer: Andrew Price anprice@redhat.com CommitterDate: Thu Feb 4 10:54:11 2016 +0000
gfs2_edit: Remove block_in_mem and fix a memory leak
block_in_mem is meant to be the block number that relates to the global bh. bh->b_blocknr can be used for the same purpose so remove block_in_mem. Also fix a memory leak that occurs when the displayed block changes.
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/edit/gfs2hex.c | 1 - gfs2/edit/hexedit.c | 8 ++++---- gfs2/edit/hexedit.h | 1 - 3 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/gfs2/edit/gfs2hex.c b/gfs2/edit/gfs2hex.c index 1f55a43..3d280b5 100644 --- a/gfs2/edit/gfs2hex.c +++ b/gfs2/edit/gfs2hex.c @@ -42,7 +42,6 @@ uint64_t block = 0; int blockhist = 0; struct iinfo *indirect; int indirect_blocks; -uint64_t block_in_mem = -1; struct gfs2_sbd sbd; uint64_t starting_blk; struct blkstack_info blockstack[BLOCK_STACK_SIZE]; diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c index a89ae36..5adf7c5 100644 --- a/gfs2/edit/hexedit.c +++ b/gfs2/edit/hexedit.c @@ -1072,7 +1072,9 @@ int display(int identify_only, int trunc_zeros, uint64_t flagref, display_title_lines(); move(2,0); } - if (block_in_mem != blk) { /* If we changed blocks from the last read */ + if (bh == NULL || bh->b_blocknr != blk) { /* If we changed blocks from the last read */ + if (bh != NULL) + brelse(bh); dev_offset = blk * sbd.bsize; ioctl(sbd.device_fd, BLKFLSBUF, 0); if (!(bh = bread(&sbd, blk))) { @@ -1083,7 +1085,6 @@ int display(int identify_only, int trunc_zeros, uint64_t flagref, (unsigned long long)dev_offset); exit(-1); } - block_in_mem = blk; /* remember which block is in memory */ } line = 1; gfs2_struct_type = display_block_type(bh, FALSE); @@ -1869,7 +1870,6 @@ static void interactive_mode(void) bobgets(estring, edit_row[dmode]+4, 24, 10, &ch); process_field(efield, estring); - block_in_mem = -1; } else bobgets(estring, edit_row[dmode]+6, 14, edit_size[dmode], &ch); @@ -2534,7 +2534,7 @@ int main(int argc, char *argv[]) edit_row[GFS2_MODE]++; else read_master_dir(); - block_in_mem = -1; + process_parameters(argc, argv, 1); /* get what to print from cmdline */
block = blockstack[0].block = starting_blk * (4096 / sbd.bsize); diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h index f3220a7..4f7207b 100644 --- a/gfs2/edit/hexedit.h +++ b/gfs2/edit/hexedit.h @@ -54,7 +54,6 @@ extern struct gfs2_inum gfs1_license_di; /* kludge because gfs2 sb too small */ extern struct gfs2_dinode di; extern int screen_chunk_size; /* how much of the 4K can fit on screen */ extern int gfs2_struct_type; -extern uint64_t block_in_mem; extern int identify; extern int color_scheme; extern WINDOW *wind;
cluster-commits@lists.fedorahosted.org