aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2016-01-26 13:08:10 -0500
committerBob Peterson <rpeterso@redhat.com>2016-03-15 10:46:11 -0400
commit67893f12e5374bbcaaffbc6e570acbc2714ea884 (patch)
tree74911bb5323cafb2e8efde1de51f44bd6b65bec1
parent7508abc4bdac43dc87d2fdd31527063f72da7020 (diff)
gfs2: avoid uninitialized variable warning
We get a bogus warning about a potential uninitialized variable use in gfs2, because the compiler does not figure out that we never use the leaf number if get_leaf_nr() returns an error: 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': fs/gfs2/dir.c:1021:8: warning: 'leaf_no' may be used uninitialized in this function [-Wmaybe-uninitialized] Changing the 'if (!error)' to 'if (!IS_ERR_VALUE(error))' is sufficient to let gcc understand that this is exactly the same condition as in IS_ERR() so it can optimize the code path enough to understand it. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Bob Peterson <rpeterso@redhat.com>
-rw-r--r--fs/gfs2/dir.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c
index 6a92592304fb..d4014af4f064 100644
--- a/fs/gfs2/dir.c
+++ b/fs/gfs2/dir.c
@@ -798,7 +798,7 @@ static int get_first_leaf(struct gfs2_inode *dip, u32 index,
798 int error; 798 int error;
799 799
800 error = get_leaf_nr(dip, index, &leaf_no); 800 error = get_leaf_nr(dip, index, &leaf_no);
801 if (!error) 801 if (!IS_ERR_VALUE(error))
802 error = get_leaf(dip, leaf_no, bh_out); 802 error = get_leaf(dip, leaf_no, bh_out);
803 803
804 return error; 804 return error;
@@ -1014,7 +1014,7 @@ static int dir_split_leaf(struct inode *inode, const struct qstr *name)
1014 1014
1015 index = name->hash >> (32 - dip->i_depth); 1015 index = name->hash >> (32 - dip->i_depth);
1016 error = get_leaf_nr(dip, index, &leaf_no); 1016 error = get_leaf_nr(dip, index, &leaf_no);
1017 if (error) 1017 if (IS_ERR_VALUE(error))
1018 return error; 1018 return error;
1019 1019
1020 /* Get the old leaf block */ 1020 /* Get the old leaf block */