Skip to contentSkip to conversation

GFS2: Avoid uninitialized variable warning (reprise)

PATCH New Andrew Price 2 participants 2 messages May 25, 2016 – May 26, 2016 GFS2 file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 GFS2: Avoid uninitialized variable warning (reprise)

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.

---
 fs/gfs2/dir.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/gfs2/dir.c +2 -2
index 4a01f30..3182c46 100644
@@ -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;
Signature · 1 line
2.4.11
#1 lore raw

PATCH 1/1 GFS2: Avoid uninitialized variable warning (reprise)

----- Original Message -----

| 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 <[email protected]>

ACK

Bob Peterson