[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <da074ecc-e688-493e-bd63-76cd88e1ff0f@embeddedor.com>
Date: Mon, 24 Nov 2025 17:34:18 +0900
From: "Gustavo A. R. Silva" <gustavo@...eddedor.com>
To: Coly Li <colyli@...as.com>
Cc: "Gustavo A. R. Silva" <gustavoars@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>, linux-bcache@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-hardening@...r.kernel.org
Subject: Re: [PATCH][next] bcache: Avoid -Wflex-array-member-not-at-end
warning
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
Powered by blists - more mailing lists