Re: [PATCH] RDMA: Replace zero-length array with flexible-array member

From: Dennis Dalessandro
Date: Fri Apr 01 2022 - 09:32:12 EST


On 4/1/22 7:50 AM, Jason Gunthorpe wrote:
> On Fri, Apr 01, 2022 at 07:54:06AM +0000, cgel.zte@xxxxxxxxx wrote:
>> From: Lv Ruyi <lv.ruyi@xxxxxxxxxx>
>>
>> There is a regular need in the kernel to provide a way to declare
>> having a dynamically sized set of trailing elements in a structure.
>> Kernel code should always use “flexible array members”[1] for these
>> cases. The older style of one-element or zero-length arrays should
>> no longer be used[2].
>
> If I recall properly this doesn't work if the flex array is nested
> inside another member.. Not sure what this thinks it is doing anyhow

I was under the impression that the main goal of using the flex array was so
that people didn't calculate sizes incorrectly. Perhaps I'm wrong though.
I don't really see this being needed. If it even works when nested as Jason
mentioned.

Now that being said there is some clean up that needs to be done to this code,
but it's not this.

-Denny