From patchwork Tue Sep 2 22:32:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Behan Webster X-Patchwork-Id: 36522 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f200.google.com (mail-ie0-f200.google.com [209.85.223.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 78C9420C87 for ; Tue, 2 Sep 2014 22:34:32 +0000 (UTC) Received: by mail-ie0-f200.google.com with SMTP id at20sf40584265iec.7 for ; Tue, 02 Sep 2014 15:34:32 -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=MpNYmZK4Ie5Fpvg3ZS9e4JxBrQ+Jv4H1XPnzhm2Mqtg=; b=kOV3UdQ+qvT+qbLIy7JnSDtvTLtv77mbZyeCQyXka4+rdbGDtzO9epV5CmNR7TugXM tG3kRP0fbbAFviK3OPhRakzMOdtFZ8go+S9r5Gaahh1ytceKw5OG5g4uA/xGI/63enJo ouqYOPVrh0M9zYbNS3QNFyvYVTY8TWImJ2+uo0UEd+L2gA5BKFkMDNlE7u4ezvuFHc4b 48noHZNlZ1+CmYefTQvQoB0iq9VSd6zYh9yxYwTkllvGTUiLhE3gHdHy0ri6R0XCYlow WO5QpdjhwTdlKNyNOLyT4T+gMGE3+39u7BGlVMW4vgA8o8w4wgB6/YV65r5ywb+FBqkS Cc7g== X-Gm-Message-State: ALoCoQneAj/kWNlk7JqkQdL+v3AGRRPb5tS36sVxXGI4Xmo3DnU1JRq0wt7arUb/TPvZFYzblgro X-Received: by 10.50.85.42 with SMTP id e10mr17268054igz.0.1409697272062; Tue, 02 Sep 2014 15:34:32 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.50.107 with SMTP id r98ls2692927qga.71.gmail; Tue, 02 Sep 2014 15:34:31 -0700 (PDT) X-Received: by 10.221.44.69 with SMTP id uf5mr32140599vcb.4.1409697271955; Tue, 02 Sep 2014 15:34:31 -0700 (PDT) Received: from mail-vc0-x22c.google.com (mail-vc0-x22c.google.com [2607:f8b0:400c:c03::22c]) by mx.google.com with ESMTPS id dd1si183847vdc.26.2014.09.02.15.34.31 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 02 Sep 2014 15:34:31 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c03::22c as permitted sender) client-ip=2607:f8b0:400c:c03::22c; Received: by mail-vc0-f172.google.com with SMTP id ij19so7879457vcb.31 for ; Tue, 02 Sep 2014 15:34:31 -0700 (PDT) X-Received: by 10.220.132.207 with SMTP id c15mr32568783vct.12.1409697271880; Tue, 02 Sep 2014 15:34: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.221.45.67 with SMTP id uj3csp594459vcb; Tue, 2 Sep 2014 15:34:31 -0700 (PDT) X-Received: by 10.69.18.65 with SMTP id gk1mr50466188pbd.68.1409697270915; Tue, 02 Sep 2014 15:34:30 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id lk6si7994305pab.105.2014.09.02.15.34.30 for ; Tue, 02 Sep 2014 15:34:30 -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 S1755620AbaIBWe1 (ORCPT + 25 others); Tue, 2 Sep 2014 18:34:27 -0400 Received: from mail-pd0-f182.google.com ([209.85.192.182]:54969 "EHLO mail-pd0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755496AbaIBWdZ (ORCPT ); Tue, 2 Sep 2014 18:33:25 -0400 Received: by mail-pd0-f182.google.com with SMTP id fp1so9560943pdb.41 for ; Tue, 02 Sep 2014 15:33:25 -0700 (PDT) X-Received: by 10.70.132.73 with SMTP id os9mr51871337pdb.63.1409697204991; Tue, 02 Sep 2014 15:33:24 -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.22 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Sep 2014 15:33:23 -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?Vin=C3=ADcius=20Tinti?= , =?UTF-8?q?Jan-Simon=20M=C3=B6ller?= , Behan Webster , Mark Charlebois Subject: [PATCH RFC 6/6] btrfs: LLVMLinux: Remove VLAIS Date: Tue, 2 Sep 2014 15:32:33 -0700 Message-Id: <1409697153-7006-7-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::22c 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: Vinícius Tinti Replaced the use of a Variable Length Array In Struct (VLAIS) with a C99 compliant equivalent. This is the original VLAIS struct. struct { struct shash_desc shash; char ctx[crypto_shash_descsize(tfm)]; } desc; This patch instead allocates the appropriate amount of memory using an char array. The new code can be compiled with both gcc and clang. 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 Signed-off-by: Vinícius Tinti Signed-off-by: Mark Charlebois --- fs/btrfs/hash.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/fs/btrfs/hash.c b/fs/btrfs/hash.c index 85889aa..2fdacda 100644 --- a/fs/btrfs/hash.c +++ b/fs/btrfs/hash.c @@ -33,18 +33,18 @@ void btrfs_hash_exit(void) u32 btrfs_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; }