2023-01-19 06:17:00

by ye.xingchen

[permalink] [raw]
Subject: [PATCH] btrfs: scrub: Remove compilation errors when -Werror=maybe-uninitialized

From: ye xingchen <[email protected]>

fs/btrfs/scrub.c: In function
'scrub_raid56_data_stripe_for_parity.isa.0':
fs/btrfs/scrub.c:3297:9 error: 'ret' may be used uninitialized in this
function [-Werror=maybe-uninitialized]

fs/btrfs/scrub.c: In function
'scrub_simple_mirror':
fs/btrfs/scrub.c:3530:9 error: 'ret' may be used uninitialized in this
function [-Werror=maybe-uninitialized]

Initialize 'ret' to aviod compilation errors.

Signed-off-by: ye xingchen <[email protected]>
---
fs/btrfs/scrub.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index a5d026041be4..d0ddf930cb79 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -3198,7 +3198,7 @@ static int scrub_raid56_data_stripe_for_parity(struct scrub_ctx *sctx,
struct btrfs_root *extent_root = btrfs_extent_root(fs_info, logical);
struct btrfs_root *csum_root = btrfs_csum_root(fs_info, logical);
u64 cur_logical = logical;
- int ret;
+ int ret = 0;

ASSERT(map->type & BTRFS_BLOCK_GROUP_RAID56_MASK);

@@ -3424,7 +3424,7 @@ static int scrub_simple_mirror(struct scrub_ctx *sctx,
const u32 max_length = SZ_64K;
struct btrfs_path path = { 0 };
u64 cur_logical = logical_start;
- int ret;
+ int ret = 0;

/* The range must be inside the bg */
ASSERT(logical_start >= bg->start && logical_end <= bg->start + bg->length);
--
2.25.1


2023-01-19 11:19:12

by David Sterba

[permalink] [raw]
Subject: Re: [PATCH] btrfs: scrub: Remove compilation errors when -Werror=maybe-uninitialized

On Thu, Jan 19, 2023 at 01:57:13PM +0800, [email protected] wrote:
> From: ye xingchen <[email protected]>
>
> fs/btrfs/scrub.c: In function
> 'scrub_raid56_data_stripe_for_parity.isa.0':
> fs/btrfs/scrub.c:3297:9 error: 'ret' may be used uninitialized in this
> function [-Werror=maybe-uninitialized]
>
> fs/btrfs/scrub.c: In function
> 'scrub_simple_mirror':
> fs/btrfs/scrub.c:3530:9 error: 'ret' may be used uninitialized in this
> function [-Werror=maybe-uninitialized]

What compiler and version do you use?