From: Jonathan Cameron <jonathan.cameron@huawei.com>
To: Tian Tao <tiantao6@huawei.com>
Cc: <gilad@benyossef.com>, <herbert@gondor.apana.org.au>,
<davem@davemloft.net>, <linux-crypto@vger.kernel.org>,
<linuxarm@huawei.com>
Subject: Re: [PATCH] crypto: fix comparison of unsigned expression warnings
Date: Mon, 30 Sep 2019 15:17:02 +0100 [thread overview]
Message-ID: <20190930151702.0000131f@huawei.com> (raw)
In-Reply-To: <1569833361-47224-1-git-send-email-tiantao6@huawei.com>
On Mon, 30 Sep 2019 16:49:21 +0800
Tian Tao <tiantao6@huawei.com> 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 <tiantao6@huawei.com>
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.
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;
next prev parent reply other threads:[~2019-09-30 14:17 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-30 8:49 [PATCH] crypto: fix comparison of unsigned expression warnings Tian Tao
2019-09-30 14:17 ` Jonathan Cameron [this message]
2019-09-30 14:44 ` Jonathan Cameron
2019-10-02 10:00 ` Gilad Ben-Yossef
2019-10-08 1:00 ` 答复: " tiantao (H)
2019-10-17 13:45 ` Gilad Ben-Yossef
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190930151702.0000131f@huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=davem@davemloft.net \
--cc=gilad@benyossef.com \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=tiantao6@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).