[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <7b37e1cb-271e-49fe-a3ee-5443006284e1@p183>
Date: Tue, 25 Nov 2025 17:25:19 +0300
From: Alexey Dobriyan <adobriyan@...il.com>
To: James Bottomley <James.Bottomley@...senPartnership.com>
Cc: ksummit@...ts.linux.dev, Dan Williams <dan.j.williams@...el.com>,
linux-kernel <linux-kernel@...r.kernel.org>,
Dan Carpenter <dan.carpenter@...aro.org>
Subject: Re: Clarifying confusion of our variable placement rules caused by
cleanup.h
On Tue, Nov 18, 2025 at 11:39:26AM -0500, James Bottomley wrote:
> So which should we do?
The best way to understand that C89 style of declaring in the beginning
of the function is pointless rule is to write some code in a language
which doesn't enforce it. You should see that nothing bad happens.
It increases bug rate due to increased variable scope allowing typos.
It bloats LOC -- in many cases declaration and initializer can fit
into a single line.
It prevents adding "const" qualifier if necessary.
Pressing PageUp and PageDown when adding new variable is pointless
busywork and distracts, breaks the tempo(flow?) so to speak.
C89 style provokes substyles(!) which makes adding new variables even
more obnoxious: some subsystems have(had?) a rule saying that declarations
(with initializers) must be sorted by length, so not only programmer has
to PageUp to the beginning of the block, but then aim carefully and
insert new declaration.
None of this is necessary (or possible) if the rule says "declare as low
as possible".
There was variation of this type of nonsense with headers (not only it has
to be sorted alphabetically but by length too!)
There is no practical difference between code and declarations:
declarations can have initializers which can be arbitrary complex,
just like "real" code. So the only difference is superficial.
C89 declaration style is pointless and dumb, no wonder other programming
languages dumped it (or never had), it should be simply discarded.
It will also make Linux slightly less white crow to newcomers
(C++ doesn't have this rule after all).
Powered by blists - more mailing lists