From patchwork Tue Sep 23 04:42:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Behan Webster X-Patchwork-Id: 4953081 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 33A2CBEEA5 for ; Tue, 23 Sep 2014 04:46:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5E16B201D3 for ; Tue, 23 Sep 2014 04:46:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 653A7201C0 for ; Tue, 23 Sep 2014 04:46:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753739AbaIWEnI (ORCPT ); Tue, 23 Sep 2014 00:43:08 -0400 Received: from mail-pa0-f41.google.com ([209.85.220.41]:46169 "EHLO mail-pa0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753540AbaIWEmx (ORCPT ); Tue, 23 Sep 2014 00:42:53 -0400 Received: by mail-pa0-f41.google.com with SMTP id ey11so6546435pad.28 for ; Mon, 22 Sep 2014 21:42:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=converseincode.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=FYPaDbsHUNLXDj3NFx4+CfRiKrUnRXwoWcLJhsD1cmI=; b=IaRQis+XcvsHPEbODliN4Eqp7DBQv8wl590Od/VYjlLxf97q30HalOMQfA/prPsoqT eOduLKq2ye1iBXsqDl5X496eQF5lhKZFi+q8J0KiG/52H81d0g8hiES/E/IjwpPKNvGw +DSLJk0uHpktKa4KuEgJXUTTM9PW5BPl+WFN8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=FYPaDbsHUNLXDj3NFx4+CfRiKrUnRXwoWcLJhsD1cmI=; b=F+YdEc9YhV8srtFku/loiF+zPMP8w0T6aaNd2jqt5cWx0iiSGBP3N3WTMM7oGmo3Zy LQXNxWMvoqljEOTmcMg4FafV2G7DZky/OEBzE7rCC03BkoaQDJWhCIOnpZi+uzLfsdjM sLUrSMbK8aZwfHnvsvAiyBtApLACw6hxUsyQoDTZVC6mf6V9arYsRSZLDaJJIu72dZTL YK4K4+2D3CmgeND23JDNSrJG8LhTANd5zA/sz9NqlsfLJShXeiTWPf9SS0HIHUhqmF7E vDAO+RrUz0U80KkdN2it/G9tTn29kupLmT7ddDSNyb57PpZUpt+ht5otFntQdsursFZD YlUg== X-Gm-Message-State: ALoCoQkUNNS3TunY8eNjHgILLABlJZ0f0cCV0H8FyXU2BsMP8ZGf/+BOhnDgd5+hU3wQIVYdQ1m/ X-Received: by 10.70.130.16 with SMTP id oa16mr36670579pdb.32.1411447372516; Mon, 22 Sep 2014 21:42:52 -0700 (PDT) Received: from galdor.websterwood.com (S0106dc9fdb80cffd.gv.shawcable.net. [96.50.97.138]) by mx.google.com with ESMTPSA id j13sm10774808pbq.42.2014.09.22.21.42.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 22 Sep 2014 21:42:51 -0700 (PDT) From: behanw@converseincode.com 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 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 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> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1411447337-22362-1-git-send-email-behanw@converseincode.com> References: <1411447337-22362-1-git-send-email-behanw@converseincode.com> MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jan-Simon Möller 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 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/ccp-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 = crypto_tfm_ctx(crypto_ahash_tfm(tfm)); struct crypto_shash *shash = 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 = crypto_shash_blocksize(shash); unsigned int digest_size = crypto_shash_digestsize(shash); int i, ret; @@ -216,11 +215,11 @@ static int ccp_sha_setkey(struct crypto_ahash *tfm, const u8 *key, if (key_len > block_size) { /* Must hash the input key */ - desc.sdesc.tfm = shash; - desc.sdesc.flags = crypto_ahash_get_flags(tfm) & + sdesc->tfm = shash; + sdesc->flags = crypto_ahash_get_flags(tfm) & CRYPTO_TFM_REQ_MAY_SLEEP; - ret = crypto_shash_digest(&desc.sdesc, key, key_len, + ret = crypto_shash_digest(sdesc, key, key_len, ctx->u.sha.key); if (ret) { crypto_ahash_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN);