[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f63891cb-13e7-443f-bf02-5a357aa2a70b@acm.org>
Date: Tue, 18 Nov 2025 09:18:50 -0800
From: Bart Van Assche <bvanassche@....org>
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 11/18/25 8:39 AM, James Bottomley wrote:
> The problem specifically is this added comment in cleanup.h:
>
>> * That bug is fixed by changing init() to call guard() and define +
>> * initialize @obj in this order::
>> *
>> * guard(mutex)(&lock);
>> * struct object *obj __free(remove_free) = alloc_add();
>
> Which is recommending mixing declarations and code contrary to our
> prior rule. I note the rule against mixing variables and code was
> relaxed in the C99 standard (and in a lot of other languages), but
> we've never formally changed our coding rules.
>
> I'm not saying we have to stick with C89, just that if we change
> adherence to it, we should do so globally and document it because
> having incosistency for __free vs other variables really isn't a good
> idea.
A related question is whether or not to allow declarations in the
initialization expression of for-statements. Although some maintainers
reject patches that use this C99 feature, apparently this feature is
already used extensively:
$ git grep -nH 'for (int ' | grep -vE '^Documentation/|^tools/' | wc -l
1239
Thanks,
Bart.
Powered by blists - more mailing lists