From: colyli@fnnas.com
To: axboe@kernel.dk
Cc: linux-bcache@vger.kernel.org, linux-block@vger.kernel.org,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
Coly Li <colyli@fnnas.com>
Subject: [PATCH 9/9] bcache: Avoid -Wflex-array-member-not-at-end warning
Date: Thu, 13 Nov 2025 13:36:30 +0800 [thread overview]
Message-ID: <20251113053630.54218-10-colyli@fnnas.com> (raw)
In-Reply-To: <20251113053630.54218-1-colyli@fnnas.com>
From: "Gustavo A. R. Silva" <gustavoars@kernel.org>
-Wflex-array-member-not-at-end was introduced in GCC-14, and we are
getting ready to enable it, globally.
Use the new TRAILING_OVERLAP() helper to fix the following warning:
drivers/md/bcache/bset.h:330:27: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
This helper creates a union between a flexible-array member (FAM) and a
set of MEMBERS that would otherwise follow it.
This overlays the trailing MEMBER struct btree_iter_set stack_data[MAX_BSETS];
onto the FAM struct btree_iter::data[], while keeping the FAM and the start
of MEMBER aligned.
The static_assert() ensures this alignment remains, and it's
intentionally placed immediately after the corresponding structures --no
blank line in between.
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Coly Li <colyli@fnnas.com>
---
drivers/md/bcache/bset.h | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/md/bcache/bset.h b/drivers/md/bcache/bset.h
index 011f6062c4c0..6ee2c6a506a2 100644
--- a/drivers/md/bcache/bset.h
+++ b/drivers/md/bcache/bset.h
@@ -327,9 +327,13 @@ struct btree_iter {
/* Fixed-size btree_iter that can be allocated on the stack */
struct btree_iter_stack {
- struct btree_iter iter;
- struct btree_iter_set stack_data[MAX_BSETS];
+ /* Must be last as it ends in a flexible-array member. */
+ TRAILING_OVERLAP(struct btree_iter, iter, data,
+ struct btree_iter_set stack_data[MAX_BSETS];
+ );
};
+static_assert(offsetof(struct btree_iter_stack, iter.data) ==
+ offsetof(struct btree_iter_stack, stack_data));
typedef bool (*ptr_filter_fn)(struct btree_keys *b, const struct bkey *k);
--
2.47.3
next prev parent reply other threads:[~2025-11-13 5:36 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-13 5:36 [PATCH 0/9] bcache patches for Linux 6.19 colyli
2025-11-13 5:36 ` [PATCH 1/9] bcache: get rid of discard code from journal colyli
2025-11-13 5:36 ` [PATCH 2/9] bcache: remove discard code from alloc.c colyli
2025-11-13 5:36 ` [PATCH 3/9] bcache: drop discard sysfs interface colyli
2025-11-13 5:36 ` [PATCH 4/9] bcache: remove discard sysfs interface document colyli
2025-11-13 5:36 ` [PATCH 5/9] bcache: reduce gc latency by processing less nodes and sleep less time colyli
2026-07-17 0:50 ` Robert Pang
2026-07-18 4:20 ` Coly Li
2026-07-21 18:55 ` Robert Pang
2026-08-06 8:36 ` Coly Li
2026-08-10 21:38 ` Robert Pang
2025-11-13 5:36 ` [PATCH 6/9] bcache: remove redundant __GFP_NOWARN colyli
2025-11-13 5:36 ` [PATCH 7/9] bcache: replace use of system_wq with system_percpu_wq colyli
2025-11-13 5:36 ` [PATCH 8/9] bcache: WQ_PERCPU added to alloc_workqueue users colyli
2025-11-13 5:36 ` colyli [this message]
2025-11-13 16:26 ` [PATCH 0/9] bcache patches for Linux 6.19 Jens Axboe
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=20251113053630.54218-10-colyli@fnnas.com \
--to=colyli@fnnas.com \
--cc=axboe@kernel.dk \
--cc=gustavoars@kernel.org \
--cc=linux-bcache@vger.kernel.org \
--cc=linux-block@vger.kernel.org \
/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