From patchwork Fri Sep 5 23:00: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: 36903 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f198.google.com (mail-ob0-f198.google.com [209.85.214.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8D4D3202A1 for ; Fri, 5 Sep 2014 23:00:21 +0000 (UTC) Received: by mail-ob0-f198.google.com with SMTP id wp18sf62511089obc.5 for ; Fri, 05 Sep 2014 16:00:21 -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=iY4k+5rCxj9/zTgO1Pw+Ra4sHKj+IJQJc2F5iPywfwA=; b=Eqcuu/5YlgUCMdFyULKir01ZnVz1w67E/feXoz5Q5+g9pPIj9l9bCbdmSgH3Tm8sQj R4eZgwF5Gh7tODrS+YhPK/5ccAB9rzkgOR6Dy8pCXzm+QZTL0BSSWdnG1pIGX3mYN8Pe Ur2nh0NHVlp+UFSh9kFfD3pkgPLEsk3+oIUbRrMDHtng/RXr1YkhHy863oLgfZK8Feej h7R6VjAKK3yzauori8CGOR+fhLSv0Ulf0X0/oB8m/TqM4k65T8WIfaozFeJHtRcqIMJr 3GQeWVag18qGBg06XbNm234rDwO1POqo5A5SN6XZuVQcTVMTwT24EKWXKcMaKYEkLKj4 uOYA== X-Gm-Message-State: ALoCoQm6EjX6+865j4AojPab+z/pFCfL1oDT3d0Iljcygt7ja3G2Zk/O897rlHPXcldZe1YmZzV7 X-Received: by 10.182.125.68 with SMTP id mo4mr7677025obb.49.1409958021205; Fri, 05 Sep 2014 16:00:21 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.83.49 with SMTP id i46ls958716qgd.10.gmail; Fri, 05 Sep 2014 16:00:21 -0700 (PDT) X-Received: by 10.220.159.204 with SMTP id k12mr12475909vcx.15.1409958021121; Fri, 05 Sep 2014 16:00:21 -0700 (PDT) Received: from mail-vc0-x22d.google.com (mail-vc0-x22d.google.com [2607:f8b0:400c:c03::22d]) by mx.google.com with ESMTPS id cd8si1521660vcb.83.2014.09.05.16.00.21 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 05 Sep 2014 16:00:21 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c03::22d as permitted sender) client-ip=2607:f8b0:400c:c03::22d; Received: by mail-vc0-f173.google.com with SMTP id im17so13115319vcb.32 for ; Fri, 05 Sep 2014 16:00:21 -0700 (PDT) X-Received: by 10.52.94.108 with SMTP id db12mr10773070vdb.8.1409958021026; Fri, 05 Sep 2014 16:00:21 -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 uj3csp148217vcb; Fri, 5 Sep 2014 16:00:20 -0700 (PDT) X-Received: by 10.66.139.200 with SMTP id ra8mr26255463pab.69.1409958020188; Fri, 05 Sep 2014 16:00:20 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v11si6132888pas.205.2014.09.05.16.00.19 for ; Fri, 05 Sep 2014 16:00:20 -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 S1753183AbaIEXAR (ORCPT ); Fri, 5 Sep 2014 19:00:17 -0400 Received: from mail-pd0-f177.google.com ([209.85.192.177]:45466 "EHLO mail-pd0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752438AbaIEXAP (ORCPT ); Fri, 5 Sep 2014 19:00:15 -0400 Received: by mail-pd0-f177.google.com with SMTP id r10so16689222pdi.36 for ; Fri, 05 Sep 2014 16:00:15 -0700 (PDT) X-Received: by 10.70.125.165 with SMTP id mr5mr26351612pdb.102.1409958014948; Fri, 05 Sep 2014 16:00:14 -0700 (PDT) Received: from galdor.websterwood.com (S0106dc9fdb80cffd.gv.shawcable.net. [96.50.97.138]) by mx.google.com with ESMTPSA id o2sm2620929pdk.87.2014.09.05.16.00.13 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 05 Sep 2014 16:00:13 -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, Behan Webster , Mark Charlebois , =?UTF-8?q?Jan-Simon=20M=C3=B6ller?= Subject: [PATCH] crypto: LLVMLinux: Remove VLAIS from crypto/n2_core.c Date: Fri, 5 Sep 2014 16:00:08 -0700 Message-Id: <1409958008-32119-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::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: 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/n2_core.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/crypto/n2_core.c b/drivers/crypto/n2_core.c index 7263c10..ed142d1 100644 --- a/drivers/crypto/n2_core.c +++ b/drivers/crypto/n2_core.c @@ -445,10 +445,9 @@ 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; + char desc[sizeof(struct shash_desc) + + crypto_shash_descsize(child_shash)] CRYPTO_MINALIGN_ATTR; + struct shash_desc *shash = (struct shash_desc *)desc; int err, bs, ds; fallback_tfm = ctx->base.fallback_tfm; @@ -456,15 +455,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;