Re: [PATCH] kbuild: drop -Wdeclaration-after-statement

From: Alexey Dobriyan
Date: Fri Oct 28 2022 - 16:55:44 EST


On Fri, Oct 28, 2022 at 01:29:08PM -0700, Linus Torvalds wrote:
> On Fri, Oct 28, 2022 at 1:00 PM Alexey Dobriyan <adobriyan@xxxxxxxxx> wrote:
> >
> > Putting declarations in the beginning of the block is an afterfact from
> > single pass compiler era. Compiler would parse all declarations, layout
> > stack frame and proceed to generate code.
>
> No, putting declarations at the beginning is still kernel syntax.
>
> Don't declare variables in multiple places. It gets really confusing.

It is not. Somehow millions of programmers manage to find their
variables just fine in C and other programming languages.

> Put all declarations at the top of the block they are contained in.

I tried it the other way after years of LK style. Universe didn't collapse.

> IOW, -Wdeclaration-after-statement does exactly the right thing, and stays.
>
> This is not about "old compilers", this is about coding rules.
>
> Linus