From patchwork Mon Sep 15 07:30:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Behan Webster X-Patchwork-Id: 37409 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D8161206A5 for ; Mon, 15 Sep 2014 07:38:15 +0000 (UTC) Received: by mail-la0-f71.google.com with SMTP id mc6sf1919107lab.6 for ; Mon, 15 Sep 2014 00:38:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type :content-transfer-encoding; bh=AQhhZMspL3BVWvzJCajLuUSlVNBOXZEIPkp/q2U02qQ=; b=buzQ5vfpUE/wxYX0Gc7DNaA+PLxA8/amY74LlGMAlQ/cvrHMy/LPgfl2nwQ0mFxCAk f1cESy6lD04CbUjsclqG92WgmT8rIqyxZwFi5uI0s78AP5xqLN/tcEnAGzBBQN46kHDm mxzg2Uz3X34MWTEBOu8MVqR+MKk+X3CUazuwvI39oEaj/5DLGOyii2vPx50vBj+b1vbU JnlnLO9DxJI1YV36ay0U+zR1aderQoljtY+LN247cuUJs/JcFvP/IAfWUZGqeEK0kIyo OqxJeo3GNdzTtC3yqRyfvjbegse8xSJ8SEBmRJVVR2HANnuiPNToAmJU8rHuqtQdl44E eYWg== X-Gm-Message-State: ALoCoQl5wLGaBszO8cdf6HESS6iTB8s/7npq1cehT+zP4D+xMVnZ0/1qz8HgUmarlwAOmoiqlmU0 X-Received: by 10.112.63.225 with SMTP id j1mr6776lbs.24.1410766693325; Mon, 15 Sep 2014 00:38:13 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.22.7 with SMTP id z7ls364528lae.79.gmail; Mon, 15 Sep 2014 00:38:13 -0700 (PDT) X-Received: by 10.112.198.34 with SMTP id iz2mr944903lbc.96.1410766692989; Mon, 15 Sep 2014 00:38:12 -0700 (PDT) Received: from mail-la0-x22d.google.com (mail-la0-x22d.google.com [2a00:1450:4010:c03::22d]) by mx.google.com with ESMTPS id g5si17551378lag.102.2014.09.15.00.38.12 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 15 Sep 2014 00:38:12 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::22d as permitted sender) client-ip=2a00:1450:4010:c03::22d; Received: by mail-la0-f45.google.com with SMTP id b17so4102456lan.18 for ; Mon, 15 Sep 2014 00:38:12 -0700 (PDT) X-Received: by 10.152.246.6 with SMTP id xs6mr26301014lac.56.1410766691523; Mon, 15 Sep 2014 00:38:11 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.130.169 with SMTP id of9csp162348lbb; Mon, 15 Sep 2014 00:38:10 -0700 (PDT) X-Received: by 10.66.129.139 with SMTP id nw11mr36042189pab.16.1410766689929; Mon, 15 Sep 2014 00:38:09 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cb1si20960061pbb.239.2014.09.15.00.38.09 for ; Mon, 15 Sep 2014 00:38:09 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753555AbaIOHiG (ORCPT + 27 others); Mon, 15 Sep 2014 03:38:06 -0400 Received: from mail-pa0-f43.google.com ([209.85.220.43]:51357 "EHLO mail-pa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753352AbaIOHb3 (ORCPT ); Mon, 15 Sep 2014 03:31:29 -0400 Received: by mail-pa0-f43.google.com with SMTP id fa1so5839917pad.30 for ; Mon, 15 Sep 2014 00:31:29 -0700 (PDT) X-Received: by 10.70.138.102 with SMTP id qp6mr11262330pdb.127.1410766288958; Mon, 15 Sep 2014 00:31:28 -0700 (PDT) Received: from galdor.edimax.com ([38.126.120.10]) by mx.google.com with ESMTPSA id cz1sm1011611pdb.85.2014.09.15.00.31.25 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Sep 2014 00:31:27 -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 v3 03/12] crypto: LLVMLinux: Remove VLAIS from crypto/ccp/ccp-crypto-sha.c Date: Mon, 15 Sep 2014 00:30:25 -0700 Message-Id: <1410766234-1634-4-git-send-email-behanw@converseincode.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1410766234-1634-1-git-send-email-behanw@converseincode.com> References: <1410766234-1634-1-git-send-email-behanw@converseincode.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Original-Sender: behanw@converseincode.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::22d as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=neutral (body hash did not verify) header.i=@ Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 --- 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);