[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20251119224140.8616-41-david.laight.linux@gmail.com>
Date: Wed, 19 Nov 2025 22:41:36 +0000
From: david.laight.linux@...il.com
To: linux-kernel@...r.kernel.org,
netdev@...r.kernel.org
Cc: "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
David Laight <david.laight.linux@...il.com>
Subject: [PATCH 40/44] net: Don't pass bitfields to max_t()
From: David Laight <david.laight.linux@...il.com>
It is invalid to use sizeof() or typeof() in bitfields which stops
them being passed to max().
This has been fixed by using max_t().
I want to add some checks to max_t() to detect cases where the cast
discards non-zero high bits - which uses sizeof().
So add 0 to the bitfield (converting it to int) then use max().
Signed-off-by: David Laight <david.laight.linux@...il.com>
---
include/net/tcp_ecn.h | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/include/net/tcp_ecn.h b/include/net/tcp_ecn.h
index f13e5cd2b1ac..14c00404a95f 100644
--- a/include/net/tcp_ecn.h
+++ b/include/net/tcp_ecn.h
@@ -196,7 +196,7 @@ static inline void tcp_accecn_opt_demand_min(struct sock *sk,
struct tcp_sock *tp = tcp_sk(sk);
u8 opt_demand;
- opt_demand = max_t(u8, opt_demand_min, tp->accecn_opt_demand);
+ opt_demand = max(opt_demand_min, tp->accecn_opt_demand + 0);
tp->accecn_opt_demand = opt_demand;
}
@@ -303,8 +303,7 @@ static inline void tcp_ecn_received_counters(struct sock *sk,
u32 bytes_mask = GENMASK_U32(31, 22);
tp->received_ecn_bytes[ecnfield - 1] += len;
- tp->accecn_minlen = max_t(u8, tp->accecn_minlen,
- minlen);
+ tp->accecn_minlen = max(tp->accecn_minlen + 0, minlen);
/* Send AccECN option at least once per 2^22-byte
* increase in any ECN byte counter.
--
2.39.5
Powered by blists - more mailing lists