From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: Coly Li <colyli@fnnas.com>
Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
linux-bcache@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-hardening@vger.kernel.org
Subject: Re: [PATCH][next] bcache: Avoid -Wflex-array-member-not-at-end warning
Date: Mon, 24 Nov 2025 17:34:18 +0900 [thread overview]
Message-ID: <da074ecc-e688-493e-bd63-76cd88e1ff0f@embeddedor.com> (raw)
In-Reply-To: <fbef561c-c470-47d0-9bc0-c565e10b2856@embeddedor.com>
On 11/13/25 13:24, Gustavo A. R. Silva wrote:
>
>> I see. I take this patch, with the above complain...
>
> Thanks, Coly.
BTW, I'm currently looking into the following struct, and I wonder if
it's okay to move struct bkey end; to the end.
drivers/md/bcache/bset.h:157:struct bset_tree {
drivers/md/bcache/bset.h-158- /*
drivers/md/bcache/bset.h-159- * We construct a binary tree in an array as if the array
drivers/md/bcache/bset.h-160- * started at 1, so that things line up on the same cachelines
drivers/md/bcache/bset.h-161- * better: see comments in bset.c at cacheline_to_bkey() for
drivers/md/bcache/bset.h-162- * details
drivers/md/bcache/bset.h-163- */
drivers/md/bcache/bset.h-164-
drivers/md/bcache/bset.h-165- /* size of the binary tree and prev array */
drivers/md/bcache/bset.h-166- unsigned int size;
drivers/md/bcache/bset.h-167-
drivers/md/bcache/bset.h-168- /* function of size - precalculated for to_inorder() */
drivers/md/bcache/bset.h-169- unsigned int extra;
drivers/md/bcache/bset.h-170-
drivers/md/bcache/bset.h-171- /* copy of the last key in the set */
drivers/md/bcache/bset.h-172- struct bkey end;
drivers/md/bcache/bset.h-173- struct bkey_float *tree;
drivers/md/bcache/bset.h-174-
drivers/md/bcache/bset.h-175- /*
drivers/md/bcache/bset.h-176- * The nodes in the bset tree point to specific keys - this
drivers/md/bcache/bset.h-177- * array holds the sizes of the previous key.
drivers/md/bcache/bset.h-178- *
drivers/md/bcache/bset.h-179- * Conceptually it's a member of struct bkey_float, but we want
drivers/md/bcache/bset.h-180- * to keep bkey_float to 4 bytes and prev isn't used in the fast
drivers/md/bcache/bset.h-181- * path.
drivers/md/bcache/bset.h-182- */
drivers/md/bcache/bset.h-183- uint8_t *prev;
drivers/md/bcache/bset.h-184-
drivers/md/bcache/bset.h-185- /* The actual btree node, with pointers to each sorted set */
drivers/md/bcache/bset.h-186- struct bset *data;
drivers/md/bcache/bset.h-187-};
Something like this:
diff --git a/drivers/md/bcache/bset.h b/drivers/md/bcache/bset.h
index 6ee2c6a506a2..e6daeb0edc02 100644
--- a/drivers/md/bcache/bset.h
+++ b/drivers/md/bcache/bset.h
@@ -169,7 +169,6 @@ struct bset_tree {
unsigned int extra;
/* copy of the last key in the set */
- struct bkey end;
struct bkey_float *tree;
/*
@@ -184,6 +183,9 @@ struct bset_tree {
/* The actual btree node, with pointers to each sorted set */
struct bset *data;
+
+ /* Must be last as it ends in a flexible-array member. */
+ struct bkey end;
};
This would fix 15 more -Wflex-array-member-not-at-end warnings.
Thanks
-Gustavo
prev parent reply other threads:[~2025-11-24 8:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-10 10:58 [PATCH][next] bcache: Avoid -Wflex-array-member-not-at-end warning Gustavo A. R. Silva
2025-11-11 13:17 ` Coly Li
2025-11-11 13:28 ` Gustavo A. R. Silva
2025-11-11 13:43 ` Coly Li
2025-11-13 4:24 ` Gustavo A. R. Silva
2025-11-24 8:34 ` Gustavo A. R. Silva [this message]
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=da074ecc-e688-493e-bd63-76cd88e1ff0f@embeddedor.com \
--to=gustavo@embeddedor.com \
--cc=akpm@linux-foundation.org \
--cc=colyli@fnnas.com \
--cc=gustavoars@kernel.org \
--cc=linux-bcache@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.