From patchwork Tue Sep 23 04:42:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Behan Webster X-Patchwork-Id: 37722 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 51E7C202A1 for ; Tue, 23 Sep 2014 04:48:26 +0000 (UTC) Received: by mail-la0-f71.google.com with SMTP id q1sf3925923lam.10 for ; Mon, 22 Sep 2014 21:48:25 -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=kBEOWTudcw4a+5Z3ZhrJDX/sgA506i0tqXtx52vRLw4=; b=kjKaGWlg95OiQdHLmHE38gYqLAXMbcnI8IPdWJhn56aID15mzKAjgXegHuthpPGuIN UG//Ezs/nZvFbh6S+VZwl1VJKkpoPIAkEHeytACz5SMzsGZABIG7z1Rm3Cg+4Dsb8D2l Cc+U+Fh+gn0xLbksVvGd871CgvQUExmIqJC3OVw7tPYmXImKPK5FUCtXfHxmtM73fEE6 p2rg9XC5WjrrmhK41eLw6/ZCXP4JLB0LpNeZ35LcFwTSGeMvBMPi+dvGEYgvVY9Kab7U 2yCbLTpQEx08DbwNNGNHBxM7JqTcmKFEbLW2SAZ24cxP1pntJfIk8rWrsMOpthpexjzV hJzQ== X-Gm-Message-State: ALoCoQlmSsufg9ZhVUnt6rwbR7I6HbqIPIxvs0pgxqCWrJvut4cqNzBLjin8/LdojG7XDpNGt/yP X-Received: by 10.194.87.35 with SMTP id u3mr1048801wjz.3.1411447705115; Mon, 22 Sep 2014 21:48:25 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.23.130 with SMTP id m2ls2597laf.89.gmail; Mon, 22 Sep 2014 21:48:24 -0700 (PDT) X-Received: by 10.112.62.200 with SMTP id a8mr28056994lbs.34.1411447704651; Mon, 22 Sep 2014 21:48:24 -0700 (PDT) Received: from mail-lb0-x229.google.com (mail-lb0-x229.google.com [2a00:1450:4010:c04::229]) by mx.google.com with ESMTPS id qj5si16911200lbb.89.2014.09.22.21.48.24 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 22 Sep 2014 21:48:24 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::229 as permitted sender) client-ip=2a00:1450:4010:c04::229; Received: by mail-lb0-f169.google.com with SMTP id b12so8047973lbj.0 for ; Mon, 22 Sep 2014 21:48:24 -0700 (PDT) X-Received: by 10.152.204.231 with SMTP id lb7mr29834052lac.44.1411447704558; Mon, 22 Sep 2014 21:48:24 -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 of9csp352467lbb; Mon, 22 Sep 2014 21:48:23 -0700 (PDT) X-Received: by 10.66.185.49 with SMTP id ez17mr31172947pac.58.1411447703074; Mon, 22 Sep 2014 21:48:23 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dz5si18591671pbb.17.2014.09.22.21.48.22 for ; Mon, 22 Sep 2014 21:48:23 -0700 (PDT) Received-SPF: none (google.com: linux-crypto-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 S1754410AbaIWEsN (ORCPT ); Tue, 23 Sep 2014 00:48:13 -0400 Received: from mail-pa0-f44.google.com ([209.85.220.44]:54317 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753656AbaIWEnC (ORCPT ); Tue, 23 Sep 2014 00:43:02 -0400 Received: by mail-pa0-f44.google.com with SMTP id eu11so4840995pac.17 for ; Mon, 22 Sep 2014 21:43:01 -0700 (PDT) X-Received: by 10.66.160.65 with SMTP id xi1mr31400004pab.123.1411447381118; Mon, 22 Sep 2014 21:43:01 -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.58 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 22 Sep 2014 21:43:00 -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 06/12] crypto: LLVMLinux: Remove VLAIS from crypto/omap_sham.c Date: Mon, 22 Sep 2014 21:42:11 -0700 Message-Id: <1411447337-22362-7-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-crypto-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-crypto@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:c04::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/omap-sham.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/drivers/crypto/omap-sham.c b/drivers/crypto/omap-sham.c index 710d863..24ef489 100644 --- a/drivers/crypto/omap-sham.c +++ b/drivers/crypto/omap-sham.c @@ -949,17 +949,14 @@ static int omap_sham_finish_hmac(struct ahash_request *req) struct omap_sham_hmac_ctx *bctx = tctx->base; int bs = crypto_shash_blocksize(bctx->shash); int ds = crypto_shash_digestsize(bctx->shash); - struct { - struct shash_desc shash; - char ctx[crypto_shash_descsize(bctx->shash)]; - } desc; + SHASH_DESC_ON_STACK(shash, bctx->shash); - desc.shash.tfm = bctx->shash; - desc.shash.flags = 0; /* not CRYPTO_TFM_REQ_MAY_SLEEP */ + shash->tfm = bctx->shash; + shash->flags = 0; /* not CRYPTO_TFM_REQ_MAY_SLEEP */ - return crypto_shash_init(&desc.shash) ?: - crypto_shash_update(&desc.shash, bctx->opad, bs) ?: - crypto_shash_finup(&desc.shash, req->result, ds, req->result); + return crypto_shash_init(shash) ?: + crypto_shash_update(shash, bctx->opad, bs) ?: + crypto_shash_finup(shash, req->result, ds, req->result); } static int omap_sham_finish(struct ahash_request *req) @@ -1118,18 +1115,15 @@ static int omap_sham_update(struct ahash_request *req) return omap_sham_enqueue(req, OP_UPDATE); } -static int omap_sham_shash_digest(struct crypto_shash *shash, u32 flags, +static int omap_sham_shash_digest(struct crypto_shash *tfm, u32 flags, const u8 *data, unsigned int len, u8 *out) { - struct { - struct shash_desc shash; - char ctx[crypto_shash_descsize(shash)]; - } desc; + SHASH_DESC_ON_STACK(shash, tfm); - desc.shash.tfm = shash; - desc.shash.flags = flags & CRYPTO_TFM_REQ_MAY_SLEEP; + shash->tfm = tfm; + shash->flags = flags & CRYPTO_TFM_REQ_MAY_SLEEP; - return crypto_shash_digest(&desc.shash, data, len, out); + return crypto_shash_digest(shash, data, len, out); } static int omap_sham_final_shash(struct ahash_request *req)