Re: [PATCH v4 2/3] device property: Refactor to use RAII approach

From: Andy Shevchenko

Date: Thu Jun 11 2026 - 17:12:32 EST


On Thu, Jun 11, 2026 at 10:46:31PM +0200, Rafael J. Wysocki wrote:
> On Thu, Jun 11, 2026 at 10:35 PM Andy Shevchenko
> <andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
> > In a couple of functions code can be made cleaner with help of
> > __free() macro. Refactor these to use RAII approach.

...

> > fwnode_graph_get_next_endpoint(const struct fwnode_handle *fwnode,
> > struct fwnode_handle *prev)
> > {
> > - struct fwnode_handle *ep, *port_parent = NULL;
> > const struct fwnode_handle *parent;
> > + struct fwnode_handle *port_parent __free(fwnode_handle) = NULL;
>
> The thing on the right-hand side of the assignment should be a
> constructor, shouldn't it?

Nope. It's a recommendation to do a such, but in this case it's hard to achieve
(since the constructor is inside the conditional scope) and actually is not needed
as we don't mix up with other RAII calls, such a guard()().

--
With Best Regards,
Andy Shevchenko