Re: [PATCH 4/9] device property: provide fwnode_property_get_names()
From: Bartosz Golaszewski
Date: Mon Nov 09 2026 - 10:00:05 EST
On Mon, Nov 09, 2026 at 03:30:08PM +0100, Alejandro Colomar wrote:
> Hi Bartosz,
>
> > Date: 2026-11-09 13:59:05+0100
> > From: Bartosz Golaszewski <brgl@xxxxxxxxxx>
> >
> [...]
> > > > > > +int fwnode_property_get_names(const struct fwnode_handle *fwnode, char ***props)
> > > > >
> > > > > Triple indirection is rare. Do we really need it?
> > > > >
> > > >
> > > > I don't have a better alternative. Having two functions: one for
> > > > counting the names and another for retrieving them into a
> > > > caller-provided array is IMO the worse alternative, so I'd keep it.
> > >
> > > Would it be possible to return the pointer, and then pass the count as
> > > a parameter?
> > >
> >
> > Is this really better? I think it's less intuitive than just passing a
> > pointer to an array of strings.
>
> Returning allocated pointers has a benefit for static analysis: the
> function could be marked with __attribute__((__malloc__(deallocator))).
>
I had a comment under a different patch in this series, where I
suggested that returning the number of properties could be used to
simply count the properties with props == NULL. This would make the
function future-proof in case we need that functionality.
Bart