diff mbox series

btrfs-progs: Initialize del_slot to eliminate compilation warnings.

Message ID 20241210152411.183742-1-sunjunchao2870@gmail.com (mailing list archive)
State New
Headers show
Series btrfs-progs: Initialize del_slot to eliminate compilation warnings. | expand

Commit Message

Julian Sun Dec. 10, 2024, 3:24 p.m. UTC
When compiling btrfs-progs with gcc 12.2.0, there is a warning
that a variable may be used uninitialized.

In function ‘reset_balance’,
    inlined from ‘reinit_extent_tree’ at check/main.c:9625:8,
    inlined from ‘cmd_check’ at check/main.c:10712:10:
check/main.c:9444:23: warning: ‘del_slot’ may be used uninitialized [-Wmaybe-uninitialized]
 9444 |                 ret = btrfs_del_items(trans, root, &path, del_slot, del_nr);
      |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
check/main.c: In function ‘cmd_check’:
check/main.c:9375:13: note: ‘del_slot’ was declared here
 9375 |         int del_slot, del_nr = 0;
      |             ^~~~~~~~

Initialize it to 0 to eliminate this warning.

Signed-off-by: Julian Sun <sunjunchao2870@gmail.com>
---
 check/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/check/main.c b/check/main.c
index 6290c6d4..6e58af92 100644
--- a/check/main.c
+++ b/check/main.c
@@ -9372,7 +9372,7 @@  static int reset_balance(struct btrfs_trans_handle *trans)
 	struct btrfs_path path = { 0 };
 	struct extent_buffer *leaf;
 	struct btrfs_key key;
-	int del_slot, del_nr = 0;
+	int del_slot = 0, del_nr = 0;
 	int ret;
 	int found = 0;