Linux Input/HID development
 help / color / mirror / Atom feed
* [PATCH][next] Input: qt1050: fix less than zero comparison on an unsigned int
@ 2019-05-07  8:21 Colin King
  2019-05-07  8:27 ` Dan Carpenter
  2019-05-07  8:32 ` Marco Felsch
  0 siblings, 2 replies; 4+ messages in thread
From: Colin King @ 2019-05-07  8:21 UTC (permalink / raw)
  To: Dmitry Torokhov, Rob Herring, Marco Felsch, linux-input
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

Currently the less than zero comparison of val is always false because
val is an unsigned int. Fix this by making val a signed int.

Addresses-Coverity: ("Unsigned compared against zero")
Fixes: a33ff45923c8 ("Input: qt1050 - add Microchip AT42QT1050 support")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/input/keyboard/qt1050.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/keyboard/qt1050.c b/drivers/input/keyboard/qt1050.c
index 6b1603cb7515..4debddb13972 100644
--- a/drivers/input/keyboard/qt1050.c
+++ b/drivers/input/keyboard/qt1050.c
@@ -222,7 +222,7 @@ static struct regmap_config qt1050_regmap_config = {
 
 static bool qt1050_identify(struct qt1050_priv *ts)
 {
-	unsigned int val;
+	int val;
 
 	/* Read Chip ID */
 	regmap_read(ts->regmap, QT1050_CHIP_ID, &val);
-- 
2.20.1

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

* Re: [PATCH][next] Input: qt1050: fix less than zero comparison on an unsigned int
  2019-05-07  8:21 [PATCH][next] Input: qt1050: fix less than zero comparison on an unsigned int Colin King
@ 2019-05-07  8:27 ` Dan Carpenter
  2019-05-07  8:32 ` Marco Felsch
  1 sibling, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2019-05-07  8:27 UTC (permalink / raw)
  To: Colin King
  Cc: Dmitry Torokhov, Rob Herring, Marco Felsch, linux-input,
	kernel-janitors, linux-kernel

On Tue, May 07, 2019 at 09:21:35AM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Currently the less than zero comparison of val is always false because
> val is an unsigned int. Fix this by making val a signed int.
> 
> Addresses-Coverity: ("Unsigned compared against zero")
> Fixes: a33ff45923c8 ("Input: qt1050 - add Microchip AT42QT1050 support")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/input/keyboard/qt1050.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/input/keyboard/qt1050.c b/drivers/input/keyboard/qt1050.c
> index 6b1603cb7515..4debddb13972 100644
> --- a/drivers/input/keyboard/qt1050.c
> +++ b/drivers/input/keyboard/qt1050.c
> @@ -222,7 +222,7 @@ static struct regmap_config qt1050_regmap_config = {
>  
>  static bool qt1050_identify(struct qt1050_priv *ts)
>  {
> -	unsigned int val;
> +	int val;

This code is checking the wrong thing anyway.  It should be:

	int ret;

	ret = regmap_read(&val);
	if (ret)
		return false;

regards,
dan carpenter

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

* Re: [PATCH][next] Input: qt1050: fix less than zero comparison on an unsigned int
  2019-05-07  8:21 [PATCH][next] Input: qt1050: fix less than zero comparison on an unsigned int Colin King
  2019-05-07  8:27 ` Dan Carpenter
@ 2019-05-07  8:32 ` Marco Felsch
  2019-05-07  8:46   ` Colin Ian King
  1 sibling, 1 reply; 4+ messages in thread
From: Marco Felsch @ 2019-05-07  8:32 UTC (permalink / raw)
  To: Colin King
  Cc: Dmitry Torokhov, Rob Herring, linux-input, kernel-janitors,
	linux-kernel

Hi Ian,

On 19-05-07 09:21, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Currently the less than zero comparison of val is always false because
> val is an unsigned int. Fix this by making val a signed int.

Thanks for covering that, was an copy 'n' paste failure..
> 
> Addresses-Coverity: ("Unsigned compared against zero")
> Fixes: a33ff45923c8 ("Input: qt1050 - add Microchip AT42QT1050 support")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/input/keyboard/qt1050.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/input/keyboard/qt1050.c b/drivers/input/keyboard/qt1050.c
> index 6b1603cb7515..4debddb13972 100644
> --- a/drivers/input/keyboard/qt1050.c
> +++ b/drivers/input/keyboard/qt1050.c
> @@ -222,7 +222,7 @@ static struct regmap_config qt1050_regmap_config = {
>  
>  static bool qt1050_identify(struct qt1050_priv *ts)
>  {
> -	unsigned int val;
> +	int val;

I think the proper solution is to add a ret val, because this covers the
success/fail. I will send a patch to fix this.

Regards,
  Marco

>  	/* Read Chip ID */
>  	regmap_read(ts->regmap, QT1050_CHIP_ID, &val);
> -- 
> 2.20.1
> 
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

* Re: [PATCH][next] Input: qt1050: fix less than zero comparison on an unsigned int
  2019-05-07  8:32 ` Marco Felsch
@ 2019-05-07  8:46   ` Colin Ian King
  0 siblings, 0 replies; 4+ messages in thread
From: Colin Ian King @ 2019-05-07  8:46 UTC (permalink / raw)
  To: Marco Felsch
  Cc: Dmitry Torokhov, Rob Herring, linux-input, kernel-janitors,
	linux-kernel

On 07/05/2019 09:32, Marco Felsch wrote:
> Hi Ian,
> 
> On 19-05-07 09:21, Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> Currently the less than zero comparison of val is always false because
>> val is an unsigned int. Fix this by making val a signed int.
> 
> Thanks for covering that, was an copy 'n' paste failure..
>>
>> Addresses-Coverity: ("Unsigned compared against zero")
>> Fixes: a33ff45923c8 ("Input: qt1050 - add Microchip AT42QT1050 support")
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>> ---
>>  drivers/input/keyboard/qt1050.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/input/keyboard/qt1050.c b/drivers/input/keyboard/qt1050.c
>> index 6b1603cb7515..4debddb13972 100644
>> --- a/drivers/input/keyboard/qt1050.c
>> +++ b/drivers/input/keyboard/qt1050.c
>> @@ -222,7 +222,7 @@ static struct regmap_config qt1050_regmap_config = {
>>  
>>  static bool qt1050_identify(struct qt1050_priv *ts)
>>  {
>> -	unsigned int val;
>> +	int val;
> 
> I think the proper solution is to add a ret val, because this covers the
> success/fail. I will send a patch to fix this.

OK, thanks for the follow-up fix.

Regards,
Colin

> 
> Regards,
>   Marco
> 
>>  	/* Read Chip ID */
>>  	regmap_read(ts->regmap, QT1050_CHIP_ID, &val);
>> -- 
>> 2.20.1
>>
>>
> 

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

end of thread, other threads:[~2019-05-07  8:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-07  8:21 [PATCH][next] Input: qt1050: fix less than zero comparison on an unsigned int Colin King
2019-05-07  8:27 ` Dan Carpenter
2019-05-07  8:32 ` Marco Felsch
2019-05-07  8:46   ` Colin Ian King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox