e2806fd624
[FALSE ALERT] With clang 15.0.7, there is a false alert on uninitialized value in ctree.c: kernel-shared/ctree.c:3418:13: warning: variable 'offset' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] } else if (ret < 0) { ^~~~~~~ kernel-shared/ctree.c:3428:41: note: uninitialized use occurs here write_extent_buffer(eb, &subvol_id_le, offset, sizeof(subvol_id_le)); ^~~~~~ kernel-shared/ctree.c:3418:9: note: remove the 'if' if its condition is always true } else if (ret < 0) { ^~~~~~~~~~~~~ kernel-shared/ctree.c:3380:22: note: initialize the variable 'offset' to silence this warning unsigned long offset; ^ = 0 kernel-shared/ctree.c:3418:13: warning: variable 'eb' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] } else if (ret < 0) { ^~~~~~~ kernel-shared/ctree.c:3429:26: note: uninitialized use occurs here btrfs_mark_buffer_dirty(eb); ^~ kernel-shared/ctree.c:3418:9: note: remove the 'if' if its condition is always true } else if (ret < 0) { ^~~~~~~~~~~~~ kernel-shared/ctree.c:3378:26: note: initialize the variable 'eb' to silence this warning struct extent_buffer *eb; ^ = NULL [CAUSE] The original code is handling the return value from btrfs_insert_empty_item() like this: ret = btrfs_insert_empty_item(); if (ret >= 0) { /* Do something for it. */ } else if (ret == -EEXIST) { /* Do something else. */ } else if (ret < 0) { /* Error handling. */ } But the problem is, the last one check is always true if we can reach there. Thus clang is providing the hint to remove the if () check. [FIX] Normally we prefer to do error handling first, so move the error handling first so we don't need the if () else if () chain. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com> |
||
---|---|---|
.. | ||
backref.c | ||
backref.h | ||
compression.h | ||
ctree.c | ||
ctree.h | ||
delayed-ref.c | ||
delayed-ref.h | ||
dir-item.c | ||
disk-io.c | ||
disk-io.h | ||
extent-tree.c | ||
extent_io.c | ||
extent_io.h | ||
file-item.c | ||
file.c | ||
free-space-cache.c | ||
free-space-cache.h | ||
free-space-tree.c | ||
free-space-tree.h | ||
inode-item.c | ||
inode.c | ||
print-tree.c | ||
print-tree.h | ||
root-tree.c | ||
send.h | ||
transaction.c | ||
transaction.h | ||
ulist.c | ||
ulist.h | ||
uuid-tree.c | ||
volumes.c | ||
volumes.h | ||
zoned.c | ||
zoned.h |