Skip to contentSkip to conversation

pktcdvd: Use clamp() instead of min()+max()

PATCH New Andy Shevchenko 1 participant 1 message Jun 20, 2023 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 pktcdvd: Use clamp() instead of min()+max()

In a couple of places replace min()+max() pair by clamp().

---
v2: Switched to clamp() for strict type checking (David)

 drivers/block/pktcdvd.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/block/pktcdvd.c +3 -6
index a1428538bda5..2fe56afc53d4 100644
@@ -208,14 +208,11 @@ static DEVICE_ATTR_RO(size);
 static void init_write_congestion_marks(int* lo, int* hi)
 {
 	if (*hi > 0) {
-		*hi = max(*hi, 500);
-		*hi = min(*hi, 1000000);
+		*hi = clamp(*hi, 500, 1000000);
 		if (*lo <= 0)
 			*lo = *hi - 100;
-		else {
-			*lo = min(*lo, *hi - 100);
-			*lo = max(*lo, 100);
-		}
+		else
+			*lo = clamp(*lo, 100, *hi - 100);
 	} else {
 		*hi = -1;
 		*lo = -1;
Signature · 1 line
2.40.0.1.gaa8946217a0b