Re: [PATCH] crypto: fix comparison of unsigned expression warnings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Sep 30, 2019 at 11:52 AM Tian Tao <tiantao6@xxxxxxxxxx> 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

Thank you very much for the patch. Please accept my apologies that it
took me some time to respond.

I'm sorry, but I don't think this is the right solution here:

seq_len here can never get a negative value so the warning is a false one.

Having said that, I suspect it would be better code to:
1. change hmac_setkey() return type to unsigned int as well, as it
doesn't ever return a negative number.
2. change the predicate in the if statement the warning mentions to
seq_len != 0.

That would be a clearer code and possibly will also silence the false warning

So NACK for this one but I would accept a patch doing he above if you send one.

Thanks again for taking the time to do this.

Gilad

>
> Signed-off-by: Tian Tao <tiantao6@xxxxxxxxxx>
> ---
>  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;
> --
> 2.7.4
>


-- 
Gilad Ben-Yossef
Chief Coffee Drinker

values of β will give rise to dom!




[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]

  Powered by Linux