On Mon, 30 Sep 2019 16:49:21 +0800
Tian Tao <tiant...@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 <tiant...@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;


Reply via email to