From patchwork Fri Sep 5 23:01:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Behan Webster X-Patchwork-Id: 36904 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f71.google.com (mail-pa0-f71.google.com [209.85.220.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7F071202A1 for ; Fri, 5 Sep 2014 23:01:20 +0000 (UTC) Received: by mail-pa0-f71.google.com with SMTP id bj1sf119662pad.10 for ; Fri, 05 Sep 2014 16:01:19 -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 :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=csJ2gKtpT0xVmgTJmPGJ3892O1EI0EEzn1Wr5kP8Te4=; b=JayRLHtSoN8MOQBsIQovtjQl/2qdmhLPS1yFL2PUUmdMoPX8hfqYErwHqt0qCZQBGt boxdq/dQbaKD2k7ab4IHcXA+sKCsunUpyeijiJD2KWufMlD4B8Q+j1pxajsaHc/zN+iP SjeskMDcIAJw7i3LlN9X2nZuZjiE3j93pAiNOBf00eQl/cvWhMIHNdwYHDH0JP7kJxPu /HTLjYaY6nSlam1bgqo2eEVcy1TmPzutHzhKQFAFBMwyrU8MhmUCsdVAjtZ2aSsUP/Xl eSqKHfgHLJSRIhzktK10Q/nf282UxO8KvSg2fkAxhrm4RahvvoOweyGWB0eQFdaPtFqd 8tWA== X-Gm-Message-State: ALoCoQn6ahG+b8lUseH6SmfjRKlHVbzrTWbH2hKeg9ACFLxiaywdeZR+ajsO7ihm6fJfX1g5sLwU X-Received: by 10.66.137.68 with SMTP id qg4mr8005847pab.26.1409958079801; Fri, 05 Sep 2014 16:01:19 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.92.228 with SMTP id b91ls939488qge.88.gmail; Fri, 05 Sep 2014 16:01:19 -0700 (PDT) X-Received: by 10.220.182.1 with SMTP id ca1mr12791485vcb.21.1409958079678; Fri, 05 Sep 2014 16:01:19 -0700 (PDT) Received: from mail-vc0-x234.google.com (mail-vc0-x234.google.com [2607:f8b0:400c:c03::234]) by mx.google.com with ESMTPS id rk7si1537553vcb.45.2014.09.05.16.01.19 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 05 Sep 2014 16:01:19 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c03::234 as permitted sender) client-ip=2607:f8b0:400c:c03::234; Received: by mail-vc0-f180.google.com with SMTP id lf12so13064158vcb.39 for ; Fri, 05 Sep 2014 16:01:19 -0700 (PDT) X-Received: by 10.220.132.207 with SMTP id c15mr12968913vct.12.1409958079584; Fri, 05 Sep 2014 16:01:19 -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.221.45.67 with SMTP id uj3csp148331vcb; Fri, 5 Sep 2014 16:01:19 -0700 (PDT) X-Received: by 10.70.41.11 with SMTP id b11mr26598201pdl.11.1409958078726; Fri, 05 Sep 2014 16:01:18 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ry6si6115631pab.217.2014.09.05.16.01.18 for ; Fri, 05 Sep 2014 16:01:18 -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 S1751674AbaIEXBR (ORCPT ); Fri, 5 Sep 2014 19:01:17 -0400 Received: from mail-pd0-f178.google.com ([209.85.192.178]:61811 "EHLO mail-pd0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751237AbaIEXBQ (ORCPT ); Fri, 5 Sep 2014 19:01:16 -0400 Received: by mail-pd0-f178.google.com with SMTP id p10so35606pdj.23 for ; Fri, 05 Sep 2014 16:01:16 -0700 (PDT) X-Received: by 10.70.102.41 with SMTP id fl9mr26174740pdb.136.1409958076194; Fri, 05 Sep 2014 16:01:16 -0700 (PDT) Received: from galdor.websterwood.com (S0106dc9fdb80cffd.gv.shawcable.net. [96.50.97.138]) by mx.google.com with ESMTPSA id fk5sm2602217pbc.53.2014.09.05.16.01.14 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 05 Sep 2014 16:01:15 -0700 (PDT) From: behanw@converseincode.com To: davem@davemloft.net, herbert@gondor.apana.org.au Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, Behan Webster , Mark Charlebois , =?UTF-8?q?Jan-Simon=20M=C3=B6ller?= Subject: [PATCH] crypto: LLVMLinux: Remove VLAIS from crypto/omap_sham.c Date: Fri, 5 Sep 2014 16:01:04 -0700 Message-Id: <1409958064-753-1-git-send-email-behanw@converseincode.com> X-Mailer: git-send-email 1.9.1 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 2607:f8b0:400c:c03::234 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 an char array. The new code can be compiled with both gcc and clang. struct shash_desc contains a flexible array member member ctx declared with CRYPTO_MINALIGN_ATTR, so sizeof(struct shash_desc) aligns the beginning of the array declared after struct shash_desc with long long. No trailing padding is required because it is not a struct type that can be used in an array. The CRYPTO_MINALIGN_ATTR is required so that desc is aligned with long long as would be the case for a struct containing a member with CRYPTO_MINALIGN_ATTR. Signed-off-by: Behan Webster Signed-off-by: Mark Charlebois Signed-off-by: Jan-Simon Möller --- drivers/crypto/omap-sham.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/drivers/crypto/omap-sham.c b/drivers/crypto/omap-sham.c index 710d863..dcbfd35 100644 --- a/drivers/crypto/omap-sham.c +++ b/drivers/crypto/omap-sham.c @@ -949,17 +949,16 @@ 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; + char desc[sizeof(struct shash_desc) + + crypto_shash_descsize(bctx->shash)] CRYPTO_MINALIGN_ATTR; + struct shash_desc *shash = (struct shash_desc *)desc; - 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 +1117,17 @@ 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; + char desc[sizeof(struct shash_desc) + + crypto_shash_descsize(shash)] CRYPTO_MINALIGN_ATTR; + struct shash_desc *shash = (struct shash_desc *)desc; - 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)