[PATCH 36/44] lib/bucket_locks: use min() instead of min_t()

david.laight.linux@gmail.com posted 44 patches 1 week, 5 days ago
There is a newer version of this series
[PATCH 36/44] lib/bucket_locks: use min() instead of min_t()
Posted by david.laight.linux@gmail.com 1 week, 5 days ago
From: David Laight <david.laight.linux@gmail.com>

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.

Detected by an extra check added to min_t().

Signed-off-by: David Laight <david.laight.linux@gmail.com>
---
 lib/bucket_locks.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/bucket_locks.c b/lib/bucket_locks.c
index 64b92e1dbace..6bad65501f2d 100644
--- a/lib/bucket_locks.c
+++ b/lib/bucket_locks.c
@@ -25,7 +25,7 @@ int __alloc_bucket_spinlocks(spinlock_t **locks, unsigned int *locks_mask,
 
 	if (cpu_mult) {
 		nr_pcpus = min_t(unsigned int, nr_pcpus, 64UL);
-		size = min_t(unsigned int, nr_pcpus * cpu_mult, max_size);
+		size = min(nr_pcpus * cpu_mult, max_size);
 	} else {
 		size = max_size;
 	}
-- 
2.39.5