From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202502 header.b=fBK4K/9b; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 664865A077E for ; Mon, 17 Mar 2025 11:02:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202502; t=1742205731; bh=6UoixGgACzrtoDwGwrF1B0VhZatdEw29yzsHky5J/wo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fBK4K/9bLvq5foPFlK9EzTf0loRfA3QfO4glHkCZzTEXQ8kbgFJWhVZAhUohy31W7 cvrnpwqP2IGdCcHzpuIG2q9HyE16qKBCbi31oTTz/2Mt8AA699mZDG5wHNZ2IrQfgH YC1w0LA4aOnr12brsH0r8PUEy25N+k/cRf7iDOXHj0Opdv9oQWKWZv6i0Hb/EBSHlP hKqXCf4IDl/DgYqWP20o9uQqmmyxTuhTOaQg0U3MWK3Yd22pm/6dSP/40bNBWXq/Im GlImCRLkyS4O0+cJU+g3plIQF3Ic/+kiWFbOuxInW489TAXucMoSH26MO8Pww/zyQz SVlXvp8a66l+A== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4ZGVrM69mfz4x9D; Mon, 17 Mar 2025 21:02:11 +1100 (AEDT) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH v2 05/11] packet: Correct type of PACKET_MAX_LEN Date: Mon, 17 Mar 2025 20:24:18 +1100 Message-ID: <20250317092424.1461719-6-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250317092424.1461719-1-david@gibson.dropbear.id.au> References: <20250317092424.1461719-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: 2GOPJWDX2KWWNEADWB2KWG7YFGAYRV7C X-Message-ID-Hash: 2GOPJWDX2KWWNEADWB2KWG7YFGAYRV7C X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 --- packet.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packet.h b/packet.h index dd18461b..9061dad7 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 -- 2.48.1