Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

crypto: LLVMLinux: Remove VLAIS usage from libcrc32c.c

Replaced the use of a Variable Length Array In Struct (VLAIS) with a C99
compliant equivalent. This patch allocates the appropriate amount of memory
using a char array using the SHASH_DESC_ON_STACK macro.

The new code can be compiled with both gcc and clang.

Signed-off-by: Jan-Simon Möller <dl9pf@gmx.de>
Signed-off-by: Behan Webster <behanw@converseincode.com>
Reviewed-by: Mark Charlebois <charlebm@gmail.com>
Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
Cc: pageexec@freemail.hu
Cc: "David S. Miller" <davem@davemloft.net>

authored by

Jan-Simon Möller and committed by
Behan Webster
ea0e0de6 ffb32e97

+7 -9
+7 -9
lib/libcrc32c.c
··· 41 41 42 42 u32 crc32c(u32 crc, const void *address, unsigned int length) 43 43 { 44 - struct { 45 - struct shash_desc shash; 46 - char ctx[crypto_shash_descsize(tfm)]; 47 - } desc; 44 + SHASH_DESC_ON_STACK(shash, tfm); 45 + u32 *ctx = (u32 *)shash_desc_ctx(shash); 48 46 int err; 49 47 50 - desc.shash.tfm = tfm; 51 - desc.shash.flags = 0; 52 - *(u32 *)desc.ctx = crc; 48 + shash->tfm = tfm; 49 + shash->flags = 0; 50 + *ctx = crc; 53 51 54 - err = crypto_shash_update(&desc.shash, address, length); 52 + err = crypto_shash_update(shash, address, length); 55 53 BUG_ON(err); 56 54 57 - return *(u32 *)desc.ctx; 55 + return *ctx; 58 56 } 59 57 60 58 EXPORT_SYMBOL(crc32c);