Skip to content

Commit 2bd9077

Browse files
GustavoARSilvatytso
authored andcommitted
jbd2: 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 this, fix 77 of the following warnings: include/linux/jbd2.h:1800: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]> Reviewed-by: Jan Kara <[email protected]> Link: https://patch.msgid.link/ZyU94w0IALVhc9Jy@kspp Signed-off-by: Theodore Ts'o <[email protected]>
1 parent 6a0c588 commit 2bd9077

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

include/linux/jbd2.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,22 +1796,21 @@ static inline unsigned long jbd2_log_space_left(journal_t *journal)
17961796
static inline u32 jbd2_chksum(journal_t *journal, u32 crc,
17971797
const void *address, unsigned int length)
17981798
{
1799-
struct {
1800-
struct shash_desc shash;
1801-
char ctx[JBD_MAX_CHECKSUM_SIZE];
1802-
} desc;
1799+
DEFINE_RAW_FLEX(struct shash_desc, desc, __ctx,
1800+
DIV_ROUND_UP(JBD_MAX_CHECKSUM_SIZE,
1801+
sizeof(*((struct shash_desc *)0)->__ctx)));
18031802
int err;
18041803

18051804
BUG_ON(crypto_shash_descsize(journal->j_chksum_driver) >
18061805
JBD_MAX_CHECKSUM_SIZE);
18071806

1808-
desc.shash.tfm = journal->j_chksum_driver;
1809-
*(u32 *)desc.ctx = crc;
1807+
desc->tfm = journal->j_chksum_driver;
1808+
*(u32 *)desc->__ctx = crc;
18101809

1811-
err = crypto_shash_update(&desc.shash, address, length);
1810+
err = crypto_shash_update(desc, address, length);
18121811
BUG_ON(err);
18131812

1814-
return *(u32 *)desc.ctx;
1813+
return *(u32 *)desc->__ctx;
18151814
}
18161815

18171816
/* Return most recent uncommitted transaction */

0 commit comments

Comments
 (0)