From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 66CE55A027D for ; Tue, 20 Feb 2024 03:48:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1708397306; bh=Oz9iPaTvzmiv5HcggiD/P1HrLvkXUN1iWsEkv87QKJE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JCR0QZ2wZ0d2RS22d3rE6t9wSB/fuNPJadNVthrtc7rKv9vz4bA0TPZmvSgb0s7Bi OdtUNC8If4gY6SRNeoQisrdD8hPOpSjx4RK/7mZvAMtCfvtqVe7Qp+DYQNl6EkeEQe KX1qkckx73/CkStsRT2ofOD2tal38gX8QrMEL2sYRpNbpJuOpQVTK7IwvlpkSrRMVg fJ4M14JWK61pNxFYcePHxB55MLb0QnJS3Jy+qK2sVW1Ugaec4m2NlNduoDx3wq3HrB RhlNgvoVOshR7fyCZCJTE5P9OMtwBHtLT0PQ3+2ju1wgjgL5tR+W0HAkZKmwqBat8a 6Ufwlclu6v/9A== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4Tf3kL1wVgz4wcQ; Tue, 20 Feb 2024 13:48:26 +1100 (AEDT) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH 1/2] udp: Assertion in udp_invert_portmap() can be calculated at compile time Date: Tue, 20 Feb 2024 13:48:23 +1100 Message-ID: <20240220024824.2198704-2-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240220024824.2198704-1-david@gibson.dropbear.id.au> References: <20240220024824.2198704-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: MFO36LZSKTAWKOIJBQDZF2VACPQAOGH2 X-Message-ID-Hash: MFO36LZSKTAWKOIJBQDZF2VACPQAOGH2 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: jk@lutty.net, 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: All the values in this ASSERT() are known at compile time, so this can be converted to a static_assert(). Signed-off-by: David Gibson --- udp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/udp.c b/udp.c index 933f24b8..c031a053 100644 --- a/udp.c +++ b/udp.c @@ -260,7 +260,8 @@ static void udp_invert_portmap(struct udp_port_fwd *fwd) { int i; - ASSERT(ARRAY_SIZE(fwd->f.delta) == ARRAY_SIZE(fwd->rdelta)); + static_assert(ARRAY_SIZE(fwd->f.delta) == ARRAY_SIZE(fwd->rdelta), + "Forward and reverse delta arrays must have same size"); for (i = 0; i < ARRAY_SIZE(fwd->f.delta); i++) { in_port_t delta = fwd->f.delta[i]; -- 2.43.2