Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Arnd Bergmann and committed by
Bob Peterson
67893f12 7508abc4

+2 -2
+2 -2
fs/gfs2/dir.c
··· 798 798 int error; 799 799 800 800 error = get_leaf_nr(dip, index, &leaf_no); 801 - if (!error) 801 + if (!IS_ERR_VALUE(error)) 802 802 error = get_leaf(dip, leaf_no, bh_out); 803 803 804 804 return error; ··· 1014 1014 1015 1015 index = name->hash >> (32 - dip->i_depth); 1016 1016 error = get_leaf_nr(dip, index, &leaf_no); 1017 - if (error) 1017 + if (IS_ERR_VALUE(error)) 1018 1018 return error; 1019 1019 1020 1020 /* Get the old leaf block */