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: 37715 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 42B56202A1 for ; Tue, 23 Sep 2014 04:43:35 +0000 (UTC) Received: by mail-lb0-f200.google.com with SMTP id u10sf3944131lbd.7 for ; Mon, 22 Sep 2014 21:43:34 -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 :in-reply-to:references: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=MRT06DArRsktpk2uS6lr4NgfxJQj9/79R44NqSe3xXg=; b=JLOFcY+wjNnQNrK79KfodOnyZ/WDRU7IEUQHnT6ocHsQgDPBvGDSfQfMI5rNkQWO5C T65VkergRgllSgfCtzjHUr3SkYNxZ4rS3F8TxKbwkZ+9ksab67M5MtJx7JemcVCI5Orb KQ4LM7LdwQfuF3lbQk+tnqrW+YkYN5Krk6eAV/DoxNBPoNN2Lj+opinymLVh/8umUn/v tQzQ4rxtoY92PHRvSqTWQ6Rl2sW/OhVqak20UWt/ejcPbMFMDi4txc0ekAzNLXgxeAhN Vxaa6e3yPFc5kibU0W2tW9J9xnxqxkvkowEhnfhQbWlN5m/PIW5PSVLzSu3N0COQRJAa Y0SQ== X-Gm-Message-State: ALoCoQkOh8IkTWN1TIEoiW5eB56jAsQXoAq71QxnUOusLXHYk1lq2B20YQuhagVakixYDrcV9zQ/ X-Received: by 10.112.167.138 with SMTP id zo10mr1132550lbb.3.1411447413778; Mon, 22 Sep 2014 21:43:33 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.37.170 with SMTP id z10ls3061laj.73.gmail; Mon, 22 Sep 2014 21:43:33 -0700 (PDT) X-Received: by 10.152.179.36 with SMTP id dd4mr19734174lac.51.1411447413415; Mon, 22 Sep 2014 21:43:33 -0700 (PDT) Received: from mail-la0-x236.google.com (mail-la0-x236.google.com [2a00:1450:4010:c03::236]) by mx.google.com with ESMTPS id tn9si16918256lbb.72.2014.09.22.21.43.33 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 22 Sep 2014 21:43:33 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::236 as permitted sender) client-ip=2a00:1450:4010:c03::236; Received: by mail-la0-f54.google.com with SMTP id ge10so7783866lab.41 for ; Mon, 22 Sep 2014 21:43:33 -0700 (PDT) X-Received: by 10.112.62.200 with SMTP id a8mr28039696lbs.34.1411447413335; Mon, 22 Sep 2014 21:43:33 -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.112.130.169 with SMTP id of9csp352057lbb; Mon, 22 Sep 2014 21:43:32 -0700 (PDT) X-Received: by 10.70.128.1 with SMTP id nk1mr36710365pdb.97.1411447410360; Mon, 22 Sep 2014 21:43:30 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id xh10si7803583pab.42.2014.09.22.21.43.29 for ; Mon, 22 Sep 2014 21:43:30 -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 S1753902AbaIWEnQ (ORCPT ); Tue, 23 Sep 2014 00:43:16 -0400 Received: from mail-pd0-f174.google.com ([209.85.192.174]:34243 "EHLO mail-pd0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753839AbaIWEnN (ORCPT ); Tue, 23 Sep 2014 00:43:13 -0400 Received: by mail-pd0-f174.google.com with SMTP id g10so5250866pdj.33 for ; Mon, 22 Sep 2014 21:43:12 -0700 (PDT) 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-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 2a00:1450:4010:c03::236 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: 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);