Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'kbuild-gnu11-v5.18' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild

Pull Kbuild update for C11 language base from Masahiro Yamada:
"Kbuild -std=gnu11 updates for v5.18

Linus pointed out the benefits of C99 some years ago, especially
variable declarations in loops [1]. At that time, we were not ready
for the migration due to old compilers.

Recently, Jakob Koschel reported a bug in list_for_each_entry(), which
leaks the invalid pointer out of the loop [2]. In the discussion, we
agreed that the time had come. Now that GCC 5.1 is the minimum
compiler version, there is nothing to prevent us from going to
-std=gnu99, or even straight to -std=gnu11.

Discussions for a better list iterator implementation are ongoing, but
this patch set must land first"

[1] https://lore.kernel.org/all/CAHk-=wgr12JkKmRd21qh-se-_Gs69kbPgR9x4C+Es-yJV2GLkA@mail.gmail.com/
[2] https://lore.kernel.org/lkml/86C4CE7D-6D93-456B-AA82-F8ADEACA40B7@gmail.com/

* tag 'kbuild-gnu11-v5.18' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
Kbuild: use -std=gnu11 for KBUILD_USERCFLAGS
Kbuild: move to -std=gnu11
Kbuild: use -Wdeclaration-after-statement
Kbuild: add -Wno-shift-negative-value where -Wextra is used

+21 -15
+3 -3
Documentation/process/programming-language.rst
··· 5 5 6 6 The kernel is written in the C programming language [c-language]_. 7 7 More precisely, the kernel is typically compiled with ``gcc`` [gcc]_ 8 - under ``-std=gnu89`` [gcc-c-dialect-options]_: the GNU dialect of ISO C90 9 - (including some C99 features). ``clang`` [clang]_ is also supported, see 10 - docs on :ref:`Building Linux with Clang/LLVM <kbuild_llvm>`. 8 + under ``-std=gnu11`` [gcc-c-dialect-options]_: the GNU dialect of ISO C11. 9 + ``clang`` [clang]_ is also supported, see docs on 10 + :ref:`Building Linux with Clang/LLVM <kbuild_llvm>`. 11 11 12 12 This dialect contains many extensions to the language [gnu-extensions]_, 13 13 and many of them are used within the kernel as a matter of course.
+2 -2
Documentation/translations/it_IT/process/programming-language.rst
··· 10 10 11 11 Il kernel è scritto nel linguaggio di programmazione C [it-c-language]_. 12 12 Più precisamente, il kernel viene compilato con ``gcc`` [it-gcc]_ usando 13 - l'opzione ``-std=gnu89`` [it-gcc-c-dialect-options]_: il dialetto GNU 14 - dello standard ISO C90 (con l'aggiunta di alcune funzionalità da C99). 13 + l'opzione ``-std=gnu11`` [it-gcc-c-dialect-options]_: il dialetto GNU 14 + dello standard ISO C11. 15 15 Linux supporta anche ``clang`` [it-clang]_, leggete la documentazione 16 16 :ref:`Building Linux with Clang/LLVM <kbuild_llvm>`. 17 17
+1 -2
Documentation/translations/zh_CN/process/programming-language.rst
··· 9 9 ============ 10 10 11 11 内核是用C语言 :ref:`c-language <cn_c-language>` 编写的。更准确地说,内核通常是用 :ref:`gcc <cn_gcc>` 12 - 在 ``-std=gnu89`` :ref:`gcc-c-dialect-options <cn_gcc-c-dialect-options>` 下编译的:ISO C90的 GNU 方言( 13 - 包括一些C99特性) 12 + 在 ``-std=gnu11`` :ref:`gcc-c-dialect-options <cn_gcc-c-dialect-options>` 下编译的:ISO C11的 GNU 方言 14 13 15 14 这种方言包含对语言 :ref:`gnu-extensions <cn_gnu-extensions>` 的许多扩展,当然,它们许多都在内核中使用。 16 15
+1 -2
Documentation/translations/zh_TW/process/programming-language.rst
··· 12 12 ============ 13 13 14 14 內核是用C語言 :ref:`c-language <tw_c-language>` 編寫的。更準確地說,內核通常是用 :ref:`gcc <tw_gcc>` 15 - 在 ``-std=gnu89`` :ref:`gcc-c-dialect-options <tw_gcc-c-dialect-options>` 下編譯的:ISO C90的 GNU 方言( 16 - 包括一些C99特性) 15 + 在 ``-std=gnu11`` :ref:`gcc-c-dialect-options <tw_gcc-c-dialect-options>` 下編譯的:ISO C11的 GNU 方言 17 16 18 17 這種方言包含對語言 :ref:`gnu-extensions <tw_gnu-extensions>` 的許多擴展,當然,它們許多都在內核中使用。 19 18
+4 -3
Makefile
··· 432 432 endif 433 433 434 434 export KBUILD_USERCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \ 435 - -O2 -fomit-frame-pointer -std=gnu89 435 + -O2 -fomit-frame-pointer -std=gnu11 \ 436 + -Wdeclaration-after-statement 436 437 export KBUILD_USERLDFLAGS := 437 438 438 439 KBUILD_HOSTCFLAGS := $(KBUILD_USERCFLAGS) $(HOST_LFS_CFLAGS) $(HOSTCFLAGS) ··· 516 515 -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \ 517 516 -Werror=implicit-function-declaration -Werror=implicit-int \ 518 517 -Werror=return-type -Wno-format-security \ 519 - -std=gnu89 518 + -std=gnu11 520 519 KBUILD_CPPFLAGS := -D__KERNEL__ 521 520 KBUILD_AFLAGS_KERNEL := 522 521 KBUILD_CFLAGS_KERNEL := ··· 783 782 784 783 ifdef CONFIG_CC_IS_CLANG 785 784 KBUILD_CPPFLAGS += -Qunused-arguments 786 - # The kernel builds with '-std=gnu89' so use of GNU extensions is acceptable. 785 + # The kernel builds with '-std=gnu11' so use of GNU extensions is acceptable. 787 786 KBUILD_CFLAGS += -Wno-gnu 788 787 # CLANG uses a _MergedGlobals as optimization, but this breaks modpost, as the 789 788 # source of a reference will be _MergedGlobals and not on of the whitelisted names.
+2 -1
arch/arm64/kernel/vdso32/Makefile
··· 68 68 -fno-strict-aliasing -fno-common \ 69 69 -Werror-implicit-function-declaration \ 70 70 -Wno-format-security \ 71 - -std=gnu89 71 + -Wdeclaration-after-statement \ 72 + -std=gnu11 72 73 VDSO_CFLAGS += -O2 73 74 # Some useful compiler-dependent flags from top-level Makefile 74 75 VDSO_CFLAGS += $(call cc32-option,-Wdeclaration-after-statement,)
+1
drivers/gpu/drm/i915/Makefile
··· 18 18 subdir-ccflags-y += -Wno-type-limits 19 19 subdir-ccflags-y += -Wno-missing-field-initializers 20 20 subdir-ccflags-y += -Wno-sign-compare 21 + subdir-ccflags-y += -Wno-shift-negative-value 21 22 subdir-ccflags-y += $(call cc-disable-warning, unused-but-set-variable) 22 23 subdir-ccflags-y += $(call cc-disable-warning, frame-address) 23 24 subdir-ccflags-$(CONFIG_DRM_I915_WERROR) += -Werror
+2 -1
drivers/staging/greybus/tools/Makefile
··· 12 12 -Wredundant-decls \ 13 13 -Wcast-align \ 14 14 -Wsign-compare \ 15 - -Wno-missing-field-initializers 15 + -Wno-missing-field-initializers \ 16 + -Wno-shift-negative-value 16 17 17 18 CC := $(CROSS_COMPILE)gcc 18 19
+1
fs/btrfs/Makefile
··· 17 17 subdir-ccflags-y += -Wno-missing-field-initializers 18 18 subdir-ccflags-y += -Wno-sign-compare 19 19 subdir-ccflags-y += -Wno-type-limits 20 + subdir-ccflags-y += -Wno-shift-negative-value 20 21 21 22 obj-$(CONFIG_BTRFS_FS) := btrfs.o 22 23
+1
scripts/Makefile.extrawarn
··· 36 36 KBUILD_CFLAGS += -Wno-missing-field-initializers 37 37 KBUILD_CFLAGS += -Wno-sign-compare 38 38 KBUILD_CFLAGS += -Wno-type-limits 39 + KBUILD_CFLAGS += -Wno-shift-negative-value 39 40 40 41 KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN1 41 42
+3 -1
scripts/mod/modpost.c
··· 838 838 { 839 839 const char *p; 840 840 while (*pat) { 841 + const char *endp; 842 + 841 843 p = *pat++; 842 - const char *endp = p + strlen(p) - 1; 844 + endp = p + strlen(p) - 1; 843 845 844 846 /* "*foo*" */ 845 847 if (*p == '*' && *endp == '*') {