Re: Clarifying confusion of our variable placement rules caused by cleanup.h

Steven Rostedt <[email protected]>
Newsgroups dev.linux.lists.ksummit,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On Tue, 18 Nov 2025 15:21:10 -0500
James Bottomley <[email protected]> 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.