On Mon, Feb 28, 2022 at 8:25 PM Mark Rutland <mark.rutland@xxxxxxx> wrote: > > Hi Arnd, > > This is great! > > On Mon, Feb 28, 2022 at 11:27:43AM +0100, Arnd Bergmann wrote: > > From: Arnd Bergmann <arnd@xxxxxxxx> > > > > During a patch discussion, Linus brought up the option of changing > > the C standard version from gnu89 to gnu99, which allows using variable > > declaration inside of a for() loop. While the C99, C11 and later standards > > introduce many other features, most of these are already available in > > gnu89 as GNU extensions as well. > > > > An earlier attempt to do this when gcc-5 started defaulting to > > -std=gnu11 failed because at the time that caused warnings about > > designated initializers with older compilers. Now that gcc-5.1 is the > > minimum compiler version used for building kernels, that is no longer a > > concern. Similarly, the behavior of 'inline' functions changes between > > gnu89 and gnu11, but this was taken care of by defining 'inline' to > > include __attribute__((gnu_inline)) in order to allow building with > > clang a while ago. > > > > One minor issue that remains is an added gcc warning for shifts of > > negative integers when building with -Werror, which happens with the > > 'make W=1' option, as well as for three drivers in the kernel that always > > enable -Werror, but it was only observed with the i915 driver so far. > > To be on the safe side, add -Wno-shift-negative-value to any -Wextra > > in a Makefile. > > > > Nathan Chancellor reported an additional -Wdeclaration-after-statement > > warning that appears in a system header on arm, this still needs a > > workaround. > > FWIW, I had a go at moving to c99 a few weeks ago (to be able to use > for-loop-declarations in some concurrency primitives), and when I tried, I also > saw declaration-after-statement warnings when building modpost.c, which is easy > enough to fix: > > https://git.kernel.org/pub/scm/linux/kernel/git/mark/linux.git/commit/?h=treewide/gnu99&id=505775bd6fd0bc1883f3271f826963066bbdc194 > I do not understand this statement: "Usually such warnings are implciitly enabled as part of `-std=gnu89`, and in preparation for changing the standard used, this patch explciitly enales the warnings with `-Wdeclaration-after-statement`, which takes effect regardless of which version of the C standard is in use." modpost is already built with -std=gnu89. If Wdeclaration-after-statement is implied by gnu89, why did nobody notice this before? -- Best Regards Masahiro Yamada