[PATCH] dm zoned: tidy up the variables in dmz_lookup_secondary_sb()

From: Yingjie Wang

Date: Wed Dec 02 2026 - 11:31:55 EST


Declare i together with nr_zones, and set nr_zones with an if statement
after the declarations instead of a conditional expression in its
initializer.

No functional change.

Suggested-by: Damien Le Moal <dlemoal@xxxxxxxxxx>
Link: https://lore.kernel.org/dm-devel/17f0e9c6-856b-4814-81c0-388743e0fd58@xxxxxxxxxx/
Signed-off-by: Yingjie Wang <x-professor@xxxxxxxxxxx>
---
Damien's review of 3/3 came after the series was applied to for-next,
so this goes on top of commit 2ee78e96ca18 ("dm zoned: fix the search
for the secondary superblock"). Feel free to fold it into that commit
instead.

drivers/md/dm-zoned-metadata.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/md/dm-zoned-metadata.c b/drivers/md/dm-zoned-metadata.c
index 687573bbc091..1eae19264981 100644
--- a/drivers/md/dm-zoned-metadata.c
+++ b/drivers/md/dm-zoned-metadata.c
@@ -1125,11 +1125,14 @@ static int dmz_read_sb(struct dmz_metadata *zmd, struct dmz_sb *sb, int set)
*/
static int dmz_lookup_secondary_sb(struct dmz_metadata *zmd)
{
- unsigned int nr_zones = zmd->nr_devs > 1 ? zmd->nr_cache_zones :
- zmd->nr_rnd_zones;
+ unsigned int nr_zones, i;
struct dmz_mblock *mblk;
unsigned int zone_id = zmd->sb[0].zone->id;
- unsigned int i;
+
+ if (zmd->nr_devs > 1)
+ nr_zones = zmd->nr_cache_zones;
+ else
+ nr_zones = zmd->nr_rnd_zones;

/* Allocate a block */
mblk = dmz_alloc_mblock(zmd, 0);

base-commit: 2ee78e96ca1894cbfe00eff1e4ff24a93215337f
--
2.43.0