Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
* [PATCH][next] IB/hfi1: Avoid -Wflex-array-member-not-at-end warning
@ 2025-03-27 19:02 Gustavo A. R. Silva
  2025-03-30  9:53 ` Zhu Yanjun
  0 siblings, 1 reply; 2+ messages in thread
From: Gustavo A. R. Silva @ 2025-03-27 19:02 UTC (permalink / raw)
  To: Dennis Dalessandro, Jason Gunthorpe, Leon Romanovsky
  Cc: linux-rdma, linux-kernel, Gustavo A. R. Silva, linux-hardening

-Wflex-array-member-not-at-end was introduced in GCC-14, and we are
getting ready to enable it, globally.

Move the conflicting declaration to the end of the structure. Notice
that `struct opa_mad_notice_attr` is a flexible structure --a structure
that contains a flexible-array member.

Fix the following warning:

drivers/infiniband/hw/hfi1/mad.c:23:36: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
 drivers/infiniband/hw/hfi1/mad.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/hfi1/mad.c b/drivers/infiniband/hw/hfi1/mad.c
index b39f63ce6dfc..3f11a90819d1 100644
--- a/drivers/infiniband/hw/hfi1/mad.c
+++ b/drivers/infiniband/hw/hfi1/mad.c
@@ -20,12 +20,14 @@
 
 struct trap_node {
 	struct list_head list;
-	struct opa_mad_notice_attr data;
 	__be64 tid;
 	int len;
 	u32 retry;
 	u8 in_use;
 	u8 repress;
+
+	/* Must be last --ends in a flexible-array member. */
+	struct opa_mad_notice_attr data;
 };
 
 static int smp_length_check(u32 data_size, u32 request_len)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH][next] IB/hfi1: Avoid -Wflex-array-member-not-at-end warning
  2025-03-27 19:02 [PATCH][next] IB/hfi1: Avoid -Wflex-array-member-not-at-end warning Gustavo A. R. Silva
@ 2025-03-30  9:53 ` Zhu Yanjun
  0 siblings, 0 replies; 2+ messages in thread
From: Zhu Yanjun @ 2025-03-30  9:53 UTC (permalink / raw)
  To: Gustavo A. R. Silva, Dennis Dalessandro, Jason Gunthorpe,
	Leon Romanovsky
  Cc: linux-rdma, linux-kernel, linux-hardening

在 2025/3/27 20:02, Gustavo A. R. Silva 写道:
> -Wflex-array-member-not-at-end was introduced in GCC-14, and we are
> getting ready to enable it, globally.
> 
> Move the conflicting declaration to the end of the structure. Notice
> that `struct opa_mad_notice_attr` is a flexible structure --a structure
> that contains a flexible-array member.
> 
> Fix the following warning:
> 
> drivers/infiniband/hw/hfi1/mad.c:23:36: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
> 
> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>

Reviewed-by: Zhu Yanjun <yanjun.zhu@linux.dev>

Thanks,
Zhu Yanjun

> ---
>   drivers/infiniband/hw/hfi1/mad.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/hw/hfi1/mad.c b/drivers/infiniband/hw/hfi1/mad.c
> index b39f63ce6dfc..3f11a90819d1 100644
> --- a/drivers/infiniband/hw/hfi1/mad.c
> +++ b/drivers/infiniband/hw/hfi1/mad.c
> @@ -20,12 +20,14 @@
>   
>   struct trap_node {
>   	struct list_head list;
> -	struct opa_mad_notice_attr data;
>   	__be64 tid;
>   	int len;
>   	u32 retry;
>   	u8 in_use;
>   	u8 repress;
> +
> +	/* Must be last --ends in a flexible-array member. */
> +	struct opa_mad_notice_attr data;
>   };
>   
>   static int smp_length_check(u32 data_size, u32 request_len)


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-03-30  9:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-27 19:02 [PATCH][next] IB/hfi1: Avoid -Wflex-array-member-not-at-end warning Gustavo A. R. Silva
2025-03-30  9:53 ` Zhu Yanjun

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox