From patchwork Tue Sep 23 04:42:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Behan Webster X-Patchwork-Id: 37723 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f200.google.com (mail-we0-f200.google.com [74.125.82.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id BE000202A1 for ; Tue, 23 Sep 2014 04:49:08 +0000 (UTC) Received: by mail-we0-f200.google.com with SMTP id w62sf1435814wes.3 for ; Mon, 22 Sep 2014 21:49:08 -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=QnwI4a22HeOjch47p2Fy9+V2X8VIn2GWZ0BtMYKLqBw=; b=cH2ZfoufJz+3sTXyrOla622Pl5tInKugDOVmwanmtc/RePbIrzhSnZNFEibpPRaAXF DMjtkz+BX1DGZkRGwjaVw0oTxi0JHify7sBIjD1EJOPQM8FYJBmkrINdmXoZb6vXQEFu oMkUQ2TdY6buFDQKv6Z7Yqi2jDK1yz0Dzi/dYppOBgCT/2kwC52mugCP5oT35vnr5uBu N4DU00pUsBncjFTrtL4HDbrVpldbf7zns1xn3iI6bFEHl2uUHU+IgM8CQCcugNroi/x6 NleXsegZh7mW7LeKMIlBuhFt2vVDRoNPpu9WaFq28uJd7xs9qqiK/XCrRU7DR50fuSvm Zbvg== X-Gm-Message-State: ALoCoQlkX4qQmzTQCm5zLFBZw8CvDZAp+Id36HBSOU1irP1qTjvTiroEwgmKGNxgzTBOSls2MQvM X-Received: by 10.180.183.165 with SMTP id en5mr2627192wic.1.1411447747984; Mon, 22 Sep 2014 21:49:07 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.19.131 with SMTP id f3ls3288lae.38.gmail; Mon, 22 Sep 2014 21:49:07 -0700 (PDT) X-Received: by 10.152.7.193 with SMTP id l1mr27743769laa.62.1411447747671; Mon, 22 Sep 2014 21:49:07 -0700 (PDT) Received: from mail-la0-x229.google.com (mail-la0-x229.google.com [2a00:1450:4010:c03::229]) by mx.google.com with ESMTPS id q8si16948922laj.55.2014.09.22.21.49.07 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 22 Sep 2014 21:49:07 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::229 as permitted sender) client-ip=2a00:1450:4010:c03::229; Received: by mail-la0-f41.google.com with SMTP id s18so8042740lam.28 for ; Mon, 22 Sep 2014 21:49:07 -0700 (PDT) X-Received: by 10.152.179.226 with SMTP id dj2mr30147182lac.40.1411447747561; Mon, 22 Sep 2014 21:49:07 -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 of9csp352530lbb; Mon, 22 Sep 2014 21:49:06 -0700 (PDT) X-Received: by 10.68.235.105 with SMTP id ul9mr30104889pbc.3.1411447746037; Mon, 22 Sep 2014 21:49:06 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u3si18519811pdm.128.2014.09.22.21.49.05 for ; Mon, 22 Sep 2014 21:49:06 -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 S1754513AbaIWEtB (ORCPT + 27 others); Tue, 23 Sep 2014 00:49:01 -0400 Received: from mail-pa0-f41.google.com ([209.85.220.41]:33485 "EHLO mail-pa0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753633AbaIWEm6 (ORCPT ); Tue, 23 Sep 2014 00:42:58 -0400 Received: by mail-pa0-f41.google.com with SMTP id ey11so6513766pad.0 for ; Mon, 22 Sep 2014 21:42:58 -0700 (PDT) X-Received: by 10.66.121.166 with SMTP id ll6mr8025872pab.77.1411447377997; Mon, 22 Sep 2014 21:42:57 -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.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 22 Sep 2014 21:42:56 -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, Behan Webster Subject: [PATCH v4 05/12] crypto: LLVMLinux: Remove VLAIS from crypto/n2_core.c Date: Mon, 22 Sep 2014 21:42:10 -0700 Message-Id: <1411447337-22362-6-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-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::229 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: Behan Webster 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: Behan Webster Reviewed-by: Mark Charlebois Reviewed-by: Jan-Simon Möller Acked-by: Herbert Xu --- drivers/crypto/n2_core.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/crypto/n2_core.c b/drivers/crypto/n2_core.c index 7263c10..f8e3207 100644 --- a/drivers/crypto/n2_core.c +++ b/drivers/crypto/n2_core.c @@ -445,10 +445,7 @@ static int n2_hmac_async_setkey(struct crypto_ahash *tfm, const u8 *key, struct n2_hmac_ctx *ctx = crypto_ahash_ctx(tfm); struct crypto_shash *child_shash = ctx->child_shash; struct crypto_ahash *fallback_tfm; - struct { - struct shash_desc shash; - char ctx[crypto_shash_descsize(child_shash)]; - } desc; + SHASH_DESC_ON_STACK(shash, child_shash); int err, bs, ds; fallback_tfm = ctx->base.fallback_tfm; @@ -456,15 +453,15 @@ static int n2_hmac_async_setkey(struct crypto_ahash *tfm, const u8 *key, if (err) return err; - desc.shash.tfm = child_shash; - desc.shash.flags = crypto_ahash_get_flags(tfm) & + shash->tfm = child_shash; + shash->flags = crypto_ahash_get_flags(tfm) & CRYPTO_TFM_REQ_MAY_SLEEP; bs = crypto_shash_blocksize(child_shash); ds = crypto_shash_digestsize(child_shash); BUG_ON(ds > N2_HASH_KEY_MAX); if (keylen > bs) { - err = crypto_shash_digest(&desc.shash, key, keylen, + err = crypto_shash_digest(shash, key, keylen, ctx->hash_key); if (err) return err;