Skip to contentSkip to conversation

Remove VLAIS usage from JBD2 code

PATCH New Behan Webster 1 participant 1 message Oct 30, 2012 Journalling layer for block devices (JBD2)

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Remove VLAIS usage from JBD2 code

From: Mark Charlebois <[email protected]>

The use of variable length arrays in structs (VLAIS) in the Linux Kernel code precludes the use of compilers which don't implement VLAIS (for instance the Clang compiler). Since ctx is always a 32-bit CRC, hard coding a size of 4 bytes accomplishes the same thing without the use of VLAIS. This is the same technique already employed in fs/ext4/ext4.h

[Used a #define to specify the fixed size of ctx]
---
 include/linux/jbd2.h |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
include/linux/jbd2.h +7 -1
index 3efc43f..93b323f 100644
@@ -1303,15 +1303,21 @@ static inline int jbd_space_needed(journal_t *journal)
 
 extern int jbd_blocks_per_page(struct inode *inode);
 
+/* JBD uses a CRC32 checksum */
+#define JBD_MAX_CHECKSUM_SIZE 4
+
 static inline u32 jbd2_chksum(journal_t *journal, u32 crc,
 			      const void *address, unsigned int length)
 {
 	struct {
 		struct shash_desc shash;
-		char ctx[crypto_shash_descsize(journal->j_chksum_driver)];
+		char ctx[JBD_MAX_CHECKSUM_SIZE];
 	} desc;
 	int err;
 
+	BUG_ON(crypto_shash_descsize(journal->j_chksum_driver) >
+		JBD_MAX_CHECKSUM_SIZE);
+
 	desc.shash.tfm = journal->j_chksum_driver;
 	desc.shash.flags = 0;
 	*(u32 *)desc.ctx = crc;
Signature · 1 line
1.7.9.5