[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240325224706.GB8419@ziepe.ca>
Date: Mon, 25 Mar 2024 19:47:06 -0300
From: Jason Gunthorpe <jgg@...pe.ca>
To: "Gustavo A. R. Silva" <gustavoars@...nel.org>
Cc: Leon Romanovsky <leon@...nel.org>, linux-rdma@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-hardening@...r.kernel.org
Subject: Re: [PATCH][next] RDMA/cm: Avoid -Wflex-array-member-not-at-end
warning
On Mon, Mar 25, 2024 at 02:24:07PM -0600, Gustavo A. R. Silva wrote:
> -Wflex-array-member-not-at-end is coming in GCC-14, and we are getting
> ready to enable it globally.
>
> Use the `struct_group_tagged()` helper to separate the flexible array
> from the rest of the members in flexible `struct cm_work`, and avoid
> embedding the flexible-array member in `struct cm_timewait_info`.
>
> Also, use `container_of()` to retrieve a pointer to the flexible
> structure.
>
> So, with these changes, fix the following warning:
> drivers/infiniband/core/cm.c:196:24: 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@...nel.org>
> ---
> drivers/infiniband/core/cm.c | 21 ++++++++++++---------
> 1 file changed, 12 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
> index bf0df6ee4f78..80c87085499c 100644
> --- a/drivers/infiniband/core/cm.c
> +++ b/drivers/infiniband/core/cm.c
> @@ -182,18 +182,21 @@ struct cm_av {
> };
>
> struct cm_work {
> - struct delayed_work work;
> - struct list_head list;
> - struct cm_port *port;
> - struct ib_mad_recv_wc *mad_recv_wc; /* Received MADs */
> - __be32 local_id; /* Established / timewait */
> - __be32 remote_id;
> - struct ib_cm_event cm_event;
> + /* New members must be added within the struct_group() macro below. */
> + struct_group_tagged(cm_work_hdr, hdr,
> + struct delayed_work work;
> + struct list_head list;
> + struct cm_port *port;
> + struct ib_mad_recv_wc *mad_recv_wc; /* Received MADs */
> + __be32 local_id; /* Established / timewait */
> + __be32 remote_id;
> + struct ib_cm_event cm_event;
> + );
> struct sa_path_rec path[];
> };
I didn't look, but does it make more sense to break out the path side
into its own type and avoid the struct_group_tagged? I seem to
remember only one thing used it.
Jason
Powered by blists - more mailing lists