diff mbox

[v2] platform/x86: peaq-wmi: silence a static checker warning

Message ID 20170719130718.gcskf2ofko5wv6rw@mwanda (mailing list archive)
State Accepted, archived
Delegated to: Andy Shevchenko
Headers show

Commit Message

Dan Carpenter July 19, 2017, 1:07 p.m. UTC
There is a harmless static checker warning here that unsigned values are
always >= 0.  The code looks like:

	if (peaq_ignore_events_counter && --peaq_ignore_events_counter >= 0)

The first part of the condition ensures that we never wrap around so the
code works as intended.  I've tweaked it slightly to avoid the warning.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2: Andy Shevchenko's approach is cleaner

Comments

Andy Shevchenko July 19, 2017, 6:11 p.m. UTC | #1
On Wed, Jul 19, 2017 at 4:07 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> There is a harmless static checker warning here that unsigned values are
> always >= 0.  The code looks like:
>
>         if (peaq_ignore_events_counter && --peaq_ignore_events_counter >= 0)
>
> The first part of the condition ensures that we never wrap around so the
> code works as intended.  I've tweaked it slightly to avoid the warning.
>

Pushed to testing, thanks.

> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> v2: Andy Shevchenko's approach is cleaner
>
> diff --git a/drivers/platform/x86/peaq-wmi.c b/drivers/platform/x86/peaq-wmi.c
> index 77d1f90b0794..c68bd76954fd 100644
> --- a/drivers/platform/x86/peaq-wmi.c
> +++ b/drivers/platform/x86/peaq-wmi.c
> @@ -51,7 +51,7 @@ static void peaq_wmi_poll(struct input_polled_dev *dev)
>                 return;
>         }
>
> -       if (peaq_ignore_events_counter && --peaq_ignore_events_counter >= 0)
> +       if (peaq_ignore_events_counter && peaq_ignore_events_counter--)
>                 return;
>
>         if (obj.integer.value) {
diff mbox

Patch

diff --git a/drivers/platform/x86/peaq-wmi.c b/drivers/platform/x86/peaq-wmi.c
index 77d1f90b0794..c68bd76954fd 100644
--- a/drivers/platform/x86/peaq-wmi.c
+++ b/drivers/platform/x86/peaq-wmi.c
@@ -51,7 +51,7 @@  static void peaq_wmi_poll(struct input_polled_dev *dev)
 		return;
 	}
 
-	if (peaq_ignore_events_counter && --peaq_ignore_events_counter >= 0)
+	if (peaq_ignore_events_counter && peaq_ignore_events_counter--)
 		return;
 
 	if (obj.integer.value) {