From patchwork Mon Sep 15 07:30:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Behan Webster X-Patchwork-Id: 37406 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f199.google.com (mail-we0-f199.google.com [74.125.82.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2D103206A5 for ; Mon, 15 Sep 2014 07:32:35 +0000 (UTC) Received: by mail-we0-f199.google.com with SMTP id q58sf1867542wes.2 for ; Mon, 15 Sep 2014 00:32:31 -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=d8ebhXJzv9QuCY5gLw839GETamvQ2OLb+08xE/Z+q1Y=; b=Lpm6lYzhandzJGfkPRU/hert7D/P+ZoyMRu+QE83IXfPoZAvtfuKi4MAy93MfMs4X1 oSuNQQ8DmWF228dpXhn3td+baBjM5cqGTE1rauXfsW8Rdhc+sZEG99+1Ff6gdInMnf3/ Aa+ZNsdFtw1GbLu5AzxNhn761qNWhGVvMfeEYBzPXgEApZrs5t5DHl5sD/pufu7IQsl6 ikhHjiRYlW0d6IO6529Y9lHjI7wzLBuCgfr8tRVGwQ5RdgBG/WXpaVespcHao+KVIby3 hM3NbpiPmgzpHS4OlaQGDEsnfhM8U0frsepf0UimjF6WtygX9gOw85xuEyXGGz/7C34Q jr6g== X-Gm-Message-State: ALoCoQkmw+ZG58stV84MZHLNLjlD4v50lXGfaF5gzwDK7UIxtOb8PgHNWJ6qI6l0vfSCfFqlrxXD X-Received: by 10.112.131.33 with SMTP id oj1mr991632lbb.7.1410766351461; Mon, 15 Sep 2014 00:32:31 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.204.34 with SMTP id kv2ls318079lac.76.gmail; Mon, 15 Sep 2014 00:32:31 -0700 (PDT) X-Received: by 10.152.42.136 with SMTP id o8mr6849789lal.71.1410766351280; Mon, 15 Sep 2014 00:32:31 -0700 (PDT) Received: from mail-la0-x22d.google.com (mail-la0-x22d.google.com [2a00:1450:4010:c03::22d]) by mx.google.com with ESMTPS id w8si17561958lbm.78.2014.09.15.00.32.31 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 15 Sep 2014 00:32:31 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::22d as permitted sender) client-ip=2a00:1450:4010:c03::22d; Received: by mail-la0-f45.google.com with SMTP id b17so4094007lan.18 for ; Mon, 15 Sep 2014 00:32:31 -0700 (PDT) X-Received: by 10.152.246.6 with SMTP id xs6mr26264180lac.56.1410766351116; Mon, 15 Sep 2014 00:32:31 -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 of9csp161703lbb; Mon, 15 Sep 2014 00:32:30 -0700 (PDT) X-Received: by 10.70.103.204 with SMTP id fy12mr2417394pdb.144.1410766348496; Mon, 15 Sep 2014 00:32:28 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dc3si20968432pdb.254.2014.09.15.00.32.27 for ; Mon, 15 Sep 2014 00:32:28 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-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 S1753509AbaIOHcA (ORCPT + 27 others); Mon, 15 Sep 2014 03:32:00 -0400 Received: from mail-pa0-f48.google.com ([209.85.220.48]:43946 "EHLO mail-pa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753477AbaIOHbx (ORCPT ); Mon, 15 Sep 2014 03:31:53 -0400 Received: by mail-pa0-f48.google.com with SMTP id hz1so5847906pad.35 for ; Mon, 15 Sep 2014 00:31:53 -0700 (PDT) X-Received: by 10.66.227.71 with SMTP id ry7mr36112312pac.32.1410766313225; Mon, 15 Sep 2014 00:31:53 -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.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Sep 2014 00:31:51 -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 v3 10/12] crypto: LLVMLinux: Remove VLAIS usage from libcrc32c.c Date: Mon, 15 Sep 2014 00:30:32 -0700 Message-Id: <1410766234-1634-11-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-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@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::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: 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 Cc: pageexec@freemail.hu Cc: "David S. Miller" Cc: Herbert Xu --- 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);