ext4: avoid dozens of -Wflex-array-member-not-at-end warnings
PATCH 1/1 ext4: avoid dozens of -Wflex-array-member-not-at-end warnings
-Wflex-array-member-not-at-end was introduced in GCC-14, and we are getting ready to enable it, globally.
Use the DEFINE_RAW_FLEX() helper for an on-stack definition of a flexible structure (struct shash_desc) where the size of the flexible-array member (__ctx) is known at compile-time, and refactor the rest of the code, accordingly.
So, with these changes, fix 38 of the following warnings:
fs/ext4/ext4.h:2471:35: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
---
Worth mentioning is that this issue is pretty much the same as this other one:
https://git.kernel.org/linus/2bd9077b6261
Thanks!
fs/ext4/ext4.h | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
fs/ext4/ext4.h +11 -9
@@ -2460,22 +2460,24 @@ static inline __le16 ext4_rec_len_to_disk(unsigned len, unsigned blocksize)#define DX_HASH_SIPHASH 6#define DX_HASH_LAST DX_HASH_SIPHASH +#define EXT4_MAX_CHECKSUM_SIZE 4 +static inline u32 ext4_chksum (struct ext4_sb_info *sbi,u32 crc,const void *address,unsigned int length) { -struct { -struct shash_desc shash; -char ctx[4 ]; - } desc; + DEFINE_RAW_FLEX(struct shash_desc, desc, __ctx, +DIV_ROUND_UP (EXT4_MAX_CHECKSUM_SIZE , + sizeof(*((struct shash_desc *)0)->__ctx))); -BUG_ON (crypto_shash_descsize (sbi->s_chksum_driver)!=sizeof (desc.ctx)); +BUG_ON (crypto_shash_descsize (sbi->s_chksum_driver) != +EXT4_MAX_CHECKSUM_SIZE ); - desc.shash.tfm = sbi->s_chksum_driver; - *(u32 *)desc.ctx = crc; + desc->tfm = sbi->s_chksum_driver; + *(u32 *)desc->__ctx = crc; -BUG_ON (crypto_shash_update (&desc.shash, address, length)); +BUG_ON (crypto_shash_update (desc, address, length)); -return *(u32 *)desc.ctx; +return *(u32 *)desc->__ctx; }#ifdef __KERNEL__
Signature · 1 line
2.43.0
Theodore Ts'o
maintainerQuoted 8 lines · Gustavo A. R. Silva
-Wflex-array-member-not-at-end was introduced in GCC-14, and we are getting ready to enable it, globally.
Use the
DEFINE_RAW_FLEX()helper for an on-stack definition of a flexible structure (struct shash_desc) where the size of the flexible-array member (__ctx) is known at compile-time, and refactor the rest of the code, accordingly.
Quoted 5 lines
So, with these changes, fix 38 of the following warnings:
fs/ext4/ext4.h:2471:35: 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 <[email protected]>
Thanks, for this patch! It appears that this patch has since been obviated by Eric Bigger's commit f2b4fa19647e (" ext4: switch to using the crc32c library"), which landed during this merge window, so this patch should not be needed.
- Ted
Quoted 5 lines
Thanks, for this patch! It appears that this patch has since been obviated by Eric Bigger's commit
f2b4fa19647e(" ext4: switch to using the crc32c library"), which landed during this merge window, so this patch should not be needed.
Oh, nice! Thanks for letting me know. :)
-Gustavo
Theodore Ts'o
maintainerQuoted 7 lines · Gustavo A. R. Silva
Quoted 5 lines
Thanks, for this patch! It appears that this patch has since been obviated by Eric Bigger's commit
f2b4fa19647e(" ext4: switch to using the crc32c library"), which landed during this merge window, so this patch should not be needed.Oh, nice! Thanks for letting me know. :)
Yeah, apologiues for not getting back to you earlier. Between travel and the holidays, I didn't have time to process patches for the merge window which just closed, so I'm not catching up on the backlog.
In any case, Eric's commit is in 6.14-rc1, so you should see the flex array warnings from the ext4 checksum inline function.
- Ted