[PATCH][next] nvme-loop: Avoid -Wflex-array-member-not-at-end warning

Gustavo A. R. Silva posted 1 patch 8 months, 3 weeks ago
drivers/nvme/target/loop.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
[PATCH][next] nvme-loop: Avoid -Wflex-array-member-not-at-end warning
Posted by Gustavo A. R. Silva 8 months, 3 weeks ago
-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 nvme_loop_iod` is a flexible structure --a structure
that contains a flexible-array member.

Fix the following warning:

drivers/nvme/target/loop.c:36:33: 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/nvme/target/loop.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/target/loop.c b/drivers/nvme/target/loop.c
index a5c41144667c..d02b80803278 100644
--- a/drivers/nvme/target/loop.c
+++ b/drivers/nvme/target/loop.c
@@ -33,10 +33,12 @@ struct nvme_loop_ctrl {
 
 	struct list_head	list;
 	struct blk_mq_tag_set	tag_set;
-	struct nvme_loop_iod	async_event_iod;
 	struct nvme_ctrl	ctrl;
 
 	struct nvmet_port	*port;
+
+	/* Must be last --ends in a flexible-array member. */
+	struct nvme_loop_iod	async_event_iod;
 };
 
 static inline struct nvme_loop_ctrl *to_loop_ctrl(struct nvme_ctrl *ctrl)
-- 
2.43.0
Re: [PATCH][next] nvme-loop: Avoid -Wflex-array-member-not-at-end warning
Posted by Christoph Hellwig 7 months, 4 weeks ago
Thanks,

applied to nvme-6.16.
Re: [PATCH][next] nvme-loop: Avoid -Wflex-array-member-not-at-end warning
Posted by Gustavo A. R. Silva 8 months ago
Hi all,

Friendly ping: who can take this patch, please? :)

Thanks!
-Gustavo

On 28/03/25 08:25, Gustavo A. R. Silva wrote:
> -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 nvme_loop_iod` is a flexible structure --a structure
> that contains a flexible-array member.
> 
> Fix the following warning:
> 
> drivers/nvme/target/loop.c:36:33: 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/nvme/target/loop.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/nvme/target/loop.c b/drivers/nvme/target/loop.c
> index a5c41144667c..d02b80803278 100644
> --- a/drivers/nvme/target/loop.c
> +++ b/drivers/nvme/target/loop.c
> @@ -33,10 +33,12 @@ struct nvme_loop_ctrl {
>   
>   	struct list_head	list;
>   	struct blk_mq_tag_set	tag_set;
> -	struct nvme_loop_iod	async_event_iod;
>   	struct nvme_ctrl	ctrl;
>   
>   	struct nvmet_port	*port;
> +
> +	/* Must be last --ends in a flexible-array member. */
> +	struct nvme_loop_iod	async_event_iod;
>   };
>   
>   static inline struct nvme_loop_ctrl *to_loop_ctrl(struct nvme_ctrl *ctrl)
Re: [PATCH][next] nvme-loop: Avoid -Wflex-array-member-not-at-end warning
Posted by Christoph Hellwig 8 months ago
On Tue, Apr 15, 2025 at 06:20:03PM -0600, Gustavo A. R. Silva wrote:
> Hi all,
>
> Friendly ping: who can take this patch, please? :)

This will go into the 6.16 nvme branch as soon as it opens.
Re: [PATCH][next] nvme-loop: Avoid -Wflex-array-member-not-at-end warning
Posted by Gustavo A. R. Silva 7 months, 4 weeks ago

On 15/04/25 23:43, Christoph Hellwig wrote:
> On Tue, Apr 15, 2025 at 06:20:03PM -0600, Gustavo A. R. Silva wrote:
>> Hi all,
>>
>> Friendly ping: who can take this patch, please? :)
> 
> This will go into the 6.16 nvme branch as soon as it opens.

Awesome. :)

Thanks

-Gustavo
Re: [PATCH][next] nvme-loop: Avoid -Wflex-array-member-not-at-end warning
Posted by Sagi Grimberg 8 months ago
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Re: [PATCH][next] nvme-loop: Avoid -Wflex-array-member-not-at-end warning
Posted by Christoph Hellwig 8 months, 2 weeks ago
Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
Re: [PATCH][next] nvme-loop: Avoid -Wflex-array-member-not-at-end warning
Posted by Chaitanya Kulkarni 8 months, 3 weeks ago
On 3/28/25 07:25, Gustavo A. R. Silva wrote:
> -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 nvme_loop_iod` is a flexible structure --a structure
> that contains a flexible-array member.

Indeed :-

  18 struct nvme_loop_iod {
  19         struct nvme_request     nvme_req;
  20         struct nvme_command     cmd;
  21         struct nvme_completion  cqe;
  22         struct nvmet_req        req;
  23         struct nvme_loop_queue  *queue;
  24         struct work_struct      work;
  25         struct sg_table sg_table;
  26         struct scatterlist      first_sgl[];
  27 };


> Fix the following warning:
>
> drivers/nvme/target/loop.c:36:33: 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>

Looks good.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>

-ck