Re: Clarifying confusion of our variable placement rules caused by cleanup.h
From: Steven Rostedt
Date: Tue Nov 18 2025 - 15:50:58 EST
On Tue, 18 Nov 2025 15:21:10 -0500
James Bottomley <James.Bottomley@xxxxxxxxxxxxxxxxxxxxx> wrote:
> There is one last case that hasn't been discussed, which is where you
> deliberately introduce an extra scope block for the free and
> allocation, so in your example above it would look like
>
> if (ret < )
> return -ERROR
>
> [ several more error exits ]
>
> {
> struct foo *var __free(kfree) = kmalloc(...)
>
> [...]
> }
I'm not too big on explicit blocks for just declarations. Especially, in my
case where the var is used until the end:
{
struct foo *var __free(kfree) = kmalloc(...)
[...]
return func(..., var);
}
It seems a bit strange to have the final return of a function from within
an explicit scope block. Especially since the beginning is just for error
conditions, and the meat of the function is now in that explicit block.
-- Steve