Re: [PATCH] iio: iio-mux: use flexible array member
From: Rosen Penev
Date: Mon Mar 16 2026 - 14:12:06 EST
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:
> > Allows using struct_size to simplify allocation slightly.
> >
> > Removes a pointer from the struct.
>
> ...
>
> > - 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.
>
>
> I rather would see two times array_size() than the above.
OK
>
> > sizeof_priv += sizeof_ext_info;
>
> --
> With Best Regards,
> Andy Shevchenko
>
>