btrfs: scrub: fix uninitialized return value in recover_scrub_rbio
authorJosef Bacik <josef@toxicpanda.com>
Fri, 16 Dec 2022 16:48:00 +0000 (11:48 -0500)
committerDavid Sterba <dsterba@suse.com>
Tue, 20 Dec 2022 18:43:45 +0000 (19:43 +0100)
Commit 75b470332965 ("btrfs: raid56: migrate recovery and scrub recovery
path to use error_bitmap") introduced an uninitialized return variable.

This can be caught by gcc 12.1 by -Wmaybe-uninitialized:

  CC [M]  fs/btrfs/raid56.o
fs/btrfs/raid56.c: In function ‘scrub_rbio’:
fs/btrfs/raid56.c:2801:15: warning: ‘ret’ may be used uninitialized [-Wmaybe-uninitialized]
 2801 |         ret = recover_scrub_rbio(rbio);
      |               ^~~~~~~~~~~~~~~~~~~~~~~~
fs/btrfs/raid56.c:2649:13: note: ‘ret’ was declared here
 2649 |         int ret;

The warning is disabled by default so we haven't caught that.

Due to the bug the raid56 scrub fstests have been failing since the
patch was merged, so initialize that.

Fixes: 75b470332965 ("btrfs: raid56: migrate recovery and scrub recovery path to use error_bitmap")
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/raid56.c

index 2d90a6b5eb00e319c36aed30d330cae6a622ceb2..6a2cf754912df27a9573aeb5f11e8bc85d217aa0 100644 (file)
@@ -2646,7 +2646,7 @@ static int recover_scrub_rbio(struct btrfs_raid_bio *rbio)
        void **pointers = NULL;
        void **unmap_array = NULL;
        int sector_nr;
-       int ret;
+       int ret = 0;
 
        /*
         * @pointers array stores the pointer for each sector.