From ba84a3b17af81e25bb11854052c616f399ba4275 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Thu, 30 Nov 2023 13:02:07 +1100 Subject: [PATCH] treewide: Add messages to static_assert() calls 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 Signed-off-by: Stefano Brivio --- 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