From: Sedat Dilek <sedat.dilek@gmail.com>
To: Arnd Bergmann <arnd@kernel.org>
Cc: Masahiro Yamada <masahiroy@kernel.org>,
Arnd Bergmann <arnd@arndb.de>,
Linus Torvalds <torvalds@linux-foundation.org>,
Marco Elver <elver@google.com>,
Jani Nikula <jani.nikula@intel.com>,
David Sterba <dsterba@suse.com>, Alex Shi <alexs@kernel.org>,
Nick Desaulniers <ndesaulniers@google.com>,
Miguel Ojeda <ojeda@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
linux-kbuild@vger.kernel.org, llvm@lists.linux.dev,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] treewide: use -Wdeclaration-after-statement
Date: Sun, 6 Mar 2022 11:03:10 +0100 [thread overview]
Message-ID: <CA+icZUVkpvQuRHqeRtQbrVHU7mb0rK7-TTFMHEgZ8k=_keMTSA@mail.gmail.com> (raw)
In-Reply-To: <CA+icZUVcNppitX53A-f9EAh-Lp6aQq1Qn7Ns1J=tDfQAf_K9vQ@mail.gmail.com>
On Fri, Mar 4, 2022 at 12:29 PM Sedat Dilek <sedat.dilek@gmail.com> wrote:
>
> On Tue, Mar 1, 2022 at 4:59 PM Arnd Bergmann <arnd@kernel.org> wrote:
> >
> > From: Mark Rutland <mark.rutland@arm.com>
> >
> > In a subsequent patch we'll move the kernel from using `-std=gnu89` to
> > `-std=gnu11`, permitting the use of additional C11 features such as
> > for-loop initial declarations.
> >
> > One contentious aspect of C99 is that it permits mixed declarations and
> > code, and for now at least, it seems preferable to enforce that
> > declarations must come first.
> >
> > These warnings were already disabled in the kernel itself, but not
> > for KBUILD_USERCFLAGS or the compat VDSO on arch/arm64, which uses
> > a separate set of CFLAGS.
> >
> > This patch fixes an existing violation in modpost.c, which is not
> > reported because of the missing flag in KBUILD_USERCFLAGS:
> >
> > | scripts/mod/modpost.c: In function ‘match’:
> > | scripts/mod/modpost.c:837:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
> > | 837 | const char *endp = p + strlen(p) - 1;
> > | | ^~~~~
> >
> > Signed-off-by: Mark Rutland <mark.rutland@arm.com>
> > [arnd: don't add a duplicate flag to the default set, update changelog]
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>
> I was able to build and boot on bare metal.
>
> No new warnings in my build-log here after switching to -std=gnu11.
>
> Tested-by: Sedat Dilek <sedat.dilek@gmail.com> # LLVM/Clang v13.0.0 x86-64
>
I have re-tested with Debian's LLVM/Clang v14.0.0-rc2.
Tested-by: Sedat Dilek <sedat.dilek@gmail.com> # LLVM/Clang v14.0.0-rc2 (x86-64)
- sed@ -
> - sed@ -
>
> > ---
> > Makefile | 3 ++-
> > arch/arm64/kernel/vdso32/Makefile | 1 +
> > scripts/mod/modpost.c | 4 +++-
> > 3 files changed, 6 insertions(+), 2 deletions(-)
> >
> > diff --git a/Makefile b/Makefile
> > index 94fa9a849a7a..37ef6a555dcd 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -432,7 +432,8 @@ HOSTCXX = g++
> > endif
> >
> > export KBUILD_USERCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \
> > - -O2 -fomit-frame-pointer -std=gnu89
> > + -O2 -fomit-frame-pointer -std=gnu89 \
> > + -Wdeclaration-after-statement
> > export KBUILD_USERLDFLAGS :=
> >
> > KBUILD_HOSTCFLAGS := $(KBUILD_USERCFLAGS) $(HOST_LFS_CFLAGS) $(HOSTCFLAGS)
> > diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/Makefile
> > index 9378ea055bf2..ed181bedbffc 100644
> > --- a/arch/arm64/kernel/vdso32/Makefile
> > +++ b/arch/arm64/kernel/vdso32/Makefile
> > @@ -68,6 +68,7 @@ VDSO_CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
> > -fno-strict-aliasing -fno-common \
> > -Werror-implicit-function-declaration \
> > -Wno-format-security \
> > + -Wdeclaration-after-statement \
> > -std=gnu11
> > VDSO_CFLAGS += -O2
> > # Some useful compiler-dependent flags from top-level Makefile
> > diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
> > index 6bfa33217914..fe693304b120 100644
> > --- a/scripts/mod/modpost.c
> > +++ b/scripts/mod/modpost.c
> > @@ -833,8 +833,10 @@ static int match(const char *sym, const char * const pat[])
> > {
> > const char *p;
> > while (*pat) {
> > + const char *endp;
> > +
> > p = *pat++;
> > - const char *endp = p + strlen(p) - 1;
> > + endp = p + strlen(p) - 1;
> >
> > /* "*foo*" */
> > if (*p == '*' && *endp == '*') {
> > --
> > 2.29.2
> >
next prev parent reply other threads:[~2022-03-06 10:03 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-01 14:52 [PATCH 1/3] [v3] Kbuild: move to -std=gnu11 Arnd Bergmann
2022-03-01 14:52 ` [PATCH 2/3] treewide: use -Wdeclaration-after-statement Arnd Bergmann
2022-03-01 16:54 ` Nathan Chancellor
2022-03-01 19:57 ` Nick Desaulniers
2022-03-01 20:06 ` Nick Desaulniers
2022-03-01 20:20 ` Linus Torvalds
2022-03-01 20:28 ` Nick Desaulniers
2022-03-03 0:44 ` Masahiro Yamada
2022-03-04 11:29 ` Sedat Dilek
2022-03-06 10:03 ` Sedat Dilek [this message]
2022-03-01 14:52 ` [PATCH 3/3] Kbuild: use -std=gnu11 for KBUILD_USERCFLAGS Arnd Bergmann
2022-03-01 17:00 ` Nathan Chancellor
2022-03-01 19:56 ` Nick Desaulniers
2022-03-02 22:14 ` Sedat Dilek
2022-03-02 22:54 ` Nick Desaulniers
2022-03-03 6:26 ` Sedat Dilek
2022-03-03 17:37 ` Nathan Chancellor
2022-03-04 6:47 ` Sedat Dilek
2022-03-04 7:18 ` Sedat Dilek
2022-03-04 11:12 ` Sedat Dilek
2022-03-06 10:04 ` Sedat Dilek
2022-03-01 16:53 ` [PATCH 1/3] [v3] Kbuild: move to -std=gnu11 Nathan Chancellor
2022-03-04 5:03 ` Masahiro Yamada
2022-03-04 11:24 ` Sedat Dilek
2022-03-06 10:01 ` Sedat Dilek
2022-03-04 11:37 ` Sedat Dilek
2022-03-04 16:25 ` Sedat Dilek
2022-03-06 15:31 ` Sedat Dilek
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='CA+icZUVkpvQuRHqeRtQbrVHU7mb0rK7-TTFMHEgZ8k=_keMTSA@mail.gmail.com' \
--to=sedat.dilek@gmail.com \
--cc=alexs@kernel.org \
--cc=arnd@arndb.de \
--cc=arnd@kernel.org \
--cc=dsterba@suse.com \
--cc=elver@google.com \
--cc=jani.nikula@intel.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=mark.rutland@arm.com \
--cc=masahiroy@kernel.org \
--cc=ndesaulniers@google.com \
--cc=ojeda@kernel.org \
--cc=torvalds@linux-foundation.org \
/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;
as well as URLs for NNTP newsgroup(s).