From patchwork Tue Sep 23 04:42:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Behan Webster X-Patchwork-Id: 4952921 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9FF449F348 for ; Tue, 23 Sep 2014 04:43:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B1F7C201C0 for ; Tue, 23 Sep 2014 04:43:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8973B201FA for ; Tue, 23 Sep 2014 04:43:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753654AbaIWEm7 (ORCPT ); Tue, 23 Sep 2014 00:42:59 -0400 Received: from mail-pa0-f47.google.com ([209.85.220.47]:35870 "EHLO mail-pa0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753509AbaIWEmt (ORCPT ); Tue, 23 Sep 2014 00:42:49 -0400 Received: by mail-pa0-f47.google.com with SMTP id et14so5840155pad.6 for ; Mon, 22 Sep 2014 21:42:49 -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=qNIXHCMcb4tIEoPtdMgjRBZFIx+GgEe1iBgGMmRGc6k=; b=eFMWC3AToiIOhCcSGQbU0ad+fFZV6VBP1mewpjYTpRuLprDYN2bzoqR7MAE6PhJEkT oepqoZFIz2LRFZzhi9pJsskNU0RMEetmVM7i4rLjLzI97HXI2WPARGlCEC99lPQxG5FI OyWGc+rg6TDOh2B/TKlq0el/nE0d1Qh0oS7jY= 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=qNIXHCMcb4tIEoPtdMgjRBZFIx+GgEe1iBgGMmRGc6k=; b=HXUTpSy05As1nF91zG935/+ASO8fuF77XNkIf3VqjzrPDinkLZN4jne/ZpqjTycaPb kMk9n8SfWoNZCAPj6jiQOGq0yHcTsv9vL9ifi4rsKLnWAb5fZ9bF0Wg0mTO0+999nYeP Kh1Hm99kxcbp4b5X0IBgQ5beX7phSI8+0D4aJfPA3ZwtGYoBilIZ88gXCniLlRDhjwQF qL2ePFei9odfKepq5ldhf0F0o+E9HXbHE7othfrb+gCK3nYXU1UJnwmOTU5t5Cvp9taW YvDQwoLjkwhIiMHHH4KHG9cl6beArkQ83W1ywnSu5ZRGuKNkKdv/auqAPDC7Kf4qfUZH 6wHQ== X-Gm-Message-State: ALoCoQlw6VH5m1bEBCDHJTTp3FhNwNVgUPOvJgjCcpGAlVRXRT0C7xWOAmrPHO0M4razgYemG972 X-Received: by 10.70.35.15 with SMTP id d15mr37855174pdj.48.1411447369548; Mon, 22 Sep 2014 21:42:49 -0700 (PDT) Received: from galdor.websterwood.com (S0106dc9fdb80cffd.gv.shawcable.net. [96.50.97.138]) by mx.google.com with ESMTPSA id j13sm10774808pbq.42.2014.09.22.21.42.47 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 22 Sep 2014 21:42:48 -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?Vin=C3=ADcius=20Tinti?= , Behan Webster Subject: [PATCH v4 02/12] btrfs: LLVMLinux: Remove VLAIS Date: Mon, 22 Sep 2014 21:42:07 -0700 Message-Id: <1411447337-22362-3-git-send-email-behanw@converseincode.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1411447337-22362-1-git-send-email-behanw@converseincode.com> References: <1411447337-22362-1-git-send-email-behanw@converseincode.com> MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham 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: Vinícius Tinti Replaced the use of a Variable Length Array In Struct (VLAIS) with a C99 compliant equivalent. This patch instead 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: Vinícius Tinti Reviewed-by: Jan-Simon Möller Reviewed-by: Mark Charlebois Signed-off-by: Behan Webster Acked-by: Chris Mason Acked-by: Herbert Xu Cc: "David S. Miller" --- fs/btrfs/hash.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/fs/btrfs/hash.c b/fs/btrfs/hash.c index 85889aa..4bf4d3a 100644 --- a/fs/btrfs/hash.c +++ b/fs/btrfs/hash.c @@ -33,18 +33,16 @@ 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; + 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; }