* [PATCH 0/8][next] Avoid a couple hundred -Wflex-array-member-not-at-end warnings
@ 2025-02-24 9:53 Gustavo A. R. Silva
2025-02-24 9:59 ` [PATCH 5/8][next] btrfs: Avoid " Gustavo A. R. Silva
0 siblings, 1 reply; 2+ messages in thread
From: Gustavo A. R. Silva @ 2025-02-24 9:53 UTC (permalink / raw)
To: Jens Axboe, Song Liu, Yu Kuai, Carlos Maiolino, Darrick J. Wong,
Gao Xiang, Chao Yu, Yue Hu, Jeffle Xu, Sandeep Dhavale,
Chris Mason, Josef Bacik, David Sterba, Christoph Hellwig,
Sagi Grimberg, Chaitanya Kulkarni, Coly Li, Kent Overstreet
Cc: linux-raid, linux-kernel, Gustavo A. R. Silva, linux-hardening,
linux-block, linux-xfs, linux-erofs, linux-btrfs, linux-nvme,
linux-bcache
This patch series aims to fix a couple hundred -Wflex-array-member-not-at-end
warnings by creating a new tagged struct `struct bio_hdr` within flexible
structure `struct bio`.
This new tagged struct will be used to fix problematic declarations
of middle-flex-arrays in composite structs, like these[1][2][3], for
instance.
[1] https://git.kernel.org/linus/a7e8997ae18c42d3
[2] https://git.kernel.org/linus/c1ddb29709e675ea
[3] https://git.kernel.org/linus/57be3d3562ca4aa6
Gustavo A. R. Silva (8):
block: blk_types.h: Use struct_group_tagged() in flex struct bio
md/raid5-ppl: Avoid -Wflex-array-member-not-at-end warning
xfs: Avoid -Wflex-array-member-not-at-end warnings
erofs: Avoid -Wflex-array-member-not-at-end warnings
btrfs: Avoid -Wflex-array-member-not-at-end warnings
nvme: target: Avoid -Wflex-array-member-not-at-end warnings
md/raid5: Avoid -Wflex-array-member-not-at-end warnings
bcache: Avoid -Wflex-array-member-not-at-end warnings
drivers/md/bcache/bcache.h | 4 +-
drivers/md/bcache/journal.c | 10 ++--
drivers/md/bcache/journal.h | 4 +-
drivers/md/bcache/super.c | 8 ++--
drivers/md/raid5-ppl.c | 8 ++--
drivers/md/raid5.c | 10 ++--
drivers/md/raid5.h | 2 +-
drivers/nvme/target/nvmet.h | 4 +-
drivers/nvme/target/passthru.c | 2 +-
drivers/nvme/target/zns.c | 2 +-
fs/btrfs/disk-io.c | 4 +-
fs/btrfs/volumes.h | 2 +-
fs/erofs/fileio.c | 25 ++++++----
fs/erofs/fscache.c | 13 +++---
fs/xfs/xfs_log.c | 15 +++---
fs/xfs/xfs_log_priv.h | 2 +-
include/linux/blk_types.h | 84 ++++++++++++++++++----------------
17 files changed, 107 insertions(+), 92 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 5/8][next] btrfs: Avoid -Wflex-array-member-not-at-end warnings
2025-02-24 9:53 [PATCH 0/8][next] Avoid a couple hundred -Wflex-array-member-not-at-end warnings Gustavo A. R. Silva
@ 2025-02-24 9:59 ` Gustavo A. R. Silva
0 siblings, 0 replies; 2+ messages in thread
From: Gustavo A. R. Silva @ 2025-02-24 9:59 UTC (permalink / raw)
To: Chris Mason, Josef Bacik, David Sterba
Cc: linux-btrfs, linux-kernel, Gustavo A. R. Silva, linux-hardening
-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@kernel.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
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-02-24 9:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-24 9:53 [PATCH 0/8][next] Avoid a couple hundred -Wflex-array-member-not-at-end warnings Gustavo A. R. Silva
2025-02-24 9:59 ` [PATCH 5/8][next] btrfs: Avoid " Gustavo A. R. Silva
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox