Re: [PATCH][next] RDMA/rxe: Avoid -Wflex-array-member-not-at-end warnings

Gustavo A. R. Silva
2025-12-19T09:55:13Z

On 12/19/25 15:59, Zhu Yanjun wrote:
>
> 在 2025/12/18 21:48, Gustavo A. R. Silva 写道:
>>
>>> The struct rxe_recv_wqe is as below.
>>>
>>> struct rxe_recv_wqe {
>>>      __aligned_u64       wr_id;
>>>      __u32           reserved;
>>>      __u32           padding;
>>>      struct rxe_dma_info dma;
>>
>> Expand struct rxe_dma_info here.
>
> Thanks. In struct rxe_dma_info, the struct is
>
> struct rxe_sge {
>        __aligned_u64 addr;
>        __u32   length;
>        __u32   lkey;
> };
>
> But in your commit, struct ib_sge is used.
>
> struct ib_sge {
>     u64 addr;
>     u32 length;
>     u32 lkey;
> };
> __aligned_u64 is a 64-bit integer with a guaranteed 8-byte alignment,
>
> used to preserve ABI correctness across architectures and between
>
> userspace and kernel, while u64 has architecture-dependent alignment.
>
> I am not sure if we can treate "struct rxe_sge" as the same with "struct ib_sge".

Just notice that the original code is the one actually doing that.
See my response in this same thread:

https://lore.kernel.org/linux-hardening/d3336e9d-2b84-4698-a799-b49e3845f38f@embeddedor.com/

So, if that code is fine, this is fine. If the original code is wrong,
then that code should be fixed first.

-Gustavo

>
>
> Leon and Jason, please comment on it.
>
>
> Yanjun.Zhu
>
>>
>>> };
>>>
>>> But I can not find dma.sge in the above struct. Can you explain it?
>>>
>>> To be honest, I read your original commit for several times, but I can not get it.  Can you explain the MACRO TRAILING_OVERLAP? And how can it replace the
>>> following struct?
>>
>> This is clearly explained in the changelog text. I think what you're
>> missing will be clear once you understand how nested structures
>> work. See my comment above.
>>
>> -Gustavo
>