From: "Gustavo A. R. Silva" <gustavoars@kernel.org>
To: Kent Overstreet <kent.overstreet@linux.dev>
Cc: linux-bcachefs@vger.kernel.org, linux-kernel@vger.kernel.org,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
linux-hardening@vger.kernel.org
Subject: [PATCH][next] bcachefs: Avoid -Wflex-array-member-not-at-end warning
Date: Tue, 29 Apr 2025 19:15:37 -0600 [thread overview]
Message-ID: <aBF5udHEHwWvmWJw@kspp> (raw)
-Wflex-array-member-not-at-end was introduced in GCC-14, and we are
getting ready to enable it, globally.
Use the `DEFINE_FLEX()` helper for on-stack definitions of a flexible
structure where the size of the flexible-array member is known at
compile-time, and refactor the rest of the code, accordingly.
So, with these changes, fix the following warning:
fs/bcachefs/disk_accounting.c:429:51: 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/bcachefs/disk_accounting.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/fs/bcachefs/disk_accounting.c b/fs/bcachefs/disk_accounting.c
index 7be71952425c..381e666679d2 100644
--- a/fs/bcachefs/disk_accounting.c
+++ b/fs/bcachefs/disk_accounting.c
@@ -425,24 +425,22 @@ int bch2_fs_replicas_usage_read(struct bch_fs *c, darray_char *usage)
percpu_down_read(&c->mark_lock);
darray_for_each(acc->k, i) {
- struct {
- struct bch_replicas_usage r;
- u8 pad[BCH_BKEY_PTRS_MAX];
- } u;
+ DEFINE_FLEX(struct bch_replicas_usage, u, r.devs, r.nr_devs,
+ BCH_BKEY_PTRS_MAX);
- if (!accounting_to_replicas(&u.r.r, i->pos))
+ if (!accounting_to_replicas(&u->r, i->pos))
continue;
u64 sectors;
bch2_accounting_mem_read_counters(acc, i - acc->k.data, §ors, 1, false);
- u.r.sectors = sectors;
+ u->sectors = sectors;
- ret = darray_make_room(usage, replicas_usage_bytes(&u.r));
+ ret = darray_make_room(usage, replicas_usage_bytes(u));
if (ret)
break;
- memcpy(&darray_top(*usage), &u.r, replicas_usage_bytes(&u.r));
- usage->nr += replicas_usage_bytes(&u.r);
+ memcpy(&darray_top(*usage), u, replicas_usage_bytes(u));
+ usage->nr += replicas_usage_bytes(u);
}
percpu_up_read(&c->mark_lock);
--
2.43.0
next reply other threads:[~2025-04-30 1:15 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-30 1:15 Gustavo A. R. Silva [this message]
2025-04-30 1:40 ` [PATCH][next] bcachefs: Avoid -Wflex-array-member-not-at-end warning Kent Overstreet
2025-04-30 18:27 ` Gustavo A. R. Silva
2025-04-30 18:32 ` Kent Overstreet
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=aBF5udHEHwWvmWJw@kspp \
--to=gustavoars@kernel.org \
--cc=kent.overstreet@linux.dev \
--cc=linux-bcachefs@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.