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

From: Linus Torvalds
Date: Fri Oct 28 2022 - 16:29:34 EST


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.
Put all declarations at the top of the block they are contained in.

IOW, -Wdeclaration-after-statement does exactly the right thing, and stays.

This is not about "old compilers", this is about coding rules.

Linus