Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dccp: ccid2.c, ccid3.c use clamp(), clamp_t()

Makes the intention of the nested min/max clear.

Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Harvey Harrison and committed by
David S. Miller
84994e16 0c0b0aca

+3 -3
+1 -1
net/dccp/ccids/ccid2.c
··· 716 716 * packets for new connections, following the rules from [RFC3390]". 717 717 * We need to convert the bytes of RFC3390 into the packets of RFC 4341. 718 718 */ 719 - hctx->ccid2hctx_cwnd = min(4U, max(2U, 4380U / dp->dccps_mss_cache)); 719 + hctx->ccid2hctx_cwnd = clamp(4380U / dp->dccps_mss_cache, 2U, 4U); 720 720 721 721 /* Make sure that Ack Ratio is enabled and within bounds. */ 722 722 max_ratio = DIV_ROUND_UP(hctx->ccid2hctx_cwnd, 2);
+2 -2
net/dccp/ccids/ccid3.c
··· 88 88 static inline u64 rfc3390_initial_rate(struct sock *sk) 89 89 { 90 90 const struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); 91 - const __u32 w_init = min_t(__u32, 4 * hctx->ccid3hctx_s, 92 - max_t(__u32, 2 * hctx->ccid3hctx_s, 4380)); 91 + const __u32 w_init = clamp_t(__u32, 4380U, 92 + 2 * hctx->ccid3hctx_s, 4 * hctx->ccid3hctx_s); 93 93 94 94 return scaled_div(w_init << 6, hctx->ccid3hctx_rtt); 95 95 }