[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <cd6f099c-c28c-4b69-85f7-6012139fd646@zytor.com>
Date: Tue, 18 Nov 2025 11:23:51 -0800
From: "H. Peter Anvin" <hpa@...or.com>
To: James Bottomley <James.Bottomley@...senPartnership.com>,
ksummit@...ts.linux.dev, Dan Williams <dan.j.williams@...el.com>
Cc: 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 2025-11-18 08:39, James Bottomley 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. However, I do think
> we should, absent ordering problems, keep __free variables
> uninitialised and at the top of the block given we can detect any
> problem (and thus keep this rule absolutely for non-__free variables
> where there's no ordering issues). But, again, I'm less attached to
> this position than I am to the consistency one: I really think it's a
> bad idea to change the rules for one class of variables but not for
> another, so whatever we do, we should do it for everything and if that
> means relaxing the rule mixing code and declarations for everthing, I
> can live with that.
>
To me, a major win with pushing declarations down to first initialization or
thereabouts is that it implicitly reduces the scope of a variable (without
needing to create new blocks.) This can sometimes catch some pretty serious
errors.
-hpa
Powered by blists - more mailing lists