From patchwork Fri Sep 5 23:03:13 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Behan Webster X-Patchwork-Id: 36908 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f200.google.com (mail-ob0-f200.google.com [209.85.214.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E94A1202E4 for ; Fri, 5 Sep 2014 23:03:24 +0000 (UTC) Received: by mail-ob0-f200.google.com with SMTP id va2sf62640840obc.3 for ; Fri, 05 Sep 2014 16:03:24 -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 :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=SyGH8XWdiyPVnG9I7gOF9gk+AABUdT61bzypaN/v82M=; b=Cb/mYAJEhlCXevOYQ2Y3OJcpmiJ6FQByMQa+tbNdBXq7uItxAdThk9prOeEuLzMqDZ efgxSJA1qeYkSvu7jboLLlNvcDRx2VTAUYYJdBR1FNo+5+LlRN7IxJ6EupqEgV8HRDyp 3BuYImcE2neTeS/azU4Rk6cffeq6HiTCOIfzvwmwujn0yD0CfWI+KKlvYkQ1UyXhVk2Z hPiBIHtr6pxsy5vh5MhUPqVwTl+y16CUM2n/fp1jPO2WlcKu5rYzpoI7QE7+fbwucJQw OFzJzXDrQ0EsVdW5hRRh2HK+7LBiJwp7MoN9jOV51HX9ALWkdDYSQseC5VBAkHJPZB3O 8gwg== X-Gm-Message-State: ALoCoQm6SsB4+CAiessuAk0l+XOKqlJIDw6TmyW+mqxpwm+tZNlYQdJ3HJ1w3aUIQtHS90Dox0WQ X-Received: by 10.42.152.201 with SMTP id j9mr8986807icw.5.1409958204508; Fri, 05 Sep 2014 16:03:24 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.50.107 with SMTP id r98ls988556qga.71.gmail; Fri, 05 Sep 2014 16:03:24 -0700 (PDT) X-Received: by 10.221.44.69 with SMTP id uf5mr12888756vcb.4.1409958204399; Fri, 05 Sep 2014 16:03:24 -0700 (PDT) Received: from mail-vc0-x230.google.com (mail-vc0-x230.google.com [2607:f8b0:400c:c03::230]) by mx.google.com with ESMTPS id v9si1549573vcs.20.2014.09.05.16.03.24 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 05 Sep 2014 16:03:24 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c03::230 as permitted sender) client-ip=2607:f8b0:400c:c03::230; Received: by mail-vc0-f176.google.com with SMTP id ik5so12848599vcb.7 for ; Fri, 05 Sep 2014 16:03:24 -0700 (PDT) X-Received: by 10.52.156.100 with SMTP id wd4mr3419607vdb.39.1409958204290; Fri, 05 Sep 2014 16:03:24 -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.221.45.67 with SMTP id uj3csp148523vcb; Fri, 5 Sep 2014 16:03:23 -0700 (PDT) X-Received: by 10.70.47.2 with SMTP id z2mr26868759pdm.38.1409958203413; Fri, 05 Sep 2014 16:03:23 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qy3si6502537pab.12.2014.09.05.16.03.22 for ; Fri, 05 Sep 2014 16:03:23 -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 S1754394AbaIEXDU (ORCPT + 26 others); Fri, 5 Sep 2014 19:03:20 -0400 Received: from mail-pa0-f50.google.com ([209.85.220.50]:39482 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752101AbaIEXDT (ORCPT ); Fri, 5 Sep 2014 19:03:19 -0400 Received: by mail-pa0-f50.google.com with SMTP id kq14so23180991pab.37 for ; Fri, 05 Sep 2014 16:03:18 -0700 (PDT) X-Received: by 10.66.189.73 with SMTP id gg9mr25869083pac.114.1409958198712; Fri, 05 Sep 2014 16:03:18 -0700 (PDT) Received: from galdor.websterwood.com (S0106dc9fdb80cffd.gv.shawcable.net. [96.50.97.138]) by mx.google.com with ESMTPSA id y1sm2621999pdk.90.2014.09.05.16.03.16 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 05 Sep 2014 16:03:17 -0700 (PDT) From: behanw@converseincode.com To: fabf@skynet.be Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, =?UTF-8?q?Jan-Simon=20M=C3=B6ller?= , Behan Webster , pageexec@freemail.hu Subject: [PATCH v2] crypto: LLVMLinux: Remove VLAIS usage from libcrc32c.c Date: Fri, 5 Sep 2014 16:03:13 -0700 Message-Id: <1409958193-4736-1-git-send-email-behanw@converseincode.com> X-Mailer: git-send-email 1.9.1 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 2607:f8b0:400c:c03::230 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 The use of variable length arrays in structs (VLAIS) in the Linux Kernel code precludes the use of compilers which don't implement VLAIS (for instance the Clang compiler). This patch instead allocates the appropriate amount of memory using an char array. struct shash_desc contains a flexible array member member ctx declared with CRYPTO_MINALIGN_ATTR, so sizeof(struct shash_desc) aligns the beginning of the array declared after struct shash_desc with long long. No trailing padding is required because it is not a struct type that can be used in an array. The CRYPTO_MINALIGN_ATTR is required so that desc is aligned with long long as would be the case for a struct containing a member with CRYPTO_MINALIGN_ATTR. Signed-off-by: Jan-Simon Möller Signed-off-by: Behan Webster Cc: pageexec@freemail.hu --- lib/libcrc32c.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/libcrc32c.c b/lib/libcrc32c.c index b3131f5..72e4ecb 100644 --- a/lib/libcrc32c.c +++ b/lib/libcrc32c.c @@ -41,20 +41,20 @@ 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; + char desc[sizeof(struct shash_desc) + + crypto_shash_descsize(tfm)] CRYPTO_MINALIGN_ATTR; + struct shash_desc *shash = (struct shash_desc *)desc; + 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);