[Cluster-devel] [fsck.gfs2 PATCH 03/30] fsck.gfs2: Change bitmap_type variables to int

Bob Peterson rpeterso at redhat.com
Fri Apr 15 13:37:57 UTC 2016


This patch changes all references of "q" from a uint8_t to a normal
int. This will allow us to check for bad return codes at some point.

Signed-off-by: Bob Peterson <rpeterso at redhat.com>
---
 gfs2/fsck/fsck.h         |  2 +-
 gfs2/fsck/lost_n_found.c |  2 +-
 gfs2/fsck/metawalk.c     | 12 ++++++------
 gfs2/fsck/pass1.c        | 18 +++++++++---------
 gfs2/fsck/pass1b.c       |  6 +++---
 gfs2/fsck/pass2.c        | 16 ++++++++--------
 gfs2/fsck/pass3.c        |  4 ++--
 gfs2/fsck/pass4.c        |  2 +-
 gfs2/fsck/pass5.c        |  2 +-
 gfs2/fsck/util.c         |  2 +-
 gfs2/fsck/util.h         | 10 +++++-----
 11 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/gfs2/fsck/fsck.h b/gfs2/fsck/fsck.h
index a3c5f72..4cf4ce1 100644
--- a/gfs2/fsck/fsck.h
+++ b/gfs2/fsck/fsck.h
@@ -53,7 +53,7 @@ struct dir_info
 struct dir_status {
 	uint8_t dotdir:1;
 	uint8_t dotdotdir:1;
-	uint8_t q;
+	int q;
 	uint32_t entry_count;
 };
 
diff --git a/gfs2/fsck/lost_n_found.c b/gfs2/fsck/lost_n_found.c
index 4816b3c..0b57d21 100644
--- a/gfs2/fsck/lost_n_found.c
+++ b/gfs2/fsck/lost_n_found.c
@@ -99,7 +99,7 @@ static void add_dotdot(struct gfs2_inode *ip)
 
 void make_sure_lf_exists(struct gfs2_inode *ip)
 {
-	uint8_t q;
+	int q;
 	struct dir_info *di;
 	struct gfs2_sbd *sdp = ip->i_sbd;
 	uint32_t mode;
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index f401f2c..3cb5a7a 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -1040,7 +1040,7 @@ static int delete_block_if_notdup(struct gfs2_inode *ip, uint64_t block,
 				  const char *btype, int *was_duplicate,
 				  void *private)
 {
-	uint8_t q;
+	int q;
 
 	if (!valid_block(ip->i_sbd, block))
 		return meta_error;
@@ -1760,7 +1760,7 @@ int remove_dentry_from_dir(struct gfs2_sbd *sdp, uint64_t dir,
 {
 	struct metawalk_fxns remove_dentry_fxns = {0};
 	struct gfs2_inode *ip;
-	uint8_t q;
+	int q;
 	int error;
 
 	log_debug( _("Removing dentry %llu (0x%llx) from directory %llu"
@@ -1822,7 +1822,7 @@ static int del_eattr_generic(struct gfs2_inode *ip, uint64_t block,
 {
 	int ret = 0;
 	int was_free = 0;
-	uint8_t q;
+	int q;
 
 	if (valid_block(ip->i_sbd, block)) {
 		q = bitmap_type(ip->i_sbd, block);
@@ -1916,7 +1916,7 @@ static int alloc_metalist(struct gfs2_inode *ip, uint64_t block,
 			  struct gfs2_buffer_head **bh, int h, int *is_valid,
 			  int *was_duplicate, void *private)
 {
-	uint8_t q;
+	int q;
 	const char *desc = (const char *)private;
 
 	/* No need to range_check here--if it was added, it's in range. */
@@ -1941,7 +1941,7 @@ static int alloc_data(struct gfs2_inode *ip, uint64_t metablock,
 		      uint64_t block, void *private,
 		      struct gfs2_buffer_head *bh, uint64_t *ptr)
 {
-	uint8_t q;
+	int q;
 	const char *desc = (const char *)private;
 
 	/* No need to range_check here--if it was added, it's in range. */
@@ -1960,7 +1960,7 @@ static int alloc_data(struct gfs2_inode *ip, uint64_t metablock,
 
 static int alloc_leaf(struct gfs2_inode *ip, uint64_t block, void *private)
 {
-	uint8_t q;
+	int q;
 
 	/* No need to range_check here--if it was added, it's in range. */
 	/* We can't check the bitmap here because this function is called
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index 875f3d3..cc70d5f 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -214,7 +214,7 @@ struct metawalk_fxns sysdir_fxns = {
 static int p1check_leaf(struct gfs2_inode *ip, uint64_t block, void *private)
 {
 	struct block_count *bc = (struct block_count *) private;
-	uint8_t q;
+	int q;
 
 	/* Note if we've gotten this far, the block has already passed the
 	   check in metawalk: gfs2_check_meta(lbh, GFS2_METATYPE_LF).
@@ -247,7 +247,7 @@ static int check_metalist(struct gfs2_inode *ip, uint64_t block,
 			  struct gfs2_buffer_head **bh, int h, int *is_valid,
 			  int *was_duplicate, void *private)
 {
-	uint8_t q;
+	int q;
 	int iblk_type;
 	struct gfs2_buffer_head *nbh;
 	struct block_count *bc = (struct block_count *)private;
@@ -445,7 +445,7 @@ static int check_data(struct gfs2_inode *ip, uint64_t metablock,
 		      uint64_t block, void *private,
 		      struct gfs2_buffer_head *bbh, uint64_t *ptr)
 {
-	uint8_t q;
+	int q;
 	struct block_count *bc = (struct block_count *) private;
 
 	if (!valid_block(ip->i_sbd, block)) {
@@ -581,7 +581,7 @@ static int undo_eattr_indir_or_leaf(struct gfs2_inode *ip, uint64_t block,
 				    void *private)
 {
 	struct gfs2_sbd *sdp = ip->i_sbd;
-	uint8_t q;
+	int q;
 	int error;
 	struct block_count *bc = (struct block_count *) private;
 
@@ -629,7 +629,7 @@ static int check_eattr_indir(struct gfs2_inode *ip, uint64_t indirect,
 {
 	struct gfs2_sbd *sdp = ip->i_sbd;
 	int ret = 0;
-	uint8_t q;
+	int q;
 	struct block_count *bc = (struct block_count *) private;
 
 	/* This inode contains an eattr - it may be invalid, but the
@@ -720,7 +720,7 @@ static int check_ealeaf_block(struct gfs2_inode *ip, uint64_t block, int btype,
 {
 	struct gfs2_buffer_head *leaf_bh = NULL;
 	struct gfs2_sbd *sdp = ip->i_sbd;
-	uint8_t q;
+	int q;
 	struct block_count *bc = (struct block_count *) private;
 
 	q = block_type(block);
@@ -948,7 +948,7 @@ static int mark_block_invalid(struct gfs2_inode *ip, uint64_t block,
 			      enum dup_ref_type reftype, const char *btype,
 			      int *is_valid, int *was_duplicate)
 {
-	uint8_t q;
+	int q;
 
 	/* If the block isn't valid, we obviously can't invalidate it.
 	 * However, if we return an error, invalidating will stop, and
@@ -1051,7 +1051,7 @@ static int rangecheck_block(struct gfs2_inode *ip, uint64_t block,
 			    void *private)
 {
 	long *bad_pointers = (long *)private;
-	uint8_t q;
+	int q;
 
 	if (!valid_block(ip->i_sbd, block)) {
 		(*bad_pointers)++;
@@ -1583,7 +1583,7 @@ static int pass1_process_bitmap(struct gfs2_sbd *sdp, struct rgrp_tree *rgd, uin
 	unsigned i;
 	uint64_t block;
 	struct gfs2_inode *ip;
-	uint8_t q;
+	int q;
 	/* Readahead numbers arrived at by experiment */
 	unsigned rawin = 50;
 	unsigned ralen = 100 * sdp->bsize;
diff --git a/gfs2/fsck/pass1b.c b/gfs2/fsck/pass1b.c
index 66dd0a8..a7b3e42 100644
--- a/gfs2/fsck/pass1b.c
+++ b/gfs2/fsck/pass1b.c
@@ -203,7 +203,7 @@ static void resolve_dup_references(struct gfs2_sbd *sdp, struct duptree *dt,
 	enum dup_ref_type this_ref;
 	struct inode_info *ii;
 	int found_good_ref = 0;
-	uint8_t q;
+	int q;
 
 	osi_list_foreach_safe(tmp, ref_list, x) {
 		if (skip_this_pass || fsck_abort)
@@ -502,7 +502,7 @@ static void resolve_last_reference(struct gfs2_sbd *sdp, struct duptree *dt,
 	struct gfs2_inode *ip;
 	struct inode_with_dups *id;
 	osi_list_t *tmp;
-	uint8_t q;
+	int q;
 
 	log_notice( _("Block %llu (0x%llx) has only one remaining "
 		      "valid inode referencing it.\n"),
@@ -856,7 +856,7 @@ int pass1b(struct gfs2_sbd *sdp)
 {
 	struct duptree *dt;
 	uint64_t i;
-	uint8_t q;
+	int q;
 	struct osi_node *n;
 	int rc = FSCK_OK;
 
diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c
index afee8dc..f114d2b 100644
--- a/gfs2/fsck/pass2.c
+++ b/gfs2/fsck/pass2.c
@@ -135,7 +135,7 @@ static const char *de_type_string(uint8_t de_type)
 	return de_types[3]; /* invalid */
 }
 
-static int check_file_type(uint64_t block, uint8_t de_type, uint8_t q,
+static int check_file_type(uint64_t block, uint8_t de_type, int q,
 			   int gfs1, int *isdir)
 {
 	struct dir_info *dt;
@@ -176,7 +176,7 @@ struct metawalk_fxns pass2_fxns_delete = {
  */
 static int bad_formal_ino(struct gfs2_inode *ip, struct gfs2_dirent *dent,
 			  struct gfs2_inum entry, const char *tmp_name,
-			  uint8_t q, struct gfs2_dirent *de,
+			  int q, struct gfs2_dirent *de,
 			  struct gfs2_buffer_head *bh)
 {
 	struct inode_info *ii;
@@ -299,7 +299,7 @@ static int wrong_leaf(struct gfs2_inode *ip, struct gfs2_inum *entry,
 		      int hash_index, struct gfs2_buffer_head *bh,
 		      struct dir_status *ds, struct gfs2_dirent *dent,
 		      struct gfs2_dirent *de, struct gfs2_dirent *prev_de,
-		      uint32_t *count, uint8_t q)
+		      uint32_t *count, int q)
 {
 	struct gfs2_sbd *sdp = ip->i_sbd;
 	struct gfs2_buffer_head *dest_lbh;
@@ -437,7 +437,7 @@ static int wrong_leaf(struct gfs2_inode *ip, struct gfs2_inum *entry,
 static int basic_dentry_checks(struct gfs2_inode *ip, struct gfs2_dirent *dent,
 			       struct gfs2_inum *entry, const char *tmp_name,
 			       uint32_t *count, struct gfs2_dirent *de,
-			       struct dir_status *ds, uint8_t *q,
+			       struct dir_status *ds, int *q,
 			       struct gfs2_buffer_head *bh, int *isdir)
 {
 	struct gfs2_sbd *sdp = ip->i_sbd;
@@ -643,7 +643,7 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
 			uint32_t *count, int *lindex, void *priv)
 {
 	struct gfs2_sbd *sdp = ip->i_sbd;
-	uint8_t q = 0;
+	int q = 0;
 	char tmp_name[MAX_FILENAME];
 	struct gfs2_inum entry;
 	struct dir_status *ds = (struct dir_status *) priv;
@@ -955,7 +955,7 @@ static int lost_leaf(struct gfs2_inode *ip, uint64_t *tbl, uint64_t leafno,
 		} else {
 			uint32_t count;
 			struct dir_status ds = {0};
-			uint8_t q = 0;
+			int q = 0;
 
 			error = basic_dentry_checks(ip, dent, &de.de_inum,
 						    tmp_name, &count, &de,
@@ -1013,7 +1013,7 @@ static int basic_check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
 			      struct gfs2_buffer_head *bh, char *filename,
 			      uint32_t *count, int *lindex, void *priv)
 {
-	uint8_t q = 0;
+	int q = 0;
 	char tmp_name[MAX_FILENAME];
 	struct gfs2_inum entry;
 	struct dir_status *ds = (struct dir_status *) priv;
@@ -1953,7 +1953,7 @@ static int pass2_check_dir(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
 int pass2(struct gfs2_sbd *sdp)
 {
 	uint64_t dirblk;
-	uint8_t q;
+	int q;
 
 	/* Check all the system directory inodes. */
 	if (!sdp->gfs1 &&
diff --git a/gfs2/fsck/pass3.c b/gfs2/fsck/pass3.c
index 7732178..a3c0a60 100644
--- a/gfs2/fsck/pass3.c
+++ b/gfs2/fsck/pass3.c
@@ -65,7 +65,7 @@ static struct dir_info *mark_and_return_parent(struct gfs2_sbd *sdp,
 					       struct dir_info *di)
 {
 	struct dir_info *pdi;
-	uint8_t q_dotdot, q_treewalk;
+	int q_dotdot, q_treewalk;
 	int error = 0;
 	struct dir_info *dt_dotdot, *dt_treewalk;
 
@@ -181,7 +181,7 @@ int pass3(struct gfs2_sbd *sdp)
 	struct osi_node *tmp, *next = NULL;
 	struct dir_info *di, *tdi;
 	struct gfs2_inode *ip;
-	uint8_t q;
+	int q;
 	struct alloc_state lf_as = {.as_blocks = 0, .as_meta_goal = 0};
 
 	di = dirtree_find(sdp->md.rooti->i_di.di_num.no_addr);
diff --git a/gfs2/fsck/pass4.c b/gfs2/fsck/pass4.c
index c3fb30a..dcd5ba7 100644
--- a/gfs2/fsck/pass4.c
+++ b/gfs2/fsck/pass4.c
@@ -47,7 +47,7 @@ static int scan_inode_list(struct gfs2_sbd *sdp) {
 	struct inode_info *ii;
 	struct gfs2_inode *ip;
 	int lf_addition = 0;
-	uint8_t q;
+	int q;
 	struct alloc_state lf_as = {.as_blocks = 0, .as_meta_goal = 0};
 
 	/* FIXME: should probably factor this out into a generic
diff --git a/gfs2/fsck/pass5.c b/gfs2/fsck/pass5.c
index fab3e5c..99ff0a1 100644
--- a/gfs2/fsck/pass5.c
+++ b/gfs2/fsck/pass5.c
@@ -19,7 +19,7 @@ static int check_block_status(struct gfs2_sbd *sdp, char *buffer,
 	unsigned char *byte, *end;
 	unsigned int bit;
 	unsigned char rg_status;
-	uint8_t q;
+	int q;
 	uint64_t block;
 
 	/* FIXME verify cast */
diff --git a/gfs2/fsck/util.c b/gfs2/fsck/util.c
index 44a41ba..55bd050 100644
--- a/gfs2/fsck/util.c
+++ b/gfs2/fsck/util.c
@@ -364,7 +364,7 @@ int add_duplicate_ref(struct gfs2_inode *ip, uint64_t block,
 
 	if (id == NULL) {
 		/* Check for the inode on the invalid inode reference list. */
-		uint8_t q;
+		int q;
 
 		id = calloc(1, sizeof(*id));
 		if (!id) {
diff --git a/gfs2/fsck/util.h b/gfs2/fsck/util.h
index 7d842e2..8709193 100644
--- a/gfs2/fsck/util.h
+++ b/gfs2/fsck/util.h
@@ -47,11 +47,11 @@ static inline int astate_changed(struct gfs2_inode *ip, struct alloc_state *as)
 	return 0;
 }
 
-static inline uint8_t block_type(uint64_t bblock)
+static inline int block_type(uint64_t bblock)
 {
 	static unsigned char *byte;
 	static uint64_t b;
-	static uint8_t btype;
+	static int btype;
 
 	byte = bl->map + BLOCKMAP_SIZE2(bblock);
 	b = BLOCKMAP_BYTE_OFFSET2(bblock);
@@ -59,7 +59,7 @@ static inline uint8_t block_type(uint64_t bblock)
 	return btype;
 }
 
-static inline uint8_t bitmap_type(struct gfs2_sbd *sdp, uint64_t bblock)
+static inline int bitmap_type(struct gfs2_sbd *sdp, uint64_t bblock)
 {
 	struct rgrp_tree *rgd;
 
@@ -67,10 +67,10 @@ static inline uint8_t bitmap_type(struct gfs2_sbd *sdp, uint64_t bblock)
 	return lgfs2_get_bitmap(sdp, bblock, rgd);
 }
 
-static const inline char *block_type_string(uint8_t q)
+static const inline char *block_type_string(int q)
 {
 	const char *blktyp[] = {"free", "data", "other", "inode", "invalid"};
-	if (q <= GFS2_BLKST_DINODE)
+	if (q >= GFS2_BLKST_FREE && q <= GFS2_BLKST_DINODE)
 		return (blktyp[q]);
 	return blktyp[4];
 }
-- 
2.5.5




More information about the Cluster-devel mailing list