From patchwork Mon Sep 15 07:30:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Behan Webster X-Patchwork-Id: 4903751 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 DB3359F32F for ; Mon, 15 Sep 2014 07:35:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 80F272015E for ; Mon, 15 Sep 2014 07:38:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4A1ED20158 for ; Mon, 15 Sep 2014 07:38:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753574AbaIOHin (ORCPT ); Mon, 15 Sep 2014 03:38:43 -0400 Received: from mail-pa0-f46.google.com ([209.85.220.46]:33110 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753227AbaIOHbX (ORCPT ); Mon, 15 Sep 2014 03:31:23 -0400 Received: by mail-pa0-f46.google.com with SMTP id kq14so5755670pab.19 for ; Mon, 15 Sep 2014 00:31:22 -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; bh=ZGXYACPOKrSbP0YQp7vS47YCYiSI2DDvYsrsC3RqPUo=; b=Hq4z6EQQxXq61MdgrXeD4jZLW4gm/76UwKDI74RFuBCjB4Jf03iOlEXX2hStqcWI3o 0eIouIpKVqgll72SDpy/ObzyeLyy5t7hg5lsBGejvHtndhfBrDPYIBwjcHocRFJXhGA1 oNfzrbjyb+elO0W5FFYm0tDKKx1gCw4OXxwDM= 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; bh=ZGXYACPOKrSbP0YQp7vS47YCYiSI2DDvYsrsC3RqPUo=; b=Ua2V6pujcGdtH4zYiLluAAKbmtM/4Inkj63IznHhqLUXCLoAZwgUdJ0+F6bwrMfYr2 LvJNA4P+f1oqZjKgS/+Xg3Addp7t3kc8jlp80t1iem3z4g6DxPRgErZ9YDXl+18wZnt/ myZvjB6WqwYkr5LBbxd/Glv2ues4EUJW9JU0hAPwsK40x9L97QWbj6CKe2s9iv5UXgbu IkpGdLREPksALObABkQGvk/0lkMBfYrtQ2efQiupsoUKLjopiPUH/Cbl+nIuvY9ktLh8 s3n+5Bq2lAOVTATeZyiKld0bn5qvRh0edodKxIVgxmN5fn128+NzyLv3UJJXGlwtm/OT rI0g== X-Gm-Message-State: ALoCoQnLRYT31C4V/0glGBIZgHBqUDCc8n3Lp4Tbqgj5YAT2/wgIyvzwNVm46SbAS75ga7E/uBDA X-Received: by 10.66.186.167 with SMTP id fl7mr34753358pac.14.1410766282579; Mon, 15 Sep 2014 00:31:22 -0700 (PDT) Received: from galdor.edimax.com ([38.126.120.10]) by mx.google.com with ESMTPSA id cz1sm1011611pdb.85.2014.09.15.00.31.19 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Sep 2014 00:31:21 -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, Behan Webster Subject: [PATCH v3 01/12] crypto: LLVMLinux: Add macro to remove use of VLAIS in crypto code Date: Mon, 15 Sep 2014 00:30:23 -0700 Message-Id: <1410766234-1634-2-git-send-email-behanw@converseincode.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1410766234-1634-1-git-send-email-behanw@converseincode.com> References: <1410766234-1634-1-git-send-email-behanw@converseincode.com> 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.4 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: Behan Webster Add a macro which replaces the use of a Variable Length Array In Struct (VLAIS) with a C99 compliant equivalent. This macro 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: Behan Webster Acked-by: Herbert Xu --- include/crypto/hash.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/crypto/hash.h b/include/crypto/hash.h index a391955..541125b 100644 --- a/include/crypto/hash.h +++ b/include/crypto/hash.h @@ -58,6 +58,11 @@ struct shash_desc { void *__ctx[] CRYPTO_MINALIGN_ATTR; }; +#define SHASH_DESC_ON_STACK(shash, tfm) \ + char __desc[sizeof(struct shash_desc) + \ + crypto_shash_descsize(tfm)] CRYPTO_MINALIGN_ATTR; \ + struct shash_desc *shash = (struct shash_desc *)__desc + struct shash_alg { int (*init)(struct shash_desc *desc); int (*update)(struct shash_desc *desc, const u8 *data,