History

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; | | ^~~~~

Mark Rutland committed 4 years ago

Commit 4d94f911 parent 13447943 files · +6 −2Browse files

Showing the changes to scripts (1 of 3 files). Show all

Unified · Split

scripts/mod/modpost.c+3−1
@@ -833,8 +833,10 @@ static int match(const char *sym, const char * const pat[]) · 832 unmodified lines
833{833{
834 const char *p;834 const char *p;
835 while (*pat) {835 while (*pat) {
836 const char *endp;
837
836 p = *pat++;838 p = *pat++;
837 const char *endp = p + strlen(p) - 1;839 endp = p + strlen(p) - 1;
838 840
839 /* "*foo*" */841 /* "*foo*" */
840 if (*p == '*' && *endp == '*') {842 if (*p == '*' && *endp == '*') {