From patchwork Mon Sep 15 07:30:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Behan Webster X-Patchwork-Id: 4903591 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Original-To: patchwork-dm-devel@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 87D929F32F for ; Mon, 15 Sep 2014 07:32:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3BC372017D for ; Mon, 15 Sep 2014 07:35:47 +0000 (UTC) Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) by mail.kernel.org (Postfix) with ESMTP id C61DF201C0 for ; Mon, 15 Sep 2014 07:35:43 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s8F7Vii1006742; Mon, 15 Sep 2014 03:31:44 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s8F7Vg1b031222 for ; Mon, 15 Sep 2014 03:31:42 -0400 Received: from mx1.redhat.com (ext-mx15.extmail.prod.ext.phx2.redhat.com [10.5.110.20]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s8F7VgNV008506 for ; Mon, 15 Sep 2014 03:31:42 -0400 Received: from mail-pd0-f178.google.com (mail-pd0-f178.google.com [209.85.192.178]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s8F7VcO2001388 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=FAIL) for ; Mon, 15 Sep 2014 03:31:39 -0400 Received: by mail-pd0-f178.google.com with SMTP id p10so5631357pdj.37 for ; Mon, 15 Sep 2014 00:31:38 -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=r+n4cYT6O5uLSekFvf+unIzZbPVXAT6rGcrWCviRtTk=; b=BIjZFBCR8sdLNUkKv/KrprVFAe76gDTb7Bw4Mqk5mI3k4w/v08xvnkM9FTalC/9QQn KzcOFwwYMqHk2TTT0ioyPZKBxPlCthAOd3mHfaFmanCO0SsRF8xQA8CHmC6vN8Q12jGG UF13jaclyoj7hTMtttn4zgSGPoL6LwtMb6xg8= 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=r+n4cYT6O5uLSekFvf+unIzZbPVXAT6rGcrWCviRtTk=; b=TZRgpgNNd3s3mYRysWE27Do1LasK9aWuLE/5TqsAOXtWp918Edu2P/tOCP5aHh7Si2 l0YLciH+QiU9+zIblCJbxpy0RI+HySdloX6V5J7iqf/iSqDwXmI8SCPuBhbBuKh7svr0 CAlro0SnJ2xmU8c+4g7WALVhcJEEz9aDHwSVCny1J9pWg+XI4xVeWfkBZgLMyCOvOJD+ WJBnln4WGK7vRlsWGi+9lWaBmSpzjuvG5TPFkPBBKxhiXFcl54qbexS3a8kl99hHH5a8 bEndxKIYZYUD9FghsqWcYjpYUsxaHRnMqKgiNZ6HnqNsQ/j1WTdhtY8F3VR1w/qVsLyG CPJQ== X-Gm-Message-State: ALoCoQmZ6j0oHPILrSU2LT0JnTgOXn9QpDIr2YwA3SpnrwW7mxpI9b3L5AxpHa6vv62E5pWEofyy X-Received: by 10.68.220.71 with SMTP id pu7mr37214003pbc.22.1410766297982; Mon, 15 Sep 2014 00:31:37 -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.35 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Sep 2014 00:31:36 -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 Date: Mon, 15 Sep 2014 00:30:28 -0700 Message-Id: <1410766234-1634-7-git-send-email-behanw@converseincode.com> In-Reply-To: <1410766234-1634-1-git-send-email-behanw@converseincode.com> References: <1410766234-1634-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.27 X-Scanned-By: MIMEDefang 2.68 on 10.5.110.20 X-loop: dm-devel@redhat.com Cc: thomas.lendacky@amd.com, linux-ima-user@lists.sourceforge.net, qat-linux@intel.com, d.kasatkin@samsung.com, bruce.w.allan@intel.com, linux-kernel@vger.kernel.org, john.griffin@intel.com, linux-raid@vger.kernel.org, linux-security-module@vger.kernel.org, Behan Webster , linux-crypto@vger.kernel.org, james.l.morris@oracle.com, torvalds@linux-foundation.org, linux-ima-devel@lists.sourceforge.net, akpm@linux-foundation.org, zohar@linux.vnet.ibm.com, linux-btrfs@vger.kernel.org, serge@hallyn.com Subject: [dm-devel] [PATCH v3 06/12] crypto: LLVMLinux: Remove VLAIS from crypto/omap_sham.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=-3.1 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: Behan Webster Replaced the use of a Variable Length Array In Struct (VLAIS) with a C99 compliant equivalent. This patch 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: Behan Webster Reviewed-by: Mark Charlebois Reviewed-by: Jan-Simon Möller --- drivers/crypto/omap-sham.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/drivers/crypto/omap-sham.c b/drivers/crypto/omap-sham.c index 710d863..24ef489 100644 --- a/drivers/crypto/omap-sham.c +++ b/drivers/crypto/omap-sham.c @@ -949,17 +949,14 @@ static int omap_sham_finish_hmac(struct ahash_request *req) struct omap_sham_hmac_ctx *bctx = tctx->base; int bs = crypto_shash_blocksize(bctx->shash); int ds = crypto_shash_digestsize(bctx->shash); - struct { - struct shash_desc shash; - char ctx[crypto_shash_descsize(bctx->shash)]; - } desc; + SHASH_DESC_ON_STACK(shash, bctx->shash); - desc.shash.tfm = bctx->shash; - desc.shash.flags = 0; /* not CRYPTO_TFM_REQ_MAY_SLEEP */ + shash->tfm = bctx->shash; + shash->flags = 0; /* not CRYPTO_TFM_REQ_MAY_SLEEP */ - return crypto_shash_init(&desc.shash) ?: - crypto_shash_update(&desc.shash, bctx->opad, bs) ?: - crypto_shash_finup(&desc.shash, req->result, ds, req->result); + return crypto_shash_init(shash) ?: + crypto_shash_update(shash, bctx->opad, bs) ?: + crypto_shash_finup(shash, req->result, ds, req->result); } static int omap_sham_finish(struct ahash_request *req) @@ -1118,18 +1115,15 @@ static int omap_sham_update(struct ahash_request *req) return omap_sham_enqueue(req, OP_UPDATE); } -static int omap_sham_shash_digest(struct crypto_shash *shash, u32 flags, +static int omap_sham_shash_digest(struct crypto_shash *tfm, u32 flags, const u8 *data, unsigned int len, u8 *out) { - struct { - struct shash_desc shash; - char ctx[crypto_shash_descsize(shash)]; - } desc; + SHASH_DESC_ON_STACK(shash, tfm); - desc.shash.tfm = shash; - desc.shash.flags = flags & CRYPTO_TFM_REQ_MAY_SLEEP; + shash->tfm = tfm; + shash->flags = flags & CRYPTO_TFM_REQ_MAY_SLEEP; - return crypto_shash_digest(&desc.shash, data, len, out); + return crypto_shash_digest(shash, data, len, out); } static int omap_sham_final_shash(struct ahash_request *req)