mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vladimir Oltean <olteanv@gmail.com>
To: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Cc: andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com,
	davem@davemloft.net, kuba@kernel.org, linux@armlinux.org.uk,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net: dsa: Remove unsigned expression compared with zero
Date: Wed, 19 May 2021 21:24:00 +0300	[thread overview]
Message-ID: <20210519182400.nnek4dp5wwvabnwf@skbuf> (raw)
In-Reply-To: <1621421391-36681-1-git-send-email-jiapeng.chong@linux.alibaba.com>

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@linux.alibaba.com>
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.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.

      reply	other threads:[~2021-05-19 18:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-19 10:49 Jiapeng Chong
2021-05-19 18:24 ` Vladimir Oltean [this message]

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=20210519182400.nnek4dp5wwvabnwf@skbuf \
    --to=olteanv@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=jiapeng.chong@linux.alibaba.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=vivien.didelot@gmail.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

all inboxes | Powered by JetHome®