diff options
author | Olliver Schinagl <oliver@schinagl.nl> | 2022-09-04 22:08:47 +0200 |
---|---|---|
committer | Christian Marangi <ansuelsmth@gmail.com> | 2022-10-13 16:03:35 +0200 |
commit | 41a1a652fbd407a40d55a07bccdbc92770a4c2be (patch) | |
tree | 785e3241cb775121ad98ab8bd39125976287efd0 /target/linux/generic/backport-5.15/005-v5.17-01-Kbuild-use-Wdeclaration-after-statement.patch | |
parent | 2f8ac8bcea879542b2bc414a108c3aff166d5ef5 (diff) | |
download | upstream-41a1a652fbd407a40d55a07bccdbc92770a4c2be.tar.gz upstream-41a1a652fbd407a40d55a07bccdbc92770a4c2be.tar.bz2 upstream-41a1a652fbd407a40d55a07bccdbc92770a4c2be.zip |
kernel: backport gnu11 upgrade
Upstream has switched to gnu11 not too long ago. One advantage of
backporting this to these older kernels is, that we can encourage and
write better upstreamable kernels. E.g. the kernel devs prefer loop
declarations. Shrinking the master/local gap will be useful in these
cases.
Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
Acked-by: Christian Marangi <ansuelsmth@gmail.com>
Diffstat (limited to 'target/linux/generic/backport-5.15/005-v5.17-01-Kbuild-use-Wdeclaration-after-statement.patch')
-rw-r--r-- | target/linux/generic/backport-5.15/005-v5.17-01-Kbuild-use-Wdeclaration-after-statement.patch | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/target/linux/generic/backport-5.15/005-v5.17-01-Kbuild-use-Wdeclaration-after-statement.patch b/target/linux/generic/backport-5.15/005-v5.17-01-Kbuild-use-Wdeclaration-after-statement.patch new file mode 100644 index 0000000000..141a7a18c5 --- /dev/null +++ b/target/linux/generic/backport-5.15/005-v5.17-01-Kbuild-use-Wdeclaration-after-statement.patch @@ -0,0 +1,81 @@ +From 2fd7e7f9317d3048a14026816d081b08ba98ea8e Mon Sep 17 00:00:00 2001 +From: Mark Rutland <mark.rutland@arm.com> +Date: Tue, 8 Mar 2022 22:56:13 +0100 +Subject: [PATCH 1/3] Kbuild: use -Wdeclaration-after-statement + +The kernel is moving 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 enabled 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> +Reviewed-by: Nathan Chancellor <nathan@kernel.org> +Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> +Tested-by: Sedat Dilek <sedat.dilek@gmail.com> # LLVM/Clang v13.0.0 (x86-64) +Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> +--- + 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 b9e0b5c604af..cfe400032f96 100644 +--- a/Makefile ++++ b/Makefile +@@ -416,7 +416,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 abad38c576e1..33cd7ed3f94f 100644 +--- a/arch/arm64/kernel/vdso32/Makefile ++++ b/arch/arm64/kernel/vdso32/Makefile +@@ -76,6 +76,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=gnu89 + 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 3c27a177b28b..d2b17ed27e6e 100644 +--- a/scripts/mod/modpost.c ++++ b/scripts/mod/modpost.c +@@ -844,8 +844,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.37.2 |