[PATCH net-next] tcp: Use clamp() in htcp_alpha_update()

From: Christophe JAILLET
Date: Sat Jul 27 2024 - 08:32:04 EST


Using clamp instead of min(max()) is easier to read and it matches even
better the comment just above it.

It also reduces the size of the preprocessed files by ~ 36 ko.
(see [1] for a discussion about it)

$ ls -l net/ipv4/tcp_htcp*.i
5871593 27 juil. 10:19 net/ipv4/tcp_htcp.old.i
5835319 27 juil. 10:21 net/ipv4/tcp_htcp.new.i

[1]: https://lore.kernel.org/all/23bdb6fc8d884ceebeb6e8b8653b8cfe@xxxxxxxxxxxxxxxx/

Signed-off-by: Christophe JAILLET <christophe.jaillet@xxxxxxxxxx>
---
net/ipv4/tcp_htcp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv4/tcp_htcp.c b/net/ipv4/tcp_htcp.c
index 52b1f2665dfa..81b96331b2bb 100644
--- a/net/ipv4/tcp_htcp.c
+++ b/net/ipv4/tcp_htcp.c
@@ -185,7 +185,7 @@ static inline void htcp_alpha_update(struct htcp *ca)
u32 scale = (HZ << 3) / (10 * minRTT);

/* clamping ratio to interval [0.5,10]<<3 */
- scale = min(max(scale, 1U << 2), 10U << 3);
+ scale = clamp(scale, 1U << 2, 10U << 3);
factor = (factor << 3) / scale;
if (!factor)
factor = 1;
--
2.45.2