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

From: David Lechner

Date: Tue Mar 17 2026 - 11:06:06 EST


On 3/17/26 2:26 AM, Andy Shevchenko wrote:
> On Mon, Mar 16, 2026 at 04:29:42PM -0700, Rosen Penev wrote:
>> Make it clear that there's trailing data
>>
>> Removes a pointer from the struct.
>>
>> Use array_size for the sizeof calculations. Slightly cleaner.
>
> array_size()
> sizeof()
>
> This commit message is poorly written. Please, consult with
> https://chris.beams.io/git-commit on how to write better commit
> messages.
>
> ...
>
>> struct mux {
>
>> struct iio_channel *parent;
>> struct iio_chan_spec *chan;
>> struct iio_chan_spec_ext_info *ext_info;
>> - struct mux_child *child;
>> u32 delay_us;
>> + struct mux_child child[];
>> };
>
> What's the point now to make it VLA? Again, why this and not the other one?

I agree with Andy here. It doesn't make much sense to use a variable length
array for one when there are other similar arrays in the same struct.


>
> ...
>
>> mux = iio_priv(indio_dev);
>> - mux->child = (struct mux_child *)(mux + 1);
>> mux->chan = (struct iio_chan_spec *)(mux->child + children);
>
> (This piece linked to the above comment.)
>