Re: Clarifying confusion of our variable placement rules caused by cleanup.h
From: Jani Nikula
Date: Tue Nov 25 2025 - 08:10:10 EST
On Tue, 18 Nov 2025, James Bottomley <James.Bottomley@xxxxxxxxxxxxxxxxxxxxx> wrote:
> For myself I do find some value in the C89 declarations at the
> beginning of the block for readability, so I'm happy to relax the
> mixing rule to cases where it's strictly necessary and require
> documenting in the comment what the necessity is.
I think I've seen an increase in patches using non-pointer const local
variables. No metrics, just a gut feeling.
const int foo = bar + 5;
I haven't really decided whether I like that or not, and subsequently I
have neither encouraged or discouraged that usage. I don't think we have
any style guidance on that either.
Anyway, more const usage like that would also benefit from declaration
and initialization at a later point when the initializer value is
available, if it's not at the beginning.
BR,
Jani.
--
Jani Nikula, Intel