From 0557c352fdbb0981be50d82059d1841e10bc55b0 Mon Sep 17 00:00:00 2001
From: Oleksandr Natalenko <oleksandr@natalenko.name>
Date: Tue, 18 Mar 2025 09:47:46 +0100
Subject: [PATCH 3/4] net-tcp_bbr: v3: silence -Wconstant-logical-operand

The `ecn_thresh` and `ecn_factor` params are just consts in a public
version of BBRv3, so evaluating them in conditions as booleans triggers
`-Wconstant-logical-operand` with Clang.

Prepend relevant invocations with double negation to convert values to
booleans explicitly.

The values are always `true`, so these parts of conditions can also be
dropped. Keeping them instead since they are used in an internal version
of BBRv3 to stay as close to the original code as possible.

Link: https://lore.kernel.org/lkml/4616579.LvFx2qVVIh@natalenko.name/T/#u
Link: https://groups.google.com/g/bbr-dev/c/4vwZGw0nxdQ/m/fWt9xmbzAwAJ
Closes: https://codeberg.org/pf-kernel/linux/issues/11
Signed-off-by: Oleksandr Natalenko <oleksandr@natalenko.name>
---
 net/ipv4/tcp_bbr.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--- a/net/ipv4/tcp_bbr.c
+++ b/net/ipv4/tcp_bbr.c
@@ -1077,7 +1077,7 @@ static int bbr_update_ecn_alpha(struct s
 
 	/* See if we should use ECN sender logic for this connection. */
 	if (!bbr->ecn_eligible && bbr_can_use_ecn(sk) &&
-	    bbr_param(sk, ecn_factor) &&
+	    !!bbr_param(sk, ecn_factor) &&
 	    (bbr->min_rtt_us <= bbr_ecn_max_rtt_us ||
 	     !bbr_ecn_max_rtt_us))
 		bbr->ecn_eligible = 1;
@@ -1184,7 +1184,7 @@ static bool bbr_is_inflight_too_high(con
 	}
 
 	if (rs->delivered_ce > 0 && rs->delivered > 0 &&
-	    bbr->ecn_eligible && bbr_param(sk, ecn_thresh)) {
+	    bbr->ecn_eligible && !!bbr_param(sk, ecn_thresh)) {
 		ecn_thresh = (u64)rs->delivered * bbr_param(sk, ecn_thresh) >>
 				BBR_SCALE;
 		if (rs->delivered_ce > ecn_thresh) {
@@ -1382,7 +1382,7 @@ static void bbr_adapt_lower_bounds(struc
 		return;
 
 	/* ECN response. */
-	if (bbr->ecn_in_round && bbr_param(sk, ecn_factor)) {
+	if (bbr->ecn_in_round && !!bbr_param(sk, ecn_factor)) {
 		bbr_init_lower_bounds(sk, false);
 		bbr_ecn_lower_bounds(sk, &ecn_inflight_lo);
 	}
