[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e6dfc07ceb44da02e9e012114a5ae44e4a9ec3d0.1739957534.git.gustavoars@kernel.org>
Date: Mon, 24 Feb 2025 20:30:45 +1030
From: "Gustavo A. R. Silva" <gustavoars@...nel.org>
To: Song Liu <song@...nel.org>, Yu Kuai <yukuai3@...wei.com>
Cc: linux-raid@...r.kernel.org, linux-kernel@...r.kernel.org,
"Gustavo A. R. Silva" <gustavoars@...nel.org>,
linux-hardening@...r.kernel.org
Subject: [PATCH 7/8][next] md/raid5: Avoid -Wflex-array-member-not-at-end
warnings
-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@...nel.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
Powered by blists - more mailing lists