linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] power: supply: sbs-battery: Fix a signedness bug in sbs_get_battery_capacity()
@ 2019-09-25 11:01 Dan Carpenter
  2019-10-20 21:14 ` Sebastian Reichel
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2019-09-25 11:01 UTC (permalink / raw)
  To: Sebastian Reichel, Rhyland Klein; +Cc: linux-pm, linux-kernel, kernel-janitors

The "mode" variable is an enum and in this context GCC treats it as an
unsigned int so the error handling is never triggered.

Fixes: 51d075660457 ("bq20z75: Add support for charge properties")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/power/supply/sbs-battery.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/power/supply/sbs-battery.c b/drivers/power/supply/sbs-battery.c
index f8d74e9f7931..62110af1abcf 100644
--- a/drivers/power/supply/sbs-battery.c
+++ b/drivers/power/supply/sbs-battery.c
@@ -555,7 +555,7 @@ static int sbs_get_battery_capacity(struct i2c_client *client,
 		mode = BATTERY_MODE_AMPS;
 
 	mode = sbs_set_battery_mode(client, mode);
-	if (mode < 0)
+	if ((int)mode < 0)
 		return mode;
 
 	ret = sbs_read_word_data(client, sbs_data[reg_offset].addr);
-- 
2.20.1


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

* Re: [PATCH] power: supply: sbs-battery: Fix a signedness bug in sbs_get_battery_capacity()
  2019-09-25 11:01 [PATCH] power: supply: sbs-battery: Fix a signedness bug in sbs_get_battery_capacity() Dan Carpenter
@ 2019-10-20 21:14 ` Sebastian Reichel
  0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Reichel @ 2019-10-20 21:14 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Rhyland Klein, linux-pm, linux-kernel, kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 1024 bytes --]

Hi,

On Wed, Sep 25, 2019 at 02:01:28PM +0300, Dan Carpenter wrote:
> The "mode" variable is an enum and in this context GCC treats it as an
> unsigned int so the error handling is never triggered.
> 
> Fixes: 51d075660457 ("bq20z75: Add support for charge properties")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---

Thanks, queued.

-- Sebastian

>  drivers/power/supply/sbs-battery.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/power/supply/sbs-battery.c b/drivers/power/supply/sbs-battery.c
> index f8d74e9f7931..62110af1abcf 100644
> --- a/drivers/power/supply/sbs-battery.c
> +++ b/drivers/power/supply/sbs-battery.c
> @@ -555,7 +555,7 @@ static int sbs_get_battery_capacity(struct i2c_client *client,
>  		mode = BATTERY_MODE_AMPS;
>  
>  	mode = sbs_set_battery_mode(client, mode);
> -	if (mode < 0)
> +	if ((int)mode < 0)
>  		return mode;
>  
>  	ret = sbs_read_word_data(client, sbs_data[reg_offset].addr);
> -- 
> 2.20.1
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2019-10-20 21:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-25 11:01 [PATCH] power: supply: sbs-battery: Fix a signedness bug in sbs_get_battery_capacity() Dan Carpenter
2019-10-20 21:14 ` Sebastian Reichel

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