[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3c3310a23caf3d78ae62c85c9476d5dfe4a1f871.1739957534.git.gustavoars@kernel.org>
Date: Mon, 24 Feb 2025 20:29:34 +1030
From: "Gustavo A. R. Silva" <gustavoars@...nel.org>
To: Chris Mason <clm@...com>, Josef Bacik <josef@...icpanda.com>,
David Sterba <dsterba@...e.com>
Cc: linux-btrfs@...r.kernel.org, linux-kernel@...r.kernel.org,
"Gustavo A. R. Silva" <gustavoars@...nel.org>,
linux-hardening@...r.kernel.org
Subject: [PATCH 5/8][next] btrfs: 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 member 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 32 of the following warnings:
fs/btrfs/volumes.h:178:20: 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>
---
fs/btrfs/disk-io.c | 4 ++--
fs/btrfs/volumes.h | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index f09db62e61a1..2fbaaa9ab3e3 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -3963,7 +3963,7 @@ static void btrfs_end_empty_barrier(struct bio *bio)
*/
static void write_dev_flush(struct btrfs_device *device)
{
- struct bio *bio = &device->flush_bio;
+ struct bio *bio = container_of(&device->flush_bio, struct bio, __hdr);
device->last_flush_error = BLK_STS_OK;
@@ -3982,7 +3982,7 @@ static void write_dev_flush(struct btrfs_device *device)
*/
static bool wait_dev_flush(struct btrfs_device *device)
{
- struct bio *bio = &device->flush_bio;
+ struct bio *bio = container_of(&device->flush_bio, struct bio, __hdr);
if (!test_and_clear_bit(BTRFS_DEV_STATE_FLUSH_SENT, &device->dev_state))
return false;
diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h
index 120f65e21eeb..6eb55103b3d1 100644
--- a/fs/btrfs/volumes.h
+++ b/fs/btrfs/volumes.h
@@ -175,7 +175,7 @@ struct btrfs_device {
u64 commit_bytes_used;
/* Bio used for flushing device barriers */
- struct bio flush_bio;
+ struct bio_hdr flush_bio;
struct completion flush_wait;
/* per-device scrub information */
--
2.43.0
Powered by blists - more mailing lists