From: behanw@converseincode.com Subject: [PATCH v4 03/12] crypto: LLVMLinux: Remove VLAIS from crypto/ccp/ccp-crypto-sha.c Date: Mon, 22 Sep 2014 21:42:08 -0700 Message-ID: <1411447337-22362-4-git-send-email-behanw@converseincode.com> References: <1411447337-22362-1-git-send-email-behanw@converseincode.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: akpm@linux-foundation.org, bruce.w.allan@intel.com, d.kasatkin@samsung.com, james.l.morris@oracle.com, john.griffin@intel.com, linux-btrfs@vger.kernel.org, linux-crypto@vger.kernel.org, linux-ima-devel@lists.sourceforge.net, linux-ima-user@lists.sourceforge.net, linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, linux-security-module@vger.kernel.org, neilb@suse.de, qat-linux@intel.com, serge@hallyn.com, thomas.lendacky@amd.com, zohar@linux.vnet.ibm.com, torvalds@linux-foundation.org, =?UTF-8?q?Jan-Simon=20M=C3=B6ller?= , Behan Webster To: agk@redhat.com, clm@fb.com, davem@davemloft.net, dm-devel@redhat.com, fabf@skynet.be, herbert@gondor.apana.org.au, jbacik@fb.com, snitzer@redhat.com, tadeusz.struk@intel.com Return-path: In-Reply-To: <1411447337-22362-1-git-send-email-behanw@converseincode.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-crypto.vger.kernel.org =46rom: Jan-Simon M=C3=B6ller Replaced the use of a Variable Length Array In Struct (VLAIS) with a C9= 9 compliant equivalent. This patch allocates the appropriate amount of me= mory 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=C3=B6ller Signed-off-by: Behan Webster Reviewed-by: Mark Charlebois Acked-by: Herbert Xu --- drivers/crypto/ccp/ccp-crypto-sha.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/crypto/ccp/ccp-crypto-sha.c b/drivers/crypto/ccp/c= cp-crypto-sha.c index 873f234..9653157 100644 --- a/drivers/crypto/ccp/ccp-crypto-sha.c +++ b/drivers/crypto/ccp/ccp-crypto-sha.c @@ -198,10 +198,9 @@ static int ccp_sha_setkey(struct crypto_ahash *tfm= , const u8 *key, { struct ccp_ctx *ctx =3D crypto_tfm_ctx(crypto_ahash_tfm(tfm)); struct crypto_shash *shash =3D ctx->u.sha.hmac_tfm; - struct { - struct shash_desc sdesc; - char ctx[crypto_shash_descsize(shash)]; - } desc; + + SHASH_DESC_ON_STACK(sdesc, shash); + unsigned int block_size =3D crypto_shash_blocksize(shash); unsigned int digest_size =3D crypto_shash_digestsize(shash); int i, ret; @@ -216,11 +215,11 @@ static int ccp_sha_setkey(struct crypto_ahash *tf= m, const u8 *key, =20 if (key_len > block_size) { /* Must hash the input key */ - desc.sdesc.tfm =3D shash; - desc.sdesc.flags =3D crypto_ahash_get_flags(tfm) & + sdesc->tfm =3D shash; + sdesc->flags =3D crypto_ahash_get_flags(tfm) & CRYPTO_TFM_REQ_MAY_SLEEP; =20 - ret =3D crypto_shash_digest(&desc.sdesc, key, key_len, + ret =3D crypto_shash_digest(sdesc, key, key_len, ctx->u.sha.key); if (ret) { crypto_ahash_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN); --=20 1.9.1