All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: linux-input@vger.kernel.org
Subject: Re: [bug report] Input: elants_i2c - add support for eKTF3624
Date: Thu, 28 Jan 2021 14:07:05 +0100	[thread overview]
Message-ID: <20210128130705.GA32681@qmqm.qmqm.pl> (raw)
In-Reply-To: <YBKKePZ1VyZIbBCo@mwanda>

On Thu, Jan 28, 2021 at 12:57:12PM +0300, Dan Carpenter wrote:
> Hello Michał Mirosław,
> 
> The patch 9517b95bdc46: "Input: elants_i2c - add support for
> eKTF3624" from Jan 24, 2021, leads to the following static checker
> warning:
> 
> 	drivers/input/touchscreen/elants_i2c.c:966 elants_i2c_mt_event()
> 	warn: should this be a bitwise negate mask?
> 
> drivers/input/touchscreen/elants_i2c.c
[...]
>    963                                  w = buf[FW_POS_WIDTH + i / 2];
>    964                                  w >>= 4 * (~i & 1);
>    965                                  w |= w << 4;
>    966                                  w |= !w;
>                                         ^^^^^^^^
> 
> This code is just very puzzling.  I think it may actually be correct?
> The boring and conventional way to write this would be to do it like so:
> 
> 	if (!w)
> 		w = 1;

It could also be written as:

	w += !w;

or:
	w += w == 0;

while avoiding conditional.

But, in this case, the warning is bogus. Because w | ~w == all-ones (always),
it might as well suggested to write:

	w = -1;

or:
	w = ~0;

making the code broken.

Best Regards
Michał Mirosław

  reply	other threads:[~2021-01-28 13:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-28  9:57 [bug report] Input: elants_i2c - add support for eKTF3624 Dan Carpenter
2021-01-28 13:07 ` Michał Mirosław [this message]
2021-01-28 14:37   ` Dan Carpenter
2021-01-28 23:21     ` Michał Mirosław

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210128130705.GA32681@qmqm.qmqm.pl \
    --to=mirq-linux@rere.qmqm.pl \
    --cc=dan.carpenter@oracle.com \
    --cc=linux-input@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.