1 From 67893f12e5374bbcaaffbc6e570acbc2714ea884 Mon Sep 17 00:00:00 2001
2 From: Arnd Bergmann <arnd@arndb.de>
3 Date: Tue, 26 Jan 2016 13:08:10 -0500
4 Subject: gfs2: avoid uninitialized variable warning
6 From: Arnd Bergmann <arnd@arndb.de>
8 commit 67893f12e5374bbcaaffbc6e570acbc2714ea884 upstream.
10 We get a bogus warning about a potential uninitialized variable
11 use in gfs2, because the compiler does not figure out that we
12 never use the leaf number if get_leaf_nr() returns an error:
14 fs/gfs2/dir.c: In function 'get_first_leaf':
15 fs/gfs2/dir.c:802:9: warning: 'leaf_no' may be used uninitialized in this function [-Wmaybe-uninitialized]
16 fs/gfs2/dir.c: In function 'dir_split_leaf':
17 fs/gfs2/dir.c:1021:8: warning: 'leaf_no' may be used uninitialized in this function [-Wmaybe-uninitialized]
19 Changing the 'if (!error)' to 'if (!IS_ERR_VALUE(error))' is
20 sufficient to let gcc understand that this is exactly the same
21 condition as in IS_ERR() so it can optimize the code path enough
24 Signed-off-by: Arnd Bergmann <arnd@arndb.de>
25 Signed-off-by: Bob Peterson <rpeterso@redhat.com>
26 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
29 fs/gfs2/dir.c | 4 ++--
30 1 file changed, 2 insertions(+), 2 deletions(-)
34 @@ -764,7 +764,7 @@ static int get_first_leaf(struct gfs2_in
37 error = get_leaf_nr(dip, index, &leaf_no);
39 + if (!IS_ERR_VALUE(error))
40 error = get_leaf(dip, leaf_no, bh_out);
43 @@ -980,7 +980,7 @@ static int dir_split_leaf(struct inode *
45 index = name->hash >> (32 - dip->i_depth);
46 error = get_leaf_nr(dip, index, &leaf_no);
48 + if (IS_ERR_VALUE(error))
51 /* Get the old leaf block */