linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] phy: rockchip-typec: Fix unsigned comparison with less than zero
@ 2023-02-07  5:26 Jiapeng Chong
  2023-02-10 16:54 ` Vinod Koul
  0 siblings, 1 reply; 2+ messages in thread
From: Jiapeng Chong @ 2023-02-07  5:26 UTC (permalink / raw)
  To: vkoul
  Cc: kishon, heiko, p.zabel, linux-phy, linux-arm-kernel,
	linux-rockchip, linux-kernel, Jiapeng Chong, Abaci Robot

The dp is defined as bool type, the return value type of function
extcon_get_state should be int, at the same time,if(dp>0) is used as the
conditional statement, so the type of dp is modified to int.

./drivers/phy/rockchip/phy-rockchip-typec.c:827:12-14: WARNING: Unsigned expression compared with zero: dp > 0.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=3962
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
 drivers/phy/rockchip/phy-rockchip-typec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/phy/rockchip/phy-rockchip-typec.c b/drivers/phy/rockchip/phy-rockchip-typec.c
index 6aea512e5d4e..85ed7d510cbf 100644
--- a/drivers/phy/rockchip/phy-rockchip-typec.c
+++ b/drivers/phy/rockchip/phy-rockchip-typec.c
@@ -808,9 +808,9 @@ static int tcphy_get_mode(struct rockchip_typec_phy *tcphy)
 	struct extcon_dev *edev = tcphy->extcon;
 	union extcon_property_value property;
 	unsigned int id;
-	bool ufp, dp;
+	bool ufp;
 	u8 mode;
-	int ret;
+	int ret, dp;
 
 	if (!edev)
 		return MODE_DFP_USB;
-- 
2.20.1.7.g153144c


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] phy: rockchip-typec: Fix unsigned comparison with less than zero
  2023-02-07  5:26 [PATCH] phy: rockchip-typec: Fix unsigned comparison with less than zero Jiapeng Chong
@ 2023-02-10 16:54 ` Vinod Koul
  0 siblings, 0 replies; 2+ messages in thread
From: Vinod Koul @ 2023-02-10 16:54 UTC (permalink / raw)
  To: Jiapeng Chong
  Cc: kishon, heiko, p.zabel, linux-phy, linux-arm-kernel,
	linux-rockchip, linux-kernel, Abaci Robot

On 07-02-23, 13:26, Jiapeng Chong wrote:
> The dp is defined as bool type, the return value type of function
> extcon_get_state should be int, at the same time,if(dp>0) is used as the
> conditional statement, so the type of dp is modified to int.
> 
> ./drivers/phy/rockchip/phy-rockchip-typec.c:827:12-14: WARNING: Unsigned expression compared with zero: dp > 0.

You should see same error for ufp as well, that also stores return of
extcon_get_state()

> 
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=3962
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
> ---
>  drivers/phy/rockchip/phy-rockchip-typec.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/phy/rockchip/phy-rockchip-typec.c b/drivers/phy/rockchip/phy-rockchip-typec.c
> index 6aea512e5d4e..85ed7d510cbf 100644
> --- a/drivers/phy/rockchip/phy-rockchip-typec.c
> +++ b/drivers/phy/rockchip/phy-rockchip-typec.c
> @@ -808,9 +808,9 @@ static int tcphy_get_mode(struct rockchip_typec_phy *tcphy)
>  	struct extcon_dev *edev = tcphy->extcon;
>  	union extcon_property_value property;
>  	unsigned int id;
> -	bool ufp, dp;
> +	bool ufp;
>  	u8 mode;
> -	int ret;
> +	int ret, dp;
>  
>  	if (!edev)
>  		return MODE_DFP_USB;
> -- 
> 2.20.1.7.g153144c

-- 
~Vinod

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-02-10 16:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-07  5:26 [PATCH] phy: rockchip-typec: Fix unsigned comparison with less than zero Jiapeng Chong
2023-02-10 16:54 ` Vinod Koul

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).