From patchwork Tue Sep 23 04:42:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Behan Webster X-Patchwork-Id: 4953031 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 202E59F348 for ; Tue, 23 Sep 2014 04:45:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2DF11201D3 for ; Tue, 23 Sep 2014 04:45:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 39B7D201C0 for ; Tue, 23 Sep 2014 04:45:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754007AbaIWEo3 (ORCPT ); Tue, 23 Sep 2014 00:44:29 -0400 Received: from mail-pd0-f169.google.com ([209.85.192.169]:51214 "EHLO mail-pd0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753841AbaIWEnN (ORCPT ); Tue, 23 Sep 2014 00:43:13 -0400 Received: by mail-pd0-f169.google.com with SMTP id fp1so1653968pdb.28 for ; Mon, 22 Sep 2014 21:43:12 -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=A+3JCOT35W9uQ36CkNL6yJr4t+VSHaRR45lsar1FUhQ=; b=Kd8RdoV1sEUMqrE+1KJz7yi5IV070lfPyT7zyndaPjBLXBiBkbpJH4UPEC4sK+X4yM n2xgjGxZaRpo/dKF0ysqNLj1EVf6VQRUy/AGofmRCXX5UPYF2zvSJc/d3ZgkU3nDBWW/ Igldbu5oyXrmxicToBa9xWTTeiA6W7o+Os2Nk= 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=A+3JCOT35W9uQ36CkNL6yJr4t+VSHaRR45lsar1FUhQ=; b=SeJKsUB7d3g6gQEYVLILyVQNZEzwBsR2zD2gS3446aylEeoE15tEi9PuNmG7KBelqR 7r2Couv5mqQGsyFPqUZJYSfBx61Z9WYfFw2kiWnoIfR5tOmCNVYzNqO7vqPKSrSZQjBs 5CCSdXEZfUMFD3wS/7t0hT/wQ0RfSwbqHDu8wn2eYVV3a0h96ROVWG6WJ9rwYBXc++Zs ojNEC4UVQxhXTu2QjEZspxr+hZJsuKvwHrWGlAgwUrYbxbEBMHphLi56hln/1Brze42N XR2L6RaJFU4AWeHX9xAy3fVZVWfaZUw6ybT+cgMH+rPhUTJKHfQNE0KpEhXJiFnajeWD tbQg== X-Gm-Message-State: ALoCoQmyz/mguourlwTeecmaXsy51xHn/bWfPOW0fWpk+kDoFiP1YIB6Ks/3O9SG8cectUH19TBA X-Received: by 10.66.144.195 with SMTP id so3mr9525308pab.156.1411447392434; Mon, 22 Sep 2014 21:43:12 -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.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 22 Sep 2014 21:43:11 -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 10/12] crypto: LLVMLinux: Remove VLAIS usage from libcrc32c.c Date: Mon, 22 Sep 2014 21:42:15 -0700 Message-Id: <1411447337-22362-11-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=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: 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 Cc: "David S. Miller" --- lib/libcrc32c.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/libcrc32c.c b/lib/libcrc32c.c index b3131f5..6a08ce7 100644 --- a/lib/libcrc32c.c +++ b/lib/libcrc32c.c @@ -41,20 +41,18 @@ static struct crypto_shash *tfm; u32 crc32c(u32 crc, const void *address, unsigned int length) { - struct { - struct shash_desc shash; - char ctx[crypto_shash_descsize(tfm)]; - } desc; + SHASH_DESC_ON_STACK(shash, tfm); + u32 *ctx = (u32 *)shash_desc_ctx(shash); int err; - desc.shash.tfm = tfm; - desc.shash.flags = 0; - *(u32 *)desc.ctx = crc; + shash->tfm = tfm; + shash->flags = 0; + *ctx = crc; - err = crypto_shash_update(&desc.shash, address, length); + err = crypto_shash_update(shash, address, length); BUG_ON(err); - return *(u32 *)desc.ctx; + return *ctx; } EXPORT_SYMBOL(crc32c);