diff mbox series

[5/8] btrfs: fix uninit warning in __set_extent_bit and convert_extent_bit

Message ID 02a60dacc01beb1ab14845f2b579e4b6f56c6359.1671221596.git.josef@toxicpanda.com (mailing list archive)
State New, archived
Headers show
Series Fixup uninitialized warnings and enable extra checks | expand

Commit Message

Josef Bacik Dec. 16, 2022, 8:15 p.m. UTC
We will pass in the parent and p pointer into our tree_search function
to avoid doing a second search when inserting a new extent state into
the tree.  However because this is conditional upon passing in these
pointers the compiler seems to think these values can be uninitialized
if we're using -Wmaybe-uninitialized.  Fix this by initializing these
values.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 fs/btrfs/extent-io-tree.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Qu Wenruo Dec. 17, 2022, 12:17 a.m. UTC | #1
On 2022/12/17 04:15, Josef Bacik wrote:
> We will pass in the parent and p pointer into our tree_search function
> to avoid doing a second search when inserting a new extent state into
> the tree.  However because this is conditional upon passing in these
> pointers the compiler seems to think these values can be uninitialized
> if we're using -Wmaybe-uninitialized.  Fix this by initializing these
> values.
> 
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu
> ---
>   fs/btrfs/extent-io-tree.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/btrfs/extent-io-tree.c b/fs/btrfs/extent-io-tree.c
> index 9ae9cd1e7035..9e1f18706a02 100644
> --- a/fs/btrfs/extent-io-tree.c
> +++ b/fs/btrfs/extent-io-tree.c
> @@ -972,8 +972,8 @@ static int __set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
>   {
>   	struct extent_state *state;
>   	struct extent_state *prealloc = NULL;
> -	struct rb_node **p;
> -	struct rb_node *parent;
> +	struct rb_node **p = NULL;
> +	struct rb_node *parent = NULL;
>   	int err = 0;
>   	u64 last_start;
>   	u64 last_end;
> @@ -1218,8 +1218,8 @@ int convert_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
>   {
>   	struct extent_state *state;
>   	struct extent_state *prealloc = NULL;
> -	struct rb_node **p;
> -	struct rb_node *parent;
> +	struct rb_node **p = NULL;
> +	struct rb_node *parent = NULL;
>   	int err = 0;
>   	u64 last_start;
>   	u64 last_end;
diff mbox series

Patch

diff --git a/fs/btrfs/extent-io-tree.c b/fs/btrfs/extent-io-tree.c
index 9ae9cd1e7035..9e1f18706a02 100644
--- a/fs/btrfs/extent-io-tree.c
+++ b/fs/btrfs/extent-io-tree.c
@@ -972,8 +972,8 @@  static int __set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
 {
 	struct extent_state *state;
 	struct extent_state *prealloc = NULL;
-	struct rb_node **p;
-	struct rb_node *parent;
+	struct rb_node **p = NULL;
+	struct rb_node *parent = NULL;
 	int err = 0;
 	u64 last_start;
 	u64 last_end;
@@ -1218,8 +1218,8 @@  int convert_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
 {
 	struct extent_state *state;
 	struct extent_state *prealloc = NULL;
-	struct rb_node **p;
-	struct rb_node *parent;
+	struct rb_node **p = NULL;
+	struct rb_node *parent = NULL;
 	int err = 0;
 	u64 last_start;
 	u64 last_end;