diff options
| author | Jan-Simon Möller <dl9pf@gmx.de> | 2012-07-02 06:54:28 -0400 |
|---|---|---|
| committer | Behan Webster <behanw@converseincode.com> | 2014-10-14 04:51:23 -0400 |
| commit | ea0e0de69fc413aa80dbf1ec1fb9702ea1b6faca (patch) | |
| tree | eaf66f02ff3614bb87a60e1ce17b8125ef67dc82 | |
| parent | ffb32e973eb5105ec55e0bbf2e77a1ea4a7a123a (diff) | |
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>
| -rw-r--r-- | lib/libcrc32c.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/lib/libcrc32c.c b/lib/libcrc32c.c index b3131f5cf8a2..6a08ce7d6adc 100644 --- a/lib/libcrc32c.c +++ b/lib/libcrc32c.c | |||
| @@ -41,20 +41,18 @@ static struct crypto_shash *tfm; | |||
| 41 | 41 | ||
| 42 | u32 crc32c(u32 crc, const void *address, unsigned int length) | 42 | u32 crc32c(u32 crc, const void *address, unsigned int length) |
| 43 | { | 43 | { |
| 44 | struct { | 44 | SHASH_DESC_ON_STACK(shash, tfm); |
| 45 | struct shash_desc shash; | 45 | u32 *ctx = (u32 *)shash_desc_ctx(shash); |
| 46 | char ctx[crypto_shash_descsize(tfm)]; | ||
| 47 | } desc; | ||
| 48 | int err; | 46 | int err; |
| 49 | 47 | ||
| 50 | desc.shash.tfm = tfm; | 48 | shash->tfm = tfm; |
| 51 | desc.shash.flags = 0; | 49 | shash->flags = 0; |
| 52 | *(u32 *)desc.ctx = crc; | 50 | *ctx = crc; |
| 53 | 51 | ||
| 54 | err = crypto_shash_update(&desc.shash, address, length); | 52 | err = crypto_shash_update(shash, address, length); |
| 55 | BUG_ON(err); | 53 | BUG_ON(err); |
| 56 | 54 | ||
| 57 | return *(u32 *)desc.ctx; | 55 | return *ctx; |
| 58 | } | 56 | } |
| 59 | 57 | ||
| 60 | EXPORT_SYMBOL(crc32c); | 58 | EXPORT_SYMBOL(crc32c); |
