* [PATCH] power: supply: rk817: Fix unsigned comparison with less than zero
@ 2022-12-13 10:19 Jiapeng Chong
2022-12-13 14:41 ` Chris Morgan
0 siblings, 1 reply; 2+ messages in thread
From: Jiapeng Chong @ 2022-12-13 10:19 UTC (permalink / raw)
To: sre; +Cc: linux-pm, linux-kernel, Jiapeng Chong, Abaci Robot
The tmp is defined as u32 type, which results in invalid processing of
tmp<0 in function rk817_read_or_set_full_charge_on_boot(). Therefore,
change the tmp type to int.
drivers/power/supply/rk817_charger.c:828 rk817_read_or_set_full_charge_on_boot() warn: unsigned 'tmp' is never less than zero.
drivers/power/supply/rk817_charger.c:788 rk817_read_or_set_full_charge_on_boot() warn: unsigned 'tmp' is never less than zero.
Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=3444
Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
drivers/power/supply/rk817_charger.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/power/supply/rk817_charger.c b/drivers/power/supply/rk817_charger.c
index 4f9c1c417916..7eefbcc0a4e9 100644
--- a/drivers/power/supply/rk817_charger.c
+++ b/drivers/power/supply/rk817_charger.c
@@ -731,8 +731,8 @@ rk817_read_or_set_full_charge_on_boot(struct rk817_charger *charger,
{
struct rk808 *rk808 = charger->rk808;
u8 bulk_reg[4];
- u32 boot_voltage, boot_charge_mah, tmp;
- int ret, reg, off_time;
+ u32 boot_voltage, boot_charge_mah;
+ int ret, reg, off_time, tmp;
bool first_boot;
/*
--
2.20.1.7.g153144c
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] power: supply: rk817: Fix unsigned comparison with less than zero
2022-12-13 10:19 [PATCH] power: supply: rk817: Fix unsigned comparison with less than zero Jiapeng Chong
@ 2022-12-13 14:41 ` Chris Morgan
0 siblings, 0 replies; 2+ messages in thread
From: Chris Morgan @ 2022-12-13 14:41 UTC (permalink / raw)
To: Jiapeng Chong; +Cc: sre, linux-pm, linux-kernel, Abaci Robot
On Tue, Dec 13, 2022 at 06:19:04PM +0800, Jiapeng Chong wrote:
> The tmp is defined as u32 type, which results in invalid processing of
> tmp<0 in function rk817_read_or_set_full_charge_on_boot(). Therefore,
> change the tmp type to int.
Good catch, but I'm wondering if we shouldn't just drop the comparison
to less than zero? If I'm not mistaken get_unaligned_be32() only
returns unsigned integers anyway, right?
Assuming my understanding is right, we'll just drop the comparison.
Otherwise, this would be the appropriate fix.
Thank you for catching this!
Chris
>
> drivers/power/supply/rk817_charger.c:828 rk817_read_or_set_full_charge_on_boot() warn: unsigned 'tmp' is never less than zero.
> drivers/power/supply/rk817_charger.c:788 rk817_read_or_set_full_charge_on_boot() warn: unsigned 'tmp' is never less than zero.
>
> Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=3444
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
> ---
> drivers/power/supply/rk817_charger.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/power/supply/rk817_charger.c b/drivers/power/supply/rk817_charger.c
> index 4f9c1c417916..7eefbcc0a4e9 100644
> --- a/drivers/power/supply/rk817_charger.c
> +++ b/drivers/power/supply/rk817_charger.c
> @@ -731,8 +731,8 @@ rk817_read_or_set_full_charge_on_boot(struct rk817_charger *charger,
> {
> struct rk808 *rk808 = charger->rk808;
> u8 bulk_reg[4];
> - u32 boot_voltage, boot_charge_mah, tmp;
> - int ret, reg, off_time;
> + u32 boot_voltage, boot_charge_mah;
> + int ret, reg, off_time, tmp;
> bool first_boot;
>
> /*
> --
> 2.20.1.7.g153144c
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-12-13 14:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-13 10:19 [PATCH] power: supply: rk817: Fix unsigned comparison with less than zero Jiapeng Chong
2022-12-13 14:41 ` Chris Morgan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox