From: Nathan Chancellor <nathan@kernel.org>
To: Palmer Dabbelt <palmer@dabbelt.com>
Cc: edumazet@google.com, davem@davemloft.net, dsahern@kernel.org,
kuba@kernel.org, pabeni@redhat.com, ndesaulniers@google.com,
trix@redhat.com, 0x7f454c46@gmail.com, fruggeri@arista.com,
noureddine@arista.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, llvm@lists.linux.dev,
patches@lists.linux.dev
Subject: Re: [PATCH net] tcp: Fix -Wc23-extensions in tcp_options_write()
Date: Wed, 1 Nov 2023 18:07:23 -0700 [thread overview]
Message-ID: <20231102010723.GA406542@dev-arch.thelio-3990X> (raw)
In-Reply-To: <mhng-df0ad8f4-f79c-427c-9798-8682fca4f516@palmer-ri-x1c9a>
On Wed, Nov 01, 2023 at 05:41:10PM -0700, Palmer Dabbelt wrote:
> On Tue, 31 Oct 2023 13:23:35 PDT (-0700), nathan@kernel.org wrote:
> > Clang warns (or errors with CONFIG_WERROR=y) when CONFIG_TCP_AO is set:
> >
> > net/ipv4/tcp_output.c:663:2: error: label at end of compound statement is a C23 extension [-Werror,-Wc23-extensions]
> > 663 | }
> > | ^
> > 1 error generated.
> >
> > On earlier releases (such as clang-11, the current minimum supported
> > version for building the kernel) that do not support C23, this was a
> > hard error unconditionally:
> >
> > net/ipv4/tcp_output.c:663:2: error: expected statement
> > }
> > ^
> > 1 error generated.
> >
> > Add a semicolon after the label to create an empty statement, which
> > resolves the warning or error for all compilers.
> >
> > Closes: https://github.com/ClangBuiltLinux/linux/issues/1953
> > Fixes: 1e03d32bea8e ("net/tcp: Add TCP-AO sign to outgoing packets")
> > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> > ---
> > net/ipv4/tcp_output.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
> > index f558c054cf6e..6064895daece 100644
> > --- a/net/ipv4/tcp_output.c
> > +++ b/net/ipv4/tcp_output.c
> > @@ -658,7 +658,7 @@ static void tcp_options_write(struct tcphdr *th, struct tcp_sock *tp,
> > memset(ptr, TCPOPT_NOP, sizeof(*ptr));
> > ptr++;
> > }
> > -out_ao:
> > +out_ao:;
> > #endif
> > }
> > if (unlikely(opts->mss)) {
> >
> > ---
> > base-commit: 55c900477f5b3897d9038446f72a281cae0efd86
> > change-id: 20231031-tcp-ao-fix-label-in-compound-statement-warning-ebd6c9978498
> >
> > Best regards,
>
> This gives me a
>
> linux/net/ipv4/tcp_output.c:663:2: error: expected statement
> }
>
> on GCC for me.
What GCC version?
I cannot reproduce that error with my patch applied. I tested mainline
at commit deefd5024f07 ("Merge tag 'vfio-v6.7-rc1' of
https://github.com/awilliam/linux-vfio") using GCC 6 from kernel.org and
I can reproduce a similar failure with ARCH=x86_64 allyesconfig:
net/ipv4/tcp_output.c: In function 'tcp_options_write':
net/ipv4/tcp_output.c:661:1: error: label at end of compound statement
out_ao:
^~~~~~
With this change applied, the error disappears for GCC 6 and GCC 13
continues to build without error. I can try the other supported versions
later, I just did an older and newer one for a quick test.
> So I think something like
>
> diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
> index f558c054cf6e..ca09763acaa8 100644
> --- a/net/ipv4/tcp_output.c
> +++ b/net/ipv4/tcp_output.c
> @@ -659,6 +659,11 @@ static void tcp_options_write(struct tcphdr *th, struct tcp_sock *tp,
> ptr++;
> }
> out_ao:
> + /*
> + * Labels at the end of compound statements are a C23 feature, so
> + * introduce a block to avoid a warning/error on strict toolchains.
> + */
> + {}
> #endif
> }
> if (unlikely(opts->mss)) {
>
> should do it (though it's still build testing...)
I am not opposed to this once we understand what versions are affected
by this so that we have some timeline of removing this workaround.
Cheers,
Nathan
next prev parent reply other threads:[~2023-11-02 1:07 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-31 20:23 Nathan Chancellor
2023-10-31 21:49 ` Nick Desaulniers
2023-11-01 4:49 ` Eric Dumazet
2023-11-02 0:41 ` Palmer Dabbelt
2023-11-02 1:07 ` Nathan Chancellor [this message]
2023-11-02 1:42 ` Palmer Dabbelt
2023-11-02 20:23 ` Palmer Dabbelt
2023-11-03 8:22 ` Christoph Hellwig
2023-11-03 16:53 ` Nathan Chancellor
2023-11-06 7:49 ` Christoph Hellwig
2023-11-03 16:57 ` Nick Desaulniers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231102010723.GA406542@dev-arch.thelio-3990X \
--to=nathan@kernel.org \
--cc=0x7f454c46@gmail.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=fruggeri@arista.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=ndesaulniers@google.com \
--cc=netdev@vger.kernel.org \
--cc=noureddine@arista.com \
--cc=pabeni@redhat.com \
--cc=palmer@dabbelt.com \
--cc=patches@lists.linux.dev \
--cc=trix@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®