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: 4829181 Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BCDE6C0338 for ; Tue, 2 Sep 2014 22:37:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2CC36201E4 for ; Tue, 2 Sep 2014 22:37:45 +0000 (UTC) Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) by mail.kernel.org (Postfix) with ESMTP id 6BAF7201DC for ; Tue, 2 Sep 2014 22:37:41 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s82MXtUJ004971; Tue, 2 Sep 2014 18:33:56 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s82MXLhn024448 for ; Tue, 2 Sep 2014 18:33:21 -0400 Received: from mx1.redhat.com (ext-mx15.extmail.prod.ext.phx2.redhat.com [10.5.110.20]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s82MXLdH022491 for ; Tue, 2 Sep 2014 18:33:21 -0400 Received: from mail-pd0-f171.google.com (mail-pd0-f171.google.com [209.85.192.171]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s82MXJiB002635 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=FAIL) for ; Tue, 2 Sep 2014 18:33:20 -0400 Received: by mail-pd0-f171.google.com with SMTP id y13so9579243pdi.16 for ; Tue, 02 Sep 2014 15:33:19 -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=dFyRf0e6aBwq9xxN8uRn4ZK/I2N1XY1fGqhcLIelHRk=; b=dWh6qbwzncDNZNMjojWTOoJAEQinIMSm3B/ha5vhj1OHEPTT54PwqfXs79I0I7JUqQ l0pFnXGUQZH1hmJHXJPGbACB/eGLqXMIYAJnkYyM7UdMS3EXmUvpq8YpsA4l0OJ6jptU ekgxkKLsd7pb4PspKfTU0pQZXhVVm8Iq2MYVo= 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=dFyRf0e6aBwq9xxN8uRn4ZK/I2N1XY1fGqhcLIelHRk=; b=VtmeEivDcShawyANaD612lyp/K3HdOeFRfMegt4yfAHW3VqfV0oiF2wNvY5HusdtlQ qTrgOL+vGnzOj2pRe/shsz4W3P9gkFeX/XO9SrXK7sM3wY3wkJwz8FB4UMY7XISPNikx XIG8ZpFRCMZaiT03PQ5gukn9CoFtkWoT20FSpECmzxQap+fVpqrNOEPCHgJzuA2ygoWK xRcYS/UUeNkOATd0pb2JDA4JDcYstyWcPHbCerdIaf27ecYPfLwnqaok0D7tdqnm0XjU eK1E4E6T4OoUGWWg13O0bNQ+Z7p7RVmgzxtjuO+iqe/gWgcTj1Kt14aI/yDKBwaB0mBz xWCg== X-Gm-Message-State: ALoCoQlAja2WZAxVfShCrfKKHE7bMhjrAUArukYeOHS8tjoXVqvhfaBYbEXW2MJQGMJywtUddeXa 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 Date: Tue, 2 Sep 2014 15:32:31 -0700 Message-Id: <1409697153-7006-5-git-send-email-behanw@converseincode.com> 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 X-RedHat-Spam-Score: -3.101 (BAYES_00, DCC_REPUT_00_12, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_LOW, SPF_PASS) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Scanned-By: MIMEDefang 2.68 on 10.5.110.20 X-loop: dm-devel@redhat.com Cc: john.johansen@canonical.com, =?UTF-8?q?Jan-Simon=20M=C3=B6ller?= , linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, linux-security-module@vger.kernel.org, Behan Webster , linux-crypto@vger.kernel.org, james.l.morris@oracle.com, pageexec@freemail.hu, akpm@linux-foundation.org, torvalds@linux-foundation.org, linux-btrfs@vger.kernel.org, serge@hallyn.com Subject: [dm-devel] [PATCH RFC 4/6] crypto: LLVMLinux: Remove VLAIS usage from crypto/testmgr.c X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable 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 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);