diff options
author | Naohiro Aota <Naohiro.Aota@wdc.com> | 2022-12-21 16:47:45 +0000 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2023-02-13 17:50:33 +0100 |
commit | cd30d3bc78d9acbd505d0d6a4cff3b87e40a8187 (patch) | |
tree | 04abcf50b4cce038973538dbd5085c513fb0b978 /fs | |
parent | 12adffe6cfb8e279e8ab49504501d894ff79822a (diff) |
btrfs: zoned: fix uninitialized variable warning in btrfs_get_dev_zones
Fix an uninitialized warning we get with -Wmaybe-uninitialized where it
thought zno may have been uninitialized, in both cases it depends on
zinfo->zone_cache but we know the value won't change between checks.
Reported-by: Josef Bacik <josef@toxicpanda.com>
Link: https://lore.kernel.org/linux-btrfs/af6c527cbd8bdc782e50bd33996ee83acc3a16fb.1671221596.git.josef@toxicpanda.com/
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/zoned.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c index 379d678e3894..d46701a77b17 100644 --- a/fs/btrfs/zoned.c +++ b/fs/btrfs/zoned.c @@ -220,7 +220,6 @@ static int btrfs_get_dev_zones(struct btrfs_device *device, u64 pos, struct blk_zone *zones, unsigned int *nr_zones) { struct btrfs_zoned_device_info *zinfo = device->zone_info; - u32 zno; int ret; if (!*nr_zones) @@ -235,6 +234,7 @@ static int btrfs_get_dev_zones(struct btrfs_device *device, u64 pos, /* Check cache */ if (zinfo->zone_cache) { unsigned int i; + u32 zno; ASSERT(IS_ALIGNED(pos, zinfo->zone_size)); zno = pos >> zinfo->zone_size_shift; @@ -274,9 +274,12 @@ static int btrfs_get_dev_zones(struct btrfs_device *device, u64 pos, return -EIO; /* Populate cache */ - if (zinfo->zone_cache) + if (zinfo->zone_cache) { + u32 zno = pos >> zinfo->zone_size_shift; + memcpy(zinfo->zone_cache + zno, zones, sizeof(*zinfo->zone_cache) * *nr_zones); + } return 0; } |