From patchwork Mon Sep 15 07:30:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Behan Webster X-Patchwork-Id: 4903711 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id ADA449F32F for ; Mon, 15 Sep 2014 07:34:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 48FFE20158 for ; Mon, 15 Sep 2014 07:37:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B8E7520166 for ; Mon, 15 Sep 2014 07:37:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753501AbaIOHhD (ORCPT ); Mon, 15 Sep 2014 03:37:03 -0400 Received: from mail-pd0-f181.google.com ([209.85.192.181]:45856 "EHLO mail-pd0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753374AbaIOHbf (ORCPT ); Mon, 15 Sep 2014 03:31:35 -0400 Received: by mail-pd0-f181.google.com with SMTP id w10so5588163pde.26 for ; Mon, 15 Sep 2014 00:31:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=converseincode.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=ejBDYWLgWWEXbTYJu4y+MWHnmWdNNnIxd+TzeQagK34=; b=g/rEgUrjw3/+SlZYIGmYn/5/Ir284V/nqY59cO3hgvVgQU85IyvoVkIQylCXBNTwsM tR/XSJul/4Fo61EnkymJnkvk5SgxO0N7KgZI0hPRSOscsL+C8TQdxlp4kOgjw6m4GoxJ ziCDGXpm/Rxf0Afkmiddvz6Ws4y9EX4rmLBSs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=ejBDYWLgWWEXbTYJu4y+MWHnmWdNNnIxd+TzeQagK34=; b=inqmtnqRDq/e2M9HYiWellHTMjipUi5O2C8g3Or6+oTWP401zAkL2Nf0m83eTX0BEl gauXZngueyCbzuqbq2Gv0mKd0QWVfj/6i3sHECzeQwIzPpvsCZUzK8CFvmwRqg1OsUQz rBM6U95tDBcD6SS3UxTzC4Ac7W1wJUKBfa9c94an4+GVrUmGNs7zrg0oQuOIXGAJeHFR 4YY3xKZ34oDEvsyQiRyfs0XnwORUGP2UdKFwibNir26+mqOugD7YhnmOQ1J5bDjLfs38 p8aFaS73AwZDLoudGuAGuh/Js4wwzL4S7ENt7Cj+QpJLJiFRo+vP+ijrG9w28qBTloV7 kGqg== X-Gm-Message-State: ALoCoQlF5DMrFqCtd0ZzTJRaS+FIw7WJw2s7EpD0kJD3S9sYpE9KNt68rcaGf/6EcH5GqZjiaiy0 X-Received: by 10.66.136.48 with SMTP id px16mr8139662pab.10.1410766295091; Mon, 15 Sep 2014 00:31:35 -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.32 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Sep 2014 00:31:33 -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 v3 05/12] crypto: LLVMLinux: Remove VLAIS from crypto/n2_core.c Date: Mon, 15 Sep 2014 00:30:27 -0700 Message-Id: <1410766234-1634-6-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-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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;