]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
jbd2: remove VLAIS usage from JBD2 code
authorBehan Webster <behanw@converseincode.com>
Thu, 8 Nov 2012 16:24:46 +0000 (11:24 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 8 Nov 2012 16:24:46 +0000 (11:24 -0500)
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

Signed-off-by: Mark Charlebois <charlebm@gmail.com>
Signed-off-by: Behan Webster <behanw@converseincode.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
include/linux/jbd2.h

index de7f55682088ebdbfd2b5c8681f85d4cde3c899d..1be23d9fdacb5151a6af6f8b30b2086e50c50bb1 100644 (file)
@@ -1302,15 +1302,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;