]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
block: use min() instead of min_t()
authorDavid Laight <david.laight.linux@gmail.com>
Wed, 19 Nov 2025 22:41:08 +0000 (22:41 +0000)
committerJens Axboe <axboe@kernel.dk>
Thu, 20 Nov 2025 14:44:29 +0000 (07:44 -0700)
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>
block/blk-iocost.c
block/partitions/efi.c

index 5bfd70311359cd3ff41794ced411aee246b3f935..a0416927d33dcaa31062b246e596af7746cb74c4 100644 (file)
@@ -2334,10 +2334,8 @@ static void ioc_timer_fn(struct timer_list *timer)
                        else
                                usage_dur = max_t(u64, now.now - ioc->period_at, 1);
 
-                       usage = clamp_t(u32,
-                               DIV64_U64_ROUND_UP(usage_us * WEIGHT_ONE,
-                                                  usage_dur),
-                               1, WEIGHT_ONE);
+                       usage = clamp(DIV64_U64_ROUND_UP(usage_us * WEIGHT_ONE, usage_dur),
+                                     1, WEIGHT_ONE);
 
                        /*
                         * Already donating or accumulated enough to start.
index 7acba66eed481c77fe45f901632fac7211acdcad..638261e9f2fbe774d777fe2ab51dd20e79cd7e28 100644 (file)
@@ -215,8 +215,7 @@ check_hybrid:
                sz = le32_to_cpu(mbr->partition_record[part].size_in_lba);
                if (sz != (uint32_t) total_sectors - 1 && sz != 0xFFFFFFFF)
                        pr_debug("GPT: mbr size in lba (%u) different than whole disk (%u).\n",
-                                sz, min_t(uint32_t,
-                                          total_sectors - 1, 0xFFFFFFFF));
+                                sz, (uint32_t)min(total_sectors - 1, 0xFFFFFFFF));
        }
 done:
        return ret;