Skip to content

Commit 7be73fa

Browse files
nathanchancedjwong
authored andcommitted
xfs: Zero initialize highstale and lowstale in xfs_dir2_leafn_add
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: ClangBuiltLinux#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>
1 parent 1b9598c commit 7be73fa

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

fs/xfs/libxfs/xfs_dir2_node.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,8 @@ xfs_dir2_leafn_add(
444444

445445
dp = args->dp;
446446
leaf = bp->b_addr;
447+
highstale = 0;
448+
lowstale = 0;
447449
dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf);
448450
ents = dp->d_ops->leaf_ents_p(leaf);
449451

0 commit comments

Comments
 (0)