[Cluster-devel] [PATCH] GFS2: Avoid uninitialized variable warning (reprise)

Andrew Price anprice at redhat.com
Wed May 25 17:20:43 UTC 2016


Commit 67893f12e attempted to fix these warnings:

fs/gfs2/dir.c: In function 'get_first_leaf':
fs/gfs2/dir.c:802:9: warning: 'leaf_no' may be used uninitialized in this function [-Wmaybe-uninitialized]
fs/gfs2/dir.c: In function 'dir_split_leaf.isra.26':
fs/gfs2/dir.c:1021:8: warning: 'leaf_no' may be used uninitialized in this function [-Wmaybe-uninitialized]

but they persisted. Fix them once and for all by initializing leaf_no.

Signed-off-by: Andrew Price <anprice at redhat.com>
---
 fs/gfs2/dir.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c
index 4a01f30..3182c46 100644
--- a/fs/gfs2/dir.c
+++ b/fs/gfs2/dir.c
@@ -794,7 +794,7 @@ static int get_leaf_nr(struct gfs2_inode *dip, u32 index,
 static int get_first_leaf(struct gfs2_inode *dip, u32 index,
 			  struct buffer_head **bh_out)
 {
-	u64 leaf_no;
+	u64 leaf_no = 0;
 	int error;
 
 	error = get_leaf_nr(dip, index, &leaf_no);
@@ -1006,7 +1006,7 @@ static int dir_split_leaf(struct inode *inode, const struct qstr *name)
 	struct gfs2_leaf *nleaf, *oleaf;
 	struct gfs2_dirent *dent = NULL, *prev = NULL, *next = NULL, *new;
 	u32 start, len, half_len, divider;
-	u64 bn, leaf_no;
+	u64 bn, leaf_no = 0;
 	__be64 *lp;
 	u32 index;
 	int x, moved = 0;
-- 
2.4.11




More information about the Cluster-devel mailing list