* [PATCH] pif: Add message to static_assert for C11 compliance, fix build with gcc 8
@ 2026-07-18 7:41 Stefano Brivio
2026-07-19 4:05 ` David Gibson
0 siblings, 1 reply; 2+ messages in thread
From: Stefano Brivio @ 2026-07-18 7:41 UTC (permalink / raw)
To: passt-dev; +Cc: David Gibson
Seen with gcc 8.5:
---
In file included from passt.h:18,
from qrap.c:36:
pif.h: In function 'pif_type':
pif.h:48:44: error: expected ',' before ')' token
static_assert(sizeof("?") <= PIF_NAME_SIZE);
^
make: *** [Makefile:105: qrap] Error 1
---
As noted in ba84a3b17af8 ("treewide: Add messages to static_assert()
calls"), static_assert() calls need a message to comply with C11. The
form without message is supported starting from C23 only.
Fixes: cbcd4284111f ("pif: Limit pif names to 128 bytes")
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
---
pif.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pif.h b/pif.h
index 3a1e2e5..dedcaa5 100644
--- a/pif.h
+++ b/pif.h
@@ -45,7 +45,7 @@ static inline const char *pif_type(enum pif_type pt)
return pif_type_str[pt];
else
return "?";
- static_assert(sizeof("?") <= PIF_NAME_SIZE);
+ static_assert(sizeof("?") <= PIF_NAME_SIZE, "PIF_NAME_SIZE too small");
}
static inline const char *pif_name(uint8_t pif)
--
2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] pif: Add message to static_assert for C11 compliance, fix build with gcc 8
2026-07-18 7:41 [PATCH] pif: Add message to static_assert for C11 compliance, fix build with gcc 8 Stefano Brivio
@ 2026-07-19 4:05 ` David Gibson
0 siblings, 0 replies; 2+ messages in thread
From: David Gibson @ 2026-07-19 4:05 UTC (permalink / raw)
To: Stefano Brivio; +Cc: passt-dev
[-- Attachment #1: Type: text/plain, Size: 1731 bytes --]
On Sat, Jul 18, 2026 at 09:41:34AM +0200, Stefano Brivio wrote:
> Seen with gcc 8.5:
>
> ---
> In file included from passt.h:18,
> from qrap.c:36:
> pif.h: In function 'pif_type':
> pif.h:48:44: error: expected ',' before ')' token
> static_assert(sizeof("?") <= PIF_NAME_SIZE);
> ^
> make: *** [Makefile:105: qrap] Error 1
> ---
>
> As noted in ba84a3b17af8 ("treewide: Add messages to static_assert()
> calls"), static_assert() calls need a message to comply with C11. The
> form without message is supported starting from C23 only.
>
> Fixes: cbcd4284111f ("pif: Limit pif names to 128 bytes")
> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Huh. Weird I didn't get a warning for this one, I've caught this same
mistake a bunch of times before because of a warning, though I forget
if it came from the compiler or one of the static checkers.
In any case,
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> ---
> pif.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/pif.h b/pif.h
> index 3a1e2e5..dedcaa5 100644
> --- a/pif.h
> +++ b/pif.h
> @@ -45,7 +45,7 @@ static inline const char *pif_type(enum pif_type pt)
> return pif_type_str[pt];
> else
> return "?";
> - static_assert(sizeof("?") <= PIF_NAME_SIZE);
> + static_assert(sizeof("?") <= PIF_NAME_SIZE, "PIF_NAME_SIZE too small");
> }
>
> static inline const char *pif_name(uint8_t pif)
> --
> 2.43.0
>
--
David Gibson (he or they) | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you, not the other way
| around.
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-19 4:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-18 7:41 [PATCH] pif: Add message to static_assert for C11 compliance, fix build with gcc 8 Stefano Brivio
2026-07-19 4:05 ` David Gibson
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).