Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp7039717ybn; Mon, 30 Sep 2019 07:46:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqwlQYGprnY60Q5gpH63fdOM9HxhEeum579w1k7R7ah7YBnxlxfaMA8vxmp2s5ekmvNWLzWS X-Received: by 2002:a17:907:441d:: with SMTP id om21mr20217278ejb.188.1569854807248; Mon, 30 Sep 2019 07:46:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569854807; cv=none; d=google.com; s=arc-20160816; b=kQgX0pTbJUDuBJA/Zi+wtmtAyvTsSejj6L3QanxhTzn0Ct/MNHgXL3u57qQXCAty5w xdbdippe9X1J2G9rVT4vUMndAHaq371KndUHhs72hncaMPSSfrefX8artX41RnSXxrpW 8GxRNOrN4b7LXRc1CDrwMcX7EJ9PUxFq1lBgUemU20TtmBOUwjjHmnBz0x7jWe/rO/yW uf3L3DxyuRLoqUR2s46p4NEE78qnVneQV+6IVLkD9+x9Dyf67+kOfmlEpPx7IozdfYTX Pt8r0N5xdH/arHc1VYcFEbcKP5cOMJjdyQZWZ/+XGr0sgk+pdZiBffoz/Pq8EoyIUSJY aD/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=ZEnA1JxZvE6cJn9eqnVbTl63i3wViWbB8YmTdI/2NbE=; b=ja+JaDk7jLW+vPBXWvin8alZP0KtWdA23aPlEEujNfAJ2YCyTNNrMgV+toRHkbgmAF hwlKVyKnj9QEuMhXPz1YvasZoisqpYsvtCPbTp+iNAt8q5xBdA34SkLpkwhpODX5GuKE B6QgvAeJYuRmnODcext/jkBsPHEmkD74uuUjfS8lIwCYXR0wN3IxMHKPKgJIUzYVq4sh zl0x8yE6iUejDqYY710ZfhMeQAOCsc0MO7uiGNoDTf9k9z620yjEsv+2Hv8evF/X4SSn 3joWUiNu9ExWrRuHieT4bi3UoFYwwKbza18291uQDaerzCd9rbu+SOaskk+2dOEMCIKx jjsQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l15si6987239eja.290.2019.09.30.07.46.16; Mon, 30 Sep 2019 07:46:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731441AbfI3Ooa (ORCPT + 99 others); Mon, 30 Sep 2019 10:44:30 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:3196 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730809AbfI3Ooa (ORCPT ); Mon, 30 Sep 2019 10:44:30 -0400 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 5854182C76215ADB9DD0; Mon, 30 Sep 2019 22:44:26 +0800 (CST) Received: from localhost (10.202.226.61) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.439.0; Mon, 30 Sep 2019 22:44:18 +0800 Date: Mon, 30 Sep 2019 15:44:05 +0100 From: Jonathan Cameron To: Tian Tao CC: , , , , Subject: Re: [PATCH] crypto: fix comparison of unsigned expression warnings Message-ID: <20190930154405.00004187@huawei.com> In-Reply-To: <20190930151702.0000131f@huawei.com> References: <1569833361-47224-1-git-send-email-tiantao6@huawei.com> <20190930151702.0000131f@huawei.com> Organization: Huawei X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; i686-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.202.226.61] X-CFilter-Loop: Reflected Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Mon, 30 Sep 2019 15:17:02 +0100 Jonathan Cameron wrote: > On Mon, 30 Sep 2019 16:49:21 +0800 > Tian Tao wrote: > > > This patch fixes the following warnings: > > drivers/crypto/ccree/cc_aead.c:630:5-12: WARNING: Unsigned expression > > compared with zero: seq_len > 0 > > > > Signed-off-by: Tian Tao > > Apologies, I should have looked into this in more depth when you asked > me about it earlier rather than assuming it was 'obviously' the right > fix. > > It's more complex than I expected given the warning, which I note > is > 0 so it's not always true. I'm curious, which compiler generates > that warning? > > So there are two ways seq_len can be set to non 0, hmac_setkey which returns a > signed int, but one that is reality is >= 0. The other is xcbc_setkey > which returns an unsigned int. > > So I would suggest that in addition to what you have here, a change > to the return type of hmac_setkey in order to make it clear that > never returns a negative anyway. Hmm. Perhaps I shouldn't review with jetlag... That should have said that I think the variable should be left unsigned as reality is that it is always >= 0. > > Can also use if (seq_len) > rather than if (seq_len > 0) > > Thanks, > > Jonathan > > > > > --- > > drivers/crypto/ccree/cc_aead.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/crypto/ccree/cc_aead.c b/drivers/crypto/ccree/cc_aead.c > > index d3e8faa..b19291d 100644 > > --- a/drivers/crypto/ccree/cc_aead.c > > +++ b/drivers/crypto/ccree/cc_aead.c > > @@ -546,7 +546,7 @@ static int cc_aead_setkey(struct crypto_aead *tfm, const u8 *key, > > struct cc_aead_ctx *ctx = crypto_aead_ctx(tfm); > > struct cc_crypto_req cc_req = {}; > > struct cc_hw_desc desc[MAX_AEAD_SETKEY_SEQ]; > > - unsigned int seq_len = 0; > > + int seq_len = 0; > > struct device *dev = drvdata_to_dev(ctx->drvdata); > > const u8 *enckey, *authkey; > > int rc; >