From patchwork Mon Sep 15 07:30:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Behan Webster X-Patchwork-Id: 37404 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 73C87218C0 for ; Mon, 15 Sep 2014 07:32:03 +0000 (UTC) Received: by mail-wi0-f198.google.com with SMTP id cc10sf1761226wib.1 for ; Mon, 15 Sep 2014 00:31:58 -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=gr9zBcfZOc5339HZ2bEhxjpfdArr8LTU5DYpQPyQzsE=; b=CcgBun3Yw1Tqpfrae/3BwvZtxP9LxvWPeOTHpRTi/Xv/1ZK2zKK6pp2BcsbUs9pUI1 YcWRDhvuFgvtFS6Y7Cjmrj8zcGVt3aprYksl6P/Afia/0Dl82M848iL1chTFQd1Pb056 iZzOoATOJxSUWvlhhVYyXBrzh2QhX/S4q7uV8qFNUFgfbeMB2mndsjxi2ORwFrLSgCno rFpauTjPt44OuIU4K7XxeUyupZjIatmm+8PeT3ylyFHZidsm5idX7+Ln+P8MuPrUUtuY us4XgI5l30DbJCNjuHpe5PrYLC+QMHKEGXNYXV/pzCHnKthjgvl/vK7DpbPaozgYYQYG cdOA== X-Gm-Message-State: ALoCoQnE8tIqGXYwMmqzHPi3HOJO7J5O4hT5PW4N7eqOcJuwng/Iwsa2QLNYeO+RW1wqz8VbXiyF X-Received: by 10.112.122.71 with SMTP id lq7mr175586lbb.16.1410766318885; Mon, 15 Sep 2014 00:31:58 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.28.39 with SMTP id y7ls346368lag.0.gmail; Mon, 15 Sep 2014 00:31:58 -0700 (PDT) X-Received: by 10.152.20.1 with SMTP id j1mr25903103lae.57.1410766318620; Mon, 15 Sep 2014 00:31:58 -0700 (PDT) Received: from mail-la0-x22b.google.com (mail-la0-x22b.google.com [2a00:1450:4010:c03::22b]) by mx.google.com with ESMTPS id ba4si17603303lab.45.2014.09.15.00.31.58 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 15 Sep 2014 00:31:58 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::22b as permitted sender) client-ip=2a00:1450:4010:c03::22b; Received: by mail-la0-f43.google.com with SMTP id gi9so4050852lab.2 for ; Mon, 15 Sep 2014 00:31:58 -0700 (PDT) X-Received: by 10.112.53.230 with SMTP id e6mr883160lbp.100.1410766318193; Mon, 15 Sep 2014 00:31:58 -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.112.130.169 with SMTP id of9csp161630lbb; Mon, 15 Sep 2014 00:31:57 -0700 (PDT) X-Received: by 10.70.132.167 with SMTP id ov7mr37038286pdb.45.1410766315020; Mon, 15 Sep 2014 00:31:55 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ra1si21020713pbb.187.2014.09.15.00.31.53 for ; Mon, 15 Sep 2014 00:31:55 -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 S1753406AbaIOHbg (ORCPT + 27 others); Mon, 15 Sep 2014 03:31:36 -0400 Received: from mail-pa0-f44.google.com ([209.85.220.44]:33552 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753375AbaIOHbc (ORCPT ); Mon, 15 Sep 2014 03:31:32 -0400 Received: by mail-pa0-f44.google.com with SMTP id kx10so5797666pab.17 for ; Mon, 15 Sep 2014 00:31:32 -0700 (PDT) X-Received: by 10.66.174.17 with SMTP id bo17mr34856604pac.98.1410766292175; Mon, 15 Sep 2014 00:31:32 -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.29 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Sep 2014 00:31:30 -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 04/12] crypto: LLVMLinux: Remove VLAIS from crypto/mv_cesa.c Date: Mon, 15 Sep 2014 00:30:26 -0700 Message-Id: <1410766234-1634-5-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> 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 2a00:1450:4010:c03::22b 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: 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/mv_cesa.c | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/drivers/crypto/mv_cesa.c b/drivers/crypto/mv_cesa.c index 29d0ee5..032c72c 100644 --- a/drivers/crypto/mv_cesa.c +++ b/drivers/crypto/mv_cesa.c @@ -402,26 +402,23 @@ static int mv_hash_final_fallback(struct ahash_request *req) { const struct mv_tfm_hash_ctx *tfm_ctx = crypto_tfm_ctx(req->base.tfm); struct mv_req_hash_ctx *req_ctx = ahash_request_ctx(req); - struct { - struct shash_desc shash; - char ctx[crypto_shash_descsize(tfm_ctx->fallback)]; - } desc; + SHASH_DESC_ON_STACK(shash, tfm_ctx->fallback); int rc; - desc.shash.tfm = tfm_ctx->fallback; - desc.shash.flags = CRYPTO_TFM_REQ_MAY_SLEEP; + shash->tfm = tfm_ctx->fallback; + shash->flags = CRYPTO_TFM_REQ_MAY_SLEEP; if (unlikely(req_ctx->first_hash)) { - crypto_shash_init(&desc.shash); - crypto_shash_update(&desc.shash, req_ctx->buffer, + crypto_shash_init(shash); + crypto_shash_update(shash, req_ctx->buffer, req_ctx->extra_bytes); } else { /* only SHA1 for now.... */ - rc = mv_hash_import_sha1_ctx(req_ctx, &desc.shash); + rc = mv_hash_import_sha1_ctx(req_ctx, shash); if (rc) goto out; } - rc = crypto_shash_final(&desc.shash, req->result); + rc = crypto_shash_final(shash, req->result); out: return rc; } @@ -794,23 +791,21 @@ static int mv_hash_setkey(struct crypto_ahash *tfm, const u8 * key, ss = crypto_shash_statesize(ctx->base_hash); { - struct { - struct shash_desc shash; - char ctx[crypto_shash_descsize(ctx->base_hash)]; - } desc; + SHASH_DESC_ON_STACK(shash, ctx->base_hash); + unsigned int i; char ipad[ss]; char opad[ss]; - desc.shash.tfm = ctx->base_hash; - desc.shash.flags = crypto_shash_get_flags(ctx->base_hash) & + shash->tfm = ctx->base_hash; + shash->flags = crypto_shash_get_flags(ctx->base_hash) & CRYPTO_TFM_REQ_MAY_SLEEP; if (keylen > bs) { int err; err = - crypto_shash_digest(&desc.shash, key, keylen, ipad); + crypto_shash_digest(shash, key, keylen, ipad); if (err) return err; @@ -826,12 +821,12 @@ static int mv_hash_setkey(struct crypto_ahash *tfm, const u8 * key, opad[i] ^= 0x5c; } - rc = crypto_shash_init(&desc.shash) ? : - crypto_shash_update(&desc.shash, ipad, bs) ? : - crypto_shash_export(&desc.shash, ipad) ? : - crypto_shash_init(&desc.shash) ? : - crypto_shash_update(&desc.shash, opad, bs) ? : - crypto_shash_export(&desc.shash, opad); + rc = crypto_shash_init(shash) ? : + crypto_shash_update(shash, ipad, bs) ? : + crypto_shash_export(shash, ipad) ? : + crypto_shash_init(shash) ? : + crypto_shash_update(shash, opad, bs) ? : + crypto_shash_export(shash, opad); if (rc == 0) mv_hash_init_ivs(ctx, ipad, opad);