mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Gustavo A. R. Silva" <gustavoars@kernel.org>
To: Song Liu <song@kernel.org>, Yu Kuai <yukuai3@huawei.com>
Cc: linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	linux-hardening@vger.kernel.org
Subject: [PATCH 7/8][next] md/raid5: Avoid -Wflex-array-member-not-at-end warnings
Date: Mon, 24 Feb 2025 20:30:45 +1030	[thread overview]
Message-ID: <e6dfc07ceb44da02e9e012114a5ae44e4a9ec3d0.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 10 of the following warnings:

drivers/md/raid5.h:262:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/md/raid5.h:262:38: 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/md/raid5.c | 10 +++++-----
 drivers/md/raid5.h |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 5c79429acc64..76981d8cbc5d 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -1178,8 +1178,8 @@ static void ops_run_io(struct stripe_head *sh, struct stripe_head_state *s)
 
 again:
 		dev = &sh->dev[i];
-		bi = &dev->req;
-		rbi = &dev->rreq; /* For writing to replacement */
+		bi = container_of(&dev->req, struct bio, __hdr);
+		rbi = container_of(&dev->rreq, struct bio, __hdr); /* For writing to replacement */
 
 		rdev = conf->disks[i].rdev;
 		rrdev = conf->disks[i].replacement;
@@ -2720,7 +2720,7 @@ static void raid5_end_read_request(struct bio * bi)
 	sector_t s;
 
 	for (i=0 ; i<disks; i++)
-		if (bi == &sh->dev[i].req)
+		if (bi == container_of(&sh->dev[i].req, struct bio, __hdr))
 			break;
 
 	pr_debug("end_read_request %llu/%d, count: %d, error %d.\n",
@@ -2848,11 +2848,11 @@ static void raid5_end_write_request(struct bio *bi)
 	int replacement = 0;
 
 	for (i = 0 ; i < disks; i++) {
-		if (bi == &sh->dev[i].req) {
+		if (bi == container_of(&sh->dev[i].req, struct bio, __hdr)) {
 			rdev = conf->disks[i].rdev;
 			break;
 		}
-		if (bi == &sh->dev[i].rreq) {
+		if (bi == container_of(&sh->dev[i].rreq, struct bio, __hdr)) {
 			rdev = conf->disks[i].replacement;
 			if (rdev)
 				replacement = 1;
diff --git a/drivers/md/raid5.h b/drivers/md/raid5.h
index eafc6e9ed6ee..3df59302e953 100644
--- a/drivers/md/raid5.h
+++ b/drivers/md/raid5.h
@@ -259,7 +259,7 @@ struct stripe_head {
 		/* rreq and rvec are used for the replacement device when
 		 * writing data to both devices.
 		 */
-		struct bio	req, rreq;
+		struct bio_hdr	req, rreq;
 		struct bio_vec	vec, rvec;
 		struct page	*page, *orig_page;
 		unsigned int    offset;     /* offset of the page */
-- 
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 ` [PATCH 6/8][next] nvme: target: " Gustavo A. R. Silva
2025-02-24 14:19   ` Christoph Hellwig
2025-02-25  1:51     ` Gustavo A. R. Silva
2025-02-24 10:00 ` Gustavo A. R. Silva [this message]
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=e6dfc07ceb44da02e9e012114a5ae44e4a9ec3d0.1739957534.git.gustavoars@kernel.org \
    --to=gustavoars@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=song@kernel.org \
    --cc=yukuai3@huawei.com \
    /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®