Re: [PATCH] iio: iio-mux: use flexible array member

From: Andy Shevchenko

Date: Mon Mar 16 2026 - 15:45:32 EST


On Mon, Mar 16, 2026 at 11:11:22AM -0700, Rosen Penev wrote:
> On Mon, Mar 16, 2026 at 7:16 AM Andy Shevchenko
> <andriy.shevchenko@xxxxxxxxx> wrote:
> > On Sun, Mar 15, 2026 at 03:45:09PM -0700, Rosen Penev wrote:

...

> > > - sizeof_priv = sizeof(*mux);
> > > - sizeof_priv += sizeof(*mux->child) * children;
> > > + sizeof_priv = struct_size(mux, child, children);
> > > sizeof_priv += sizeof(*mux->chan) * children;
> >
> > There are two arrays that are allocated at the end of the same object.
> > Why is mux better than the chan?
> It's how it's already laid out. mux first and then the other data.

It doesn't matter, right?

> > I rather would see two times array_size() than the above.

> OK

> > > sizeof_priv += sizeof_ext_info;

--
With Best Regards,
Andy Shevchenko