Skip to content

Commit 9420e72

Browse files
David Laightaxboe
authored andcommitted
block: use min() instead of min_t()
min_t(unsigned int, a, b) casts an 'unsigned long' to 'unsigned int'. Use min(a, b) instead as it promotes any 'unsigned int' to 'unsigned long' and so cannot discard significant bits. In this case the 'unsigned long' value is small enough that the result is ok. (Similarly for max_t() and clamp_t().) Detected by an extra check added to min_t(). Signed-off-by: David Laight <david.laight.linux@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent e8f0abd commit 9420e72

2 files changed

Lines changed: 3 additions & 6 deletions

File tree

block/blk-iocost.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2334,10 +2334,8 @@ static void ioc_timer_fn(struct timer_list *timer)
23342334
else
23352335
usage_dur = max_t(u64, now.now - ioc->period_at, 1);
23362336

2337-
usage = clamp_t(u32,
2338-
DIV64_U64_ROUND_UP(usage_us * WEIGHT_ONE,
2339-
usage_dur),
2340-
1, WEIGHT_ONE);
2337+
usage = clamp(DIV64_U64_ROUND_UP(usage_us * WEIGHT_ONE, usage_dur),
2338+
1, WEIGHT_ONE);
23412339

23422340
/*
23432341
* Already donating or accumulated enough to start.

block/partitions/efi.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,7 @@ static int is_pmbr_valid(legacy_mbr *mbr, sector_t total_sectors)
215215
sz = le32_to_cpu(mbr->partition_record[part].size_in_lba);
216216
if (sz != (uint32_t) total_sectors - 1 && sz != 0xFFFFFFFF)
217217
pr_debug("GPT: mbr size in lba (%u) different than whole disk (%u).\n",
218-
sz, min_t(uint32_t,
219-
total_sectors - 1, 0xFFFFFFFF));
218+
sz, (uint32_t)min(total_sectors - 1, 0xFFFFFFFF));
220219
}
221220
done:
222221
return ret;

0 commit comments

Comments
 (0)