Skip to content

Commit ae7e864

Browse files
asjkdave
authored andcommitted
btrfs-progs: fix may be used uninitialized in __set_extent_bit
Compiler is throwing out this false positive warning in the following function flow. Apparently, %parent and %p are initialized in tree_search_for_insert(). __set_extent_bit() state = tree_search_for_insert(tree, start, &p, &parent); insert_state_fast(tree, prealloc, p, parent, bits, changeset); rb_link_node(&state->rb_node, parent, node); Compile warnings: In file included from ./common/extent-cache.h:23, from kernel-shared/ctree.h:26, from kernel-shared/extent-io-tree.c:4: kernel-shared/extent-io-tree.c: In function ‘__set_extent_bit’: ./kernel-lib/rbtree.h:80:28: warning: ‘parent’ may be used uninitialized in this function [-Wmaybe-uninitialized] node->__rb_parent_color = (unsigned long)parent; ^~~~~~~~~~~~~~~~~~~~~ kernel-shared/extent-io-tree.c:996:18: note: ‘parent’ was declared here struct rb_node *parent; ^~~~~~ In file included from ./common/extent-cache.h:23, from kernel-shared/ctree.h:26, from kernel-shared/extent-io-tree.c:4: ./kernel-lib/rbtree.h:83:11: warning: ‘p’ may be used uninitialized in this function [-Wmaybe-uninitialized] *rb_link = node; ~~~~~~~~~^~~~~~ kernel-shared/extent-io-tree.c:995:19: note: ‘p’ was declared here struct rb_node **p; Fix: Initialize to NULL, as in the kernel. Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 16f9a8f commit ae7e864

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel-shared/extent-io-tree.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -993,8 +993,8 @@ static int __set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
993993
{
994994
struct extent_state *state;
995995
struct extent_state *prealloc = NULL;
996-
struct rb_node **p;
997-
struct rb_node *parent;
996+
struct rb_node **p = NULL;
997+
struct rb_node *parent = NULL;
998998
int err = 0;
999999
u64 last_start;
10001000
u64 last_end;

0 commit comments

Comments
 (0)