mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Gustavo A. R. Silva" <gustavoars@kernel.org>
To: Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>,
	Chaitanya Kulkarni <kch@nvidia.com>
Cc: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	linux-hardening@vger.kernel.org
Subject: [PATCH 6/8][next] nvme: target: Avoid -Wflex-array-member-not-at-end warnings
Date: Mon, 24 Feb 2025 20:30:10 +1030	[thread overview]
Message-ID: <ef7a6920384ab2f8f83c0f630f94edc73cd65997.1739957534.git.gustavoars@kernel.org> (raw)
In-Reply-To: <cover.1739957534.git.gustavoars@kernel.org>

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

Change the type of the middle struct members currently causing trouble
from `struct bio` to `struct bio_hdr`.

We also use `container_of()` whenever we need to retrieve a pointer to
the flexible structure `struct bio`, through which we can access the
flexible-array member in it, if necessary.

With these changes fix 38 of the following warnings:

drivers/nvme/target/nvmet.h:455:49: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/nvme/target/nvmet.h:462:49: 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/nvmet.h    | 4 ++--
 drivers/nvme/target/passthru.c | 2 +-
 drivers/nvme/target/zns.c      | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
index 4be8d22d2d8d..13ee8026d3d8 100644
--- a/drivers/nvme/target/nvmet.h
+++ b/drivers/nvme/target/nvmet.h
@@ -452,14 +452,14 @@ struct nvmet_req {
 			struct work_struct      work;
 		} f;
 		struct {
-			struct bio		inline_bio;
+			struct bio_hdr		inline_bio;
 			struct request		*rq;
 			struct work_struct      work;
 			bool			use_workqueue;
 		} p;
 #ifdef CONFIG_BLK_DEV_ZONED
 		struct {
-			struct bio		inline_bio;
+			struct bio_hdr		inline_bio;
 			struct work_struct	zmgmt_work;
 		} z;
 #endif /* CONFIG_BLK_DEV_ZONED */
diff --git a/drivers/nvme/target/passthru.c b/drivers/nvme/target/passthru.c
index 26e2907ce8bb..bff52252ffb9 100644
--- a/drivers/nvme/target/passthru.c
+++ b/drivers/nvme/target/passthru.c
@@ -268,7 +268,7 @@ static int nvmet_passthru_map_sg(struct nvmet_req *req, struct request *rq)
 		return -EINVAL;
 
 	if (nvmet_use_inline_bvec(req)) {
-		bio = &req->p.inline_bio;
+		bio = container_of(&req->p.inline_bio, struct bio, __hdr);
 		bio_init(bio, NULL, req->inline_bvec,
 			 ARRAY_SIZE(req->inline_bvec), req_op(rq));
 	} else {
diff --git a/drivers/nvme/target/zns.c b/drivers/nvme/target/zns.c
index 29a60fabfcc8..afedbd984d39 100644
--- a/drivers/nvme/target/zns.c
+++ b/drivers/nvme/target/zns.c
@@ -570,7 +570,7 @@ void nvmet_bdev_execute_zone_append(struct nvmet_req *req)
 	}
 
 	if (nvmet_use_inline_bvec(req)) {
-		bio = &req->z.inline_bio;
+		bio = container_of(&req->z.inline_bio, struct bio, __hdr);
 		bio_init(bio, req->ns->bdev, req->inline_bvec,
 			 ARRAY_SIZE(req->inline_bvec), opf);
 	} else {
-- 
2.43.0


  parent reply	other threads:[~2025-02-24 10:00 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-24  9:53 [PATCH 0/8][next] Avoid a couple hundred " Gustavo A. R. Silva
2025-02-24  9:55 ` [PATCH 1/8][next] block: blk_types.h: Use struct_group_tagged() in flex struct bio Gustavo A. R. Silva
2025-02-24 16:39   ` Christoph Hellwig
2025-02-24  9:56 ` [PATCH 2/8][next] md/raid5-ppl: Avoid -Wflex-array-member-not-at-end warning Gustavo A. R. Silva
2025-02-24  9:57 ` [PATCH 3/8][next] xfs: Avoid -Wflex-array-member-not-at-end warnings Gustavo A. R. Silva
2025-02-24 19:12   ` Darrick J. Wong
2025-02-24 21:45   ` Dave Chinner
2025-02-24  9:58 ` [PATCH 4/8][next] erofs: " Gustavo A. R. Silva
2025-02-24  9:59 ` [PATCH 5/8][next] btrfs: " Gustavo A. R. Silva
2025-02-24 10:00 ` Gustavo A. R. Silva [this message]
2025-02-24 14:19   ` [PATCH 6/8][next] nvme: target: " Christoph Hellwig
2025-02-25  1:51     ` Gustavo A. R. Silva
2025-02-24 10:00 ` [PATCH 7/8][next] md/raid5: " Gustavo A. R. Silva
2025-02-24 10:01 ` [PATCH 8/8][next] bcache: " Gustavo A. R. Silva
2025-02-24 14:04   ` Coly Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ef7a6920384ab2f8f83c0f630f94edc73cd65997.1739957534.git.gustavoars@kernel.org \
    --to=gustavoars@kernel.org \
    --cc=hch@lst.de \
    --cc=kch@nvidia.com \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®