* Re: [PATCH] ip: Wrap CASE macro body in braces for pre-C23 compatibility
2026-05-18 13:58 [PATCH] ip: Wrap CASE macro body in braces for pre-C23 compatibility Anshu Kumari
@ 2026-05-19 1:57 ` David Gibson
2026-05-19 7:06 ` Laurent Vivier
2026-05-20 0:37 ` Stefano Brivio
2 siblings, 0 replies; 5+ messages in thread
From: David Gibson @ 2026-05-19 1:57 UTC (permalink / raw)
To: Anshu Kumari; +Cc: passt-dev, sbrivio, jmaloy, lvivier, Jeskynar
[-- Attachment #1: Type: text/plain, Size: 1338 bytes --]
On Mon, May 18, 2026 at 07:28:06PM +0530, Anshu Kumari wrote:
> From: Jeskynar <jeskynar@gmail.com>
>
> Compiling on RHEL8 (gcc-8.5) gives an error in ip.c.
> ip.c:88:3: error: a label can only be part of a statement and
> a declaration is not a statement due to the use of static_assert.
>
> The fix is to surround it with {}.
>
> Link: https://bugs.passt.top/show_bug.cgi?id=201
> Signed-off-by: Anshu Kumari <anskuma@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> ---
> ip.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/ip.c b/ip.c
> index f2506bb..7b674e0 100644
> --- a/ip.c
> +++ b/ip.c
> @@ -35,9 +35,9 @@ const char *ipproto_name(uint8_t proto)
> {
> switch (proto) {
> #define CASE(s) \
> - static_assert(sizeof(s) <= IPPROTO_STRLEN, \
> - "Increase IPPROTO_STRLEN to contain " #s); \
> - return s;
> + {static_assert(sizeof(s) <= IPPROTO_STRLEN, \
> + "Increase IPPROTO_STRLEN to contain " #s); \
> + return s;}
> case IPPROTO_ICMP:
> CASE("ICMP");
> case IPPROTO_TCP:
> --
> 2.54.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] 5+ messages in thread* Re: [PATCH] ip: Wrap CASE macro body in braces for pre-C23 compatibility
2026-05-18 13:58 [PATCH] ip: Wrap CASE macro body in braces for pre-C23 compatibility Anshu Kumari
2026-05-19 1:57 ` David Gibson
@ 2026-05-19 7:06 ` Laurent Vivier
2026-05-20 0:37 ` Stefano Brivio
2 siblings, 0 replies; 5+ messages in thread
From: Laurent Vivier @ 2026-05-19 7:06 UTC (permalink / raw)
To: Anshu Kumari, passt-dev, sbrivio; +Cc: david, jmaloy, Jeskynar
On 5/18/26 15:58, Anshu Kumari wrote:
> From: Jeskynar <jeskynar@gmail.com>
>
> Compiling on RHEL8 (gcc-8.5) gives an error in ip.c.
> ip.c:88:3: error: a label can only be part of a statement and
> a declaration is not a statement due to the use of static_assert.
>
> The fix is to surround it with {}.
>
> Link: https://bugs.passt.top/show_bug.cgi?id=201
> Signed-off-by: Anshu Kumari <anskuma@redhat.com>
Fixes: 93c3e351f235 ("ip: Define a bound for the string returned by ipproto_name()")
Reviewed-by: Laurent Vivier <lvivier@redhat.com>
> ---
> ip.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/ip.c b/ip.c
> index f2506bb..7b674e0 100644
> --- a/ip.c
> +++ b/ip.c
> @@ -35,9 +35,9 @@ const char *ipproto_name(uint8_t proto)
> {
> switch (proto) {
> #define CASE(s) \
> - static_assert(sizeof(s) <= IPPROTO_STRLEN, \
> - "Increase IPPROTO_STRLEN to contain " #s); \
> - return s;
> + {static_assert(sizeof(s) <= IPPROTO_STRLEN, \
> + "Increase IPPROTO_STRLEN to contain " #s); \
> + return s;}
> case IPPROTO_ICMP:
> CASE("ICMP");
> case IPPROTO_TCP:
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] ip: Wrap CASE macro body in braces for pre-C23 compatibility
2026-05-18 13:58 [PATCH] ip: Wrap CASE macro body in braces for pre-C23 compatibility Anshu Kumari
2026-05-19 1:57 ` David Gibson
2026-05-19 7:06 ` Laurent Vivier
@ 2026-05-20 0:37 ` Stefano Brivio
2026-05-26 12:45 ` Stefano Brivio
2 siblings, 1 reply; 5+ messages in thread
From: Stefano Brivio @ 2026-05-20 0:37 UTC (permalink / raw)
To: Anshu Kumari; +Cc: passt-dev, david, jmaloy, lvivier, Jeskynar
On Mon, 18 May 2026 19:28:06 +0530
Anshu Kumari <anskuma@redhat.com> wrote:
> From: Jeskynar <jeskynar@gmail.com>
>
> Compiling on RHEL8 (gcc-8.5) gives an error in ip.c.
> ip.c:88:3: error: a label can only be part of a statement and
> a declaration is not a statement due to the use of static_assert.
>
> The fix is to surround it with {}.
>
> Link: https://bugs.passt.top/show_bug.cgi?id=201
> Signed-off-by: Anshu Kumari <anskuma@redhat.com>
> ---
> ip.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/ip.c b/ip.c
> index f2506bb..7b674e0 100644
> --- a/ip.c
> +++ b/ip.c
> @@ -35,9 +35,9 @@ const char *ipproto_name(uint8_t proto)
> {
> switch (proto) {
> #define CASE(s) \
> - static_assert(sizeof(s) <= IPPROTO_STRLEN, \
> - "Increase IPPROTO_STRLEN to contain " #s); \
> - return s;
> + {static_assert(sizeof(s) <= IPPROTO_STRLEN, \
> + "Increase IPPROTO_STRLEN to contain " #s); \
> + return s;}
One minor detail, which I would usually fix up on merge, but in this
case it's half of the patch...: our coding style always has code blocks
separated by newlines and indented, that is, in this case:
{
static_assert(sizeof(s) <= IPPROTO_STRLEN, \
"Increase IPPROTO_STRLEN to contain " \
#s); \
return s;
}
and in these cases I would suggest to add (perhaps I mentioned it
already?) something like "Based on a patch from ..." blah. Then before
your Signed-off-by you can describe shortly what you changed in square
brackets.
Just grep for "Based on" in the git log, you'll find plenty of (rather
consistent) examples.
--
Stefano
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] ip: Wrap CASE macro body in braces for pre-C23 compatibility
2026-05-20 0:37 ` Stefano Brivio
@ 2026-05-26 12:45 ` Stefano Brivio
0 siblings, 0 replies; 5+ messages in thread
From: Stefano Brivio @ 2026-05-26 12:45 UTC (permalink / raw)
To: Anshu Kumari; +Cc: passt-dev, david, jmaloy, lvivier, Jeskynar
On Wed, 20 May 2026 02:37:47 +0200
Stefano Brivio <sbrivio@redhat.com> wrote:
> On Mon, 18 May 2026 19:28:06 +0530
> Anshu Kumari <anskuma@redhat.com> wrote:
>
> > From: Jeskynar <jeskynar@gmail.com>
> >
> > Compiling on RHEL8 (gcc-8.5) gives an error in ip.c.
> > ip.c:88:3: error: a label can only be part of a statement and
> > a declaration is not a statement due to the use of static_assert.
> >
> > The fix is to surround it with {}.
> >
> > Link: https://bugs.passt.top/show_bug.cgi?id=201
> > Signed-off-by: Anshu Kumari <anskuma@redhat.com>
> > ---
> > ip.c | 6 +++---
> > 1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/ip.c b/ip.c
> > index f2506bb..7b674e0 100644
> > --- a/ip.c
> > +++ b/ip.c
> > @@ -35,9 +35,9 @@ const char *ipproto_name(uint8_t proto)
> > {
> > switch (proto) {
> > #define CASE(s) \
> > - static_assert(sizeof(s) <= IPPROTO_STRLEN, \
> > - "Increase IPPROTO_STRLEN to contain " #s); \
> > - return s;
> > + {static_assert(sizeof(s) <= IPPROTO_STRLEN, \
> > + "Increase IPPROTO_STRLEN to contain " #s); \
> > + return s;}
>
> One minor detail, which I would usually fix up on merge, but in this
> case it's half of the patch...: our coding style always has code blocks
> separated by newlines and indented, that is, in this case:
>
> {
> static_assert(sizeof(s) <= IPPROTO_STRLEN, \
> "Increase IPPROTO_STRLEN to contain " \
> #s); \
> return s;
> }
>
> and in these cases I would suggest to add (perhaps I mentioned it
> already?) something like "Based on a patch from ..." blah. Then before
> your Signed-off-by you can describe shortly what you changed in square
> brackets.
>
> Just grep for "Based on" in the git log, you'll find plenty of (rather
> consistent) examples.
I went ahead and fixed the coding style myself while applying this.
As we just fixed all known regressions from 2026_05_07.1afd4ed, I'm
about to tag a release now, and it would be nice to have this fix in.
--
Stefano
^ permalink raw reply [flat|nested] 5+ messages in thread