From c48331ca51399fe1779529511be395b576aaf0af Mon Sep 17 00:00:00 2001 From: David Gibson Date: Mon, 17 Mar 2025 20:24:18 +1100 Subject: packet: Correct type of PACKET_MAX_LEN PACKET_MAX_LEN is usually involved in calculations on size_t values - the type of the iov_len field in struct iovec. However, being defined bare as UINT16_MAX, the compiled is likely to assign it a shorter type. This can lead to unexpected promotions (or lack thereof). Add a cast to force the type to be what we expect. Fixes: c43972ad6 ("packet: Give explicit name to maximum packet size") Signed-off-by: David Gibson Signed-off-by: Stefano Brivio --- packet.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packet.h b/packet.h index dd18461..9061dad 100644 --- a/packet.h +++ b/packet.h @@ -9,7 +9,7 @@ #include /* Maximum size of a single packet stored in pool, including headers */ -#define PACKET_MAX_LEN UINT16_MAX +#define PACKET_MAX_LEN ((size_t)UINT16_MAX) /** * struct pool - Generic pool of packets stored in a buffer -- cgit v1.2.3