]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: Zero initialize highstale and lowstale in xfs_dir2_leafn_add
authorNathan Chancellor <natechancellor@gmail.com>
Mon, 6 May 2019 22:00:29 +0000 (18:00 -0400)
committerEric Sandeen <sandeen@redhat.com>
Mon, 6 May 2019 22:00:29 +0000 (18:00 -0400)
Source kernel commit: 7be73fa1c1b0b6aaf15d590320f2c5c1108cb87a

When building with -Wsometimes-uninitialized, Clang warns:

fs/xfs/libxfs/xfs_dir2_node.c:481:6: warning: variable 'lowstale' is
used uninitialized whenever 'if' condition is false
[-Wsometimes-uninitialized]
fs/xfs/libxfs/xfs_dir2_node.c:481:6: warning: variable 'highstale' is
used uninitialized whenever 'if' condition is false
[-Wsometimes-uninitialized]

While it isn't technically wrong, it isn't a problem in practice because
highstale and lowstale are only initialized in xfs_dir2_leafn_add when
compact is not zero then they are passed to xfs_dir3_leaf_find_entry,
where they are initialized before use when compact is zero. Regardless,
it's better not to be passing around uninitialized stack memory so zero
initialize these variables, which silences this warning.

Link: https://github.com/ClangBuiltLinux/linux/issues/393
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/xfs_dir2_node.c

index 9492bfdc83426cd99bcb1b2cdb912796502cd8ee..3d085a4616e591d17420090326b437af8c79d60f 100644 (file)
@@ -441,6 +441,8 @@ xfs_dir2_leafn_add(
 
        dp = args->dp;
        leaf = bp->b_addr;
+       highstale = 0;
+       lowstale = 0;
        dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf);
        ents = dp->d_ops->leaf_ents_p(leaf);