From patchwork Tue Sep 2 22:32:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Behan Webster X-Patchwork-Id: 36519 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f197.google.com (mail-ie0-f197.google.com [209.85.223.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3B2AB20C87 for ; Tue, 2 Sep 2014 22:33:43 +0000 (UTC) Received: by mail-ie0-f197.google.com with SMTP id rp18sf40615902iec.0 for ; Tue, 02 Sep 2014 15:33:42 -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=mretivVjHtfnzWujU37fDdInwVk+Dzj2/GqYJShODmM=; b=FutH4w94PtyLctsQIMJYmA7bkzrlRTrlnFQ0wxfETp1y8hm468L8RDKcLONg3FV9iB fdf1lBo4jZpreldynUahGv0k1WJAorgVpwVPqdCaZ388HwZ0vZFzyQUMy9nXF6N1DyAF q5jw631gZk8MNQ+87EVwPEle8PgD2H0AOu0cDYXKmNjZziZcFOZXFIHNBBJGiXMUUKhH +wfeBJv95+YE82pXxTiFdqQhKugtUCAVXAFi1aL1JOYW0krUIdTC0n+4jp5OlhX6LcR5 xVrBVsbTyKRr8H2hGg45WpfhrjAkK/WiHs2XuyL2VqpknPJkTBPiPqtfTLIbgWtbbt9z s8fA== X-Gm-Message-State: ALoCoQmFRNmAVPKMkGW+dXo5NHKztwfbt3SGZvYkSXNwiNX/Ny9GQyqqLHdlBwVpRkR9kaNk8WRA X-Received: by 10.182.230.133 with SMTP id sy5mr21650509obc.22.1409697222879; Tue, 02 Sep 2014 15:33:42 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.32.138 with SMTP id h10ls2613271qgh.87.gmail; Tue, 02 Sep 2014 15:33:42 -0700 (PDT) X-Received: by 10.220.184.70 with SMTP id cj6mr31699048vcb.5.1409697222775; Tue, 02 Sep 2014 15:33:42 -0700 (PDT) Received: from mail-vc0-x234.google.com (mail-vc0-x234.google.com [2607:f8b0:400c:c03::234]) by mx.google.com with ESMTPS id bb7si165228vdc.58.2014.09.02.15.33.42 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 02 Sep 2014 15:33:42 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c03::234 as permitted sender) client-ip=2607:f8b0:400c:c03::234; Received: by mail-vc0-f180.google.com with SMTP id lf12so7825211vcb.39 for ; Tue, 02 Sep 2014 15:33:42 -0700 (PDT) X-Received: by 10.52.146.17 with SMTP id sy17mr26731451vdb.29.1409697222659; Tue, 02 Sep 2014 15:33:42 -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 uj3csp594389vcb; Tue, 2 Sep 2014 15:33:42 -0700 (PDT) X-Received: by 10.68.189.3 with SMTP id ge3mr23268727pbc.128.1409697221710; Tue, 02 Sep 2014 15:33:41 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id py9si7775869pac.208.2014.09.02.15.33.40 for ; Tue, 02 Sep 2014 15:33:41 -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 S1755583AbaIBWdc (ORCPT + 25 others); Tue, 2 Sep 2014 18:33:32 -0400 Received: from mail-pd0-f175.google.com ([209.85.192.175]:35317 "EHLO mail-pd0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755438AbaIBWdT (ORCPT ); Tue, 2 Sep 2014 18:33:19 -0400 Received: by mail-pd0-f175.google.com with SMTP id ft15so9563342pdb.6 for ; Tue, 02 Sep 2014 15:33:19 -0700 (PDT) X-Received: by 10.66.121.137 with SMTP id lk9mr51514530pab.86.1409697199383; Tue, 02 Sep 2014 15:33:19 -0700 (PDT) Received: from galdor.websterwood.com (S0106dc9fdb80cffd.gv.shawcable.net. [96.50.97.138]) by mx.google.com with ESMTPSA id c2sm6945161pds.32.2014.09.02.15.33.17 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Sep 2014 15:33:18 -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 Cc: akpm@linux-foundation.org, james.l.morris@oracle.com, john.johansen@canonical.com, linux-btrfs@vger.kernel.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, linux-security-module@vger.kernel.org, neilb@suse.de, serge@hallyn.com, torvalds@linux-foundation.org, =?UTF-8?q?Jan-Simon=20M=C3=B6ller?= , Behan Webster , pageexec@freemail.hu Subject: [PATCH RFC 4/6] crypto: LLVMLinux: Remove VLAIS usage from crypto/testmgr.c Date: Tue, 2 Sep 2014 15:32:31 -0700 Message-Id: <1409697153-7006-5-git-send-email-behanw@converseincode.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1409697153-7006-1-git-send-email-behanw@converseincode.com> References: <1409697153-7006-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 2607:f8b0:400c:c03::234 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 --- crypto/testmgr.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/crypto/testmgr.c b/crypto/testmgr.c index ac2b631..f4bf5c2 100644 --- a/crypto/testmgr.c +++ b/crypto/testmgr.c @@ -1714,16 +1714,16 @@ static int alg_test_crc32c(const struct alg_test_desc *desc, } do { - struct { - struct shash_desc shash; - char ctx[crypto_shash_descsize(tfm)]; - } sdesc; + char sdesc[sizeof(struct shash_desc) + + crypto_shash_descsize(tfm)] CRYPTO_MINALIGN_ATTR; + struct shash_desc *shash = (struct shash_desc *)sdesc; + u32 *ctx = (u32 *)shash_desc_ctx(shash); - sdesc.shash.tfm = tfm; - sdesc.shash.flags = 0; + shash->tfm = tfm; + shash->flags = 0; - *(u32 *)sdesc.ctx = le32_to_cpu(420553207); - err = crypto_shash_final(&sdesc.shash, (u8 *)&val); + *ctx = le32_to_cpu(420553207); + err = crypto_shash_final(shash, (u8 *)&val); if (err) { printk(KERN_ERR "alg: crc32c: Operation failed for " "%s: %d\n", driver, err);