[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20210519182400.nnek4dp5wwvabnwf@skbuf>
Date: Wed, 19 May 2021 21:24:00 +0300
From: Vladimir Oltean <olteanv@...il.com>
To: Jiapeng Chong <jiapeng.chong@...ux.alibaba.com>
Cc: andrew@...n.ch, vivien.didelot@...il.com, f.fainelli@...il.com,
davem@...emloft.net, kuba@...nel.org, linux@...linux.org.uk,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] net: dsa: Remove unsigned expression compared with zero
Hi Jiapeng,
On Wed, May 19, 2021 at 06:49:51PM +0800, Jiapeng Chong wrote:
> Variable val is "u32" always >= 0, so val >= 0 condition are redundant.
>
> Clean up the following coccicheck warning:
>
> ./drivers/net/dsa/qca8k.c:732:5-8: WARNING: Unsigned expression compared
> with zero: val >= 0.
>
> Reported-by: Abaci Robot <abaci@...ux.alibaba.com>
> Signed-off-by: Jiapeng Chong <jiapeng.chong@...ux.alibaba.com>
> ---
> drivers/net/dsa/qca8k.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/net/dsa/qca8k.c b/drivers/net/dsa/qca8k.c
> index 4753228..7b38b8d 100644
> --- a/drivers/net/dsa/qca8k.c
> +++ b/drivers/net/dsa/qca8k.c
> @@ -729,8 +729,7 @@
>
> mutex_unlock(&bus->mdio_lock);
>
> - if (val >= 0)
> - val &= QCA8K_MDIO_MASTER_DATA_MASK;
> + val &= QCA8K_MDIO_MASTER_DATA_MASK;
>
> return val;
> }
> --
> 1.8.3.1
>
The qca8k driver has some problems with the handling of signed/unsigned
return values. I would suggest a better approach to be to make
qca8k_mii_read32 to return an int value, and keep this check as is.
Powered by blists - more mailing lists