From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 4677A5A027C for ; Thu, 30 Nov 2023 03:02:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1701309746; bh=ebN3CuStuB7NPQMzydlFMOxUm0kfD+DgMfpKyXf6NL8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L0h5tC7IhEGqCkcHQ4hjOZwlAx3rudLzBQMumJZVaHEz4DjSFXmylYRuRu8HLeanb l/mHNwGeXDwDiZThPnC9XbCO/k05tkGYIW+u0kuJjPzJm0Vg/ISs7q1g/zCPAq2AA0 eVNhVDdBiEGU2xR9UnKVEpeGeh7v9ciMGRpifDRs= Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4Sgfb60Jydz4xVl; Thu, 30 Nov 2023 13:02:26 +1100 (AEDT) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH v3 01/16] treewide: Add messages to static_assert() calls Date: Thu, 30 Nov 2023 13:02:07 +1100 Message-ID: <20231130020222.4056647-2-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231130020222.4056647-1-david@gibson.dropbear.id.au> References: <20231130020222.4056647-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: UWNTCA2PKJ4RQFEDCOM7UJVL4YM3YNZ7 X-Message-ID-Hash: UWNTCA2PKJ4RQFEDCOM7UJVL4YM3YNZ7 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: A while ago, we updated passt to require C11, for several reasons, but one was to be able to use static_assert() for build time checks. The C11 version of static_assert() requires a message to print in case of failure as well as the test condition it self. It was extended in C23 to make the message optional, but we don't want to require C23 at this time. Unfortunately we missed that in some of the static_assert()s we already added which use the C23 form without a message. clang-tidy has a warning for this, but for some reason it's not seeming to trigger in the current cases (but did for some I'm working on adding). Signed-off-by: David Gibson --- inany.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/inany.h b/inany.h index 85a18e3..90e98f1 100644 --- a/inany.h +++ b/inany.h @@ -27,8 +27,10 @@ union inany_addr { } v4mapped; uint32_t u32[4]; }; -static_assert(sizeof(union inany_addr) == sizeof(struct in6_addr)); -static_assert(_Alignof(union inany_addr) == _Alignof(uint32_t)); +static_assert(sizeof(union inany_addr) == sizeof(struct in6_addr), + "union inany_addr is larger than an IPv6 address"); +static_assert(_Alignof(union inany_addr) == _Alignof(uint32_t), + "union inany_addr has unexpected alignment"); /** inany_v4 - Extract IPv4 address, if present, from IPv[46] address * @addr: IPv4 or IPv6 address -- 2.43.0