From patchwork Tue Sep 23 04:42:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Behan Webster X-Patchwork-Id: 4953061 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E5B5FBEEA5 for ; Tue, 23 Sep 2014 04:46:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0E544201C0 for ; Tue, 23 Sep 2014 04:46:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0DE6420109 for ; Tue, 23 Sep 2014 04:46:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754136AbaIWEqA (ORCPT ); Tue, 23 Sep 2014 00:46:00 -0400 Received: from mail-pd0-f178.google.com ([209.85.192.178]:53497 "EHLO mail-pd0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753771AbaIWEnK (ORCPT ); Tue, 23 Sep 2014 00:43:10 -0400 Received: by mail-pd0-f178.google.com with SMTP id ft15so5717251pdb.37 for ; Mon, 22 Sep 2014 21:43:09 -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=g9xDceIZGlWb0MxZOFg1QWND6FazFw1DvpH/g1qRyGI=; b=tKQjjmXnXJaVAIOLJeUbfAK/VUfHq/n1ZLaOLGFu7G1JB5yzQAPtSZDDd1VMws8y/q I6wd9QU7BQrTa0HDhYnQ+usGEuFPSwS3H2N5qYNKF3bKhlHJAR/lnDSjLqFf7tkePKfZ b1vSPZCgd0tLkZqBapFxKDZwnHpCb6TEDq4nk= 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=g9xDceIZGlWb0MxZOFg1QWND6FazFw1DvpH/g1qRyGI=; b=akWQuWypc6NK8cpEq/aq1EFN31jdGWZD1M3ZzLJU5h5I/GMjldTRrOlvtMAxb1TXqZ A6zfAy+9q8w5pz/7GUku5/EsEa9nr6r7F4L5mYxQhszEkjSay1uc1DMf8LEMcu+4P34Z haS/nbtK8Ik7wUKjPRr3PF5mYtFsQJdeHFe7YKC7iFtHtexdhkpvMSkpOpRx0hGxZCc/ 1tyhQv4+Eu26PGc+9QSo2ch31frxRzpm+U4u5MTo5qmyi/6kHz4patEh0V5Y+f52a8Th yubsWOxAylYFg5fucEDpu8iEbkh6dPnXP72PUCDdBKeMyGJfytX/u/rVVFGBoXz0Y+mx uOjw== X-Gm-Message-State: ALoCoQmFXBqdSCze6FD7f7Y4uKfghIyB9F2OfFJj9Bm3oM86cAmWv+USq4BQUvmhrqGCXK+viUzL X-Received: by 10.68.115.48 with SMTP id jl16mr30697292pbb.78.1411447389665; Mon, 22 Sep 2014 21:43:09 -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.43.07 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 22 Sep 2014 21:43:08 -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, =?UTF-8?q?Jan-Simon=20M=C3=B6ller?= , Behan Webster , pageexec@freemail.hu Subject: [PATCH v4 09/12] crypto: LLVMLinux: Remove VLAIS usage from crypto/hmac.c Date: Mon, 22 Sep 2014 21:42:14 -0700 Message-Id: <1411447337-22362-10-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-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable 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: Jan-Simon Möller 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: Jan-Simon Möller Signed-off-by: Behan Webster Reviewed-by: Mark Charlebois Acked-by: Herbert Xu Cc: pageexec@freemail.hu --- crypto/hmac.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/crypto/hmac.c b/crypto/hmac.c index 8d9544c..e392219 100644 --- a/crypto/hmac.c +++ b/crypto/hmac.c @@ -52,20 +52,17 @@ static int hmac_setkey(struct crypto_shash *parent, struct hmac_ctx *ctx = align_ptr(opad + ss, crypto_tfm_ctx_alignment()); struct crypto_shash *hash = ctx->hash; - struct { - struct shash_desc shash; - char ctx[crypto_shash_descsize(hash)]; - } desc; + SHASH_DESC_ON_STACK(shash, hash); unsigned int i; - desc.shash.tfm = hash; - desc.shash.flags = crypto_shash_get_flags(parent) & - CRYPTO_TFM_REQ_MAY_SLEEP; + shash->tfm = hash; + shash->flags = crypto_shash_get_flags(parent) + & CRYPTO_TFM_REQ_MAY_SLEEP; if (keylen > bs) { int err; - err = crypto_shash_digest(&desc.shash, inkey, keylen, ipad); + err = crypto_shash_digest(shash, inkey, keylen, ipad); if (err) return err; @@ -81,12 +78,12 @@ static int hmac_setkey(struct crypto_shash *parent, opad[i] ^= 0x5c; } - return crypto_shash_init(&desc.shash) ?: - crypto_shash_update(&desc.shash, ipad, bs) ?: - crypto_shash_export(&desc.shash, ipad) ?: - crypto_shash_init(&desc.shash) ?: - crypto_shash_update(&desc.shash, opad, bs) ?: - crypto_shash_export(&desc.shash, opad); + return crypto_shash_init(shash) ?: + crypto_shash_update(shash, ipad, bs) ?: + crypto_shash_export(shash, ipad) ?: + crypto_shash_init(shash) ?: + crypto_shash_update(shash, opad, bs) ?: + crypto_shash_export(shash, opad); } static int hmac_export(struct shash_desc *pdesc, void *out)