From patchwork Fri Jan 8 11:24:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 7984601 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 336A3BEEE5 for ; Fri, 8 Jan 2016 11:24:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3D76520103 for ; Fri, 8 Jan 2016 11:24:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 224F8200FF for ; Fri, 8 Jan 2016 11:24:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751780AbcAHLYi (ORCPT ); Fri, 8 Jan 2016 06:24:38 -0500 Received: from foss.arm.com ([217.140.101.70]:44605 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754719AbcAHLYg (ORCPT ); Fri, 8 Jan 2016 06:24:36 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2AD1446A; Fri, 8 Jan 2016 03:24:02 -0800 (PST) Received: from e104803-lin.lan (unknown [10.1.203.153]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C13933F24D; Fri, 8 Jan 2016 03:24:33 -0800 (PST) From: Andre Przywara To: Corentin Labbe , Maxime Ripard , Chen-Yu Tsai , Arnd Bergmann Cc: Herbert Xu , "David S . Miller" , linux-sunxi@googlegroups.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org Subject: [RESEND PATCH 2/2] crypto: sunxi-ss-hash: promote variables to match types in min3() calls Date: Fri, 8 Jan 2016 11:24:09 +0000 Message-Id: <1452252249-12040-3-git-send-email-andre.przywara@arm.com> X-Mailer: git-send-email 2.6.4 In-Reply-To: <1452252249-12040-1-git-send-email-andre.przywara@arm.com> References: <1452252249-12040-1-git-send-email-andre.przywara@arm.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 (resending to add linux-crypto, patch unchanged) The min3() macro expects all arguments to be of the same type (or size at least). Change the type of some local variables in sun4i-ss-hash.c to size_t to match the type used in some generic structures we compare against. That shouldn't change anything for 32-bit (as size_t is unsigned int there anyway), but allows compilation for 64-bit architectures. There are two casts still necessary, because we can't change the type in a generic structure. Signed-off-by: Andre Przywara --- drivers/crypto/sunxi-ss/sun4i-ss-hash.c | 12 ++++++------ drivers/crypto/sunxi-ss/sun4i-ss.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/crypto/sunxi-ss/sun4i-ss-hash.c b/drivers/crypto/sunxi-ss/sun4i-ss-hash.c index ff80314..c0384f1 100644 --- a/drivers/crypto/sunxi-ss/sun4i-ss-hash.c +++ b/drivers/crypto/sunxi-ss/sun4i-ss-hash.c @@ -170,7 +170,7 @@ int sun4i_hash_update(struct ahash_request *areq) struct sun4i_ss_ctx *ss = op->ss; struct crypto_ahash *tfm = crypto_ahash_reqtfm(areq); unsigned int in_i = 0; /* advancement in the current SG */ - unsigned int end; + size_t end; /* * end is the position when we need to stop writing to the device, * to be compared to i @@ -181,7 +181,7 @@ int sun4i_hash_update(struct ahash_request *areq) size_t copied = 0; struct sg_mapping_iter mi; - dev_dbg(ss->dev, "%s %s bc=%llu len=%u mode=%x wl=%u h0=%0x", + dev_dbg(ss->dev, "%s %s bc=%llu len=%u mode=%x wl=%zu h0=%0x", __func__, crypto_tfm_alg_name(areq->base.tfm), op->byte_count, areq->nbytes, op->mode, op->len, op->hash[0]); @@ -206,7 +206,7 @@ int sun4i_hash_update(struct ahash_request *areq) end = ((areq->nbytes + op->len) / 64) * 64 - op->len; if (end > areq->nbytes || areq->nbytes - end > 63) { - dev_err(ss->dev, "ERROR: Bound error %u %u\n", + dev_err(ss->dev, "ERROR: Bound error %zu %u\n", end, areq->nbytes); return -EINVAL; } @@ -266,7 +266,7 @@ int sun4i_hash_update(struct ahash_request *areq) } if (mi.length - in_i > 3 && i < end) { /* how many bytes we can read from current SG */ - in_r = min3(mi.length - in_i, areq->nbytes - i, + in_r = min3(mi.length - in_i, (size_t)areq->nbytes - i, ((mi.length - in_i) / 4) * 4); /* how many bytes we can write in the device*/ todo = min3((u32)(end - i) / 4, rx_cnt, (u32)in_r / 4); @@ -289,7 +289,7 @@ int sun4i_hash_update(struct ahash_request *areq) if ((areq->nbytes - i) < 64) { while (i < areq->nbytes && in_i < mi.length && op->len < 64) { /* how many bytes we can read from current SG */ - in_r = min3(mi.length - in_i, areq->nbytes - i, + in_r = min3(mi.length - in_i, (size_t)areq->nbytes - i, 64 - op->len); memcpy(op->buf + op->len, mi.addr + in_i, in_r); op->len += in_r; @@ -352,7 +352,7 @@ int sun4i_hash_final(struct ahash_request *areq) u32 wb = 0; unsigned int nwait, nbw = 0; - dev_dbg(ss->dev, "%s: byte=%llu len=%u mode=%x wl=%u h=%x", + dev_dbg(ss->dev, "%s: byte=%llu len=%u mode=%x wl=%zu h=%x", __func__, op->byte_count, areq->nbytes, op->mode, op->len, op->hash[0]); diff --git a/drivers/crypto/sunxi-ss/sun4i-ss.h b/drivers/crypto/sunxi-ss/sun4i-ss.h index 8e9c05f..c15fa21 100644 --- a/drivers/crypto/sunxi-ss/sun4i-ss.h +++ b/drivers/crypto/sunxi-ss/sun4i-ss.h @@ -162,7 +162,7 @@ struct sun4i_req_ctx { u64 byte_count; /* number of bytes "uploaded" to the device */ u32 hash[5]; /* for storing SS_IVx register */ char buf[64]; - unsigned int len; + size_t len; struct sun4i_ss_ctx *ss; };