Patch "Kbuild: use -Wdeclaration-after-statement" has been added to the 5.15-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    Kbuild: use -Wdeclaration-after-statement

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     kbuild-use-wdeclaration-after-statement.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit c06a25dc5234f3654a23eb292536f8f7f6a69a8f
Author: Mark Rutland <mark.rutland@xxxxxxx>
Date:   Tue Mar 8 22:56:13 2022 +0100

    Kbuild: use -Wdeclaration-after-statement
    
    [ Upstream commit 4d94f910e79a349b00a4f8aab6f3ae87129d8c5a ]
    
    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@xxxxxxx>
    [arnd: don't add a duplicate flag to the default set, update changelog]
    Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
    Reviewed-by: Nathan Chancellor <nathan@xxxxxxxxxx>
    Reviewed-by: Nick Desaulniers <ndesaulniers@xxxxxxxxxx>
    Tested-by: Sedat Dilek <sedat.dilek@xxxxxxxxx> # LLVM/Clang v13.0.0 (x86-64)
    Signed-off-by: Masahiro Yamada <masahiroy@xxxxxxxxxx>
    Stable-dep-of: cbf54f37600e ("platform/x86: wmi: Skip blocks with zero instances")
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/Makefile b/Makefile
index 678e712591f89..5976e71522607 100644
--- a/Makefile
+++ b/Makefile
@@ -440,7 +440,8 @@ endif
 HOSTPKG_CONFIG	= pkg-config
 
 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 83e9399e38368..50cb1ec092ae5 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 c6e655e0ed988..945f9ecb34079 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 == '*') {




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux