linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 08/14] Input: adxl34x - fix gcc-7 -Wint-in-bool-context warning
       [not found] <20170714092540.1217397-1-arnd@arndb.de>
@ 2017-07-14  9:25 ` Arnd Bergmann
  2017-07-14 19:24   ` Linus Torvalds
  0 siblings, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2017-07-14  9:25 UTC (permalink / raw)
  To: linux-kernel, Michael Hennerich, Dmitry Torokhov
  Cc: Arnd Bergmann, Greg Kroah-Hartman, dri-devel, linux-ide,
	linux-input, Tejun Heo, akpm, Linus Torvalds, Guenter Roeck,
	linux-media

FIFO_MODE is an macro expression with a '<<' operator, which
gcc points out could be misread as a '<':

drivers/input/misc/adxl34x.c: In function 'adxl34x_probe':
drivers/input/misc/adxl34x.c:799:36: error: '<<' in boolean context, did you mean '<' ? [-Werror=int-in-bool-context]

This converts the test to an explicit comparison with zero,
making it clearer to gcc and the reader what is intended.

Fixes: e27c729219ad ("Input: add driver for ADXL345/346 Digital Accelerometers")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/input/misc/adxl34x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/misc/adxl34x.c b/drivers/input/misc/adxl34x.c
index 2b2d02f408bb..e0caaa0de454 100644
--- a/drivers/input/misc/adxl34x.c
+++ b/drivers/input/misc/adxl34x.c
@@ -796,7 +796,7 @@ struct adxl34x *adxl34x_probe(struct device *dev, int irq,
 
 	if (pdata->watermark) {
 		ac->int_mask |= WATERMARK;
-		if (!FIFO_MODE(pdata->fifo_mode))
+		if (FIFO_MODE(pdata->fifo_mode) == 0)
 			ac->pdata.fifo_mode |= FIFO_STREAM;
 	} else {
 		ac->int_mask |= DATA_READY;
-- 
2.9.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 08/14] Input: adxl34x - fix gcc-7 -Wint-in-bool-context warning
  2017-07-14  9:25 ` [PATCH 08/14] Input: adxl34x - fix gcc-7 -Wint-in-bool-context warning Arnd Bergmann
@ 2017-07-14 19:24   ` Linus Torvalds
  2017-07-14 20:17     ` Arnd Bergmann
  0 siblings, 1 reply; 4+ messages in thread
From: Linus Torvalds @ 2017-07-14 19:24 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Linux Kernel Mailing List, Michael Hennerich, Dmitry Torokhov,
	Greg Kroah-Hartman, Tejun Heo, Guenter Roeck, IDE-ML,
	Linux Media Mailing List, Andrew Morton, DRI,
	linux-input@vger.kernel.org

On Fri, Jul 14, 2017 at 2:25 AM, Arnd Bergmann <arnd@arndb.de> wrote:
> FIFO_MODE is an macro expression with a '<<' operator, which
> gcc points out could be misread as a '<':

Yeah, no, NAK again.

We don't make the code look worse just because gcc is being a f*cking
moron about things.

This warning is clearly pure garbage.

                 Linus

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

* Re: [PATCH 08/14] Input: adxl34x - fix gcc-7 -Wint-in-bool-context warning
  2017-07-14 19:24   ` Linus Torvalds
@ 2017-07-14 20:17     ` Arnd Bergmann
  2017-07-14 21:40       ` Dmitry Torokhov
  0 siblings, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2017-07-14 20:17 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Linux Kernel Mailing List, Michael Hennerich, Dmitry Torokhov,
	Greg Kroah-Hartman, Tejun Heo, Guenter Roeck, IDE-ML,
	Linux Media Mailing List, Andrew Morton, DRI,
	linux-input@vger.kernel.org

On Fri, Jul 14, 2017 at 9:24 PM, Linus Torvalds
<torvalds@linux-foundation.org> wrote:
> On Fri, Jul 14, 2017 at 2:25 AM, Arnd Bergmann <arnd@arndb.de> wrote:
>> FIFO_MODE is an macro expression with a '<<' operator, which
>> gcc points out could be misread as a '<':
>
> Yeah, no, NAK again.
>
> We don't make the code look worse just because gcc is being a f*cking
> moron about things.
>
> This warning is clearly pure garbage.
>

I looked at this one again and found a better approach, matching the
check that is done a few lines later. Unless you find something wrong
with that one, I'd resubmit it with the fixup below.

      Arnd

--- a/drivers/input/misc/adxl34x.c
+++ b/drivers/input/misc/adxl34x.c
@@ -789,21 +789,21 @@ struct adxl34x *adxl34x_probe(struct device *dev, int irq,
                __set_bit(pdata->ev_code_ff, input_dev->keybit);
        }

        if (pdata->ev_code_act_inactivity)
                __set_bit(pdata->ev_code_act_inactivity, input_dev->keybit);

        ac->int_mask |= ACTIVITY | INACTIVITY;

        if (pdata->watermark) {
                ac->int_mask |= WATERMARK;
-               if (FIFO_MODE(pdata->fifo_mode) == 0)
+               if (FIFO_MODE(pdata->fifo_mode) == FIFO_BYPASS)
                        ac->pdata.fifo_mode |= FIFO_STREAM;
        } else {
                ac->int_mask |= DATA_READY;
        }

        if (pdata->tap_axis_control & (TAP_X_EN | TAP_Y_EN | TAP_Z_EN))
                ac->int_mask |= SINGLE_TAP | DOUBLE_TAP;

        if (FIFO_MODE(pdata->fifo_mode) == FIFO_BYPASS)
                ac->fifo_delay = false;

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

* Re: [PATCH 08/14] Input: adxl34x - fix gcc-7 -Wint-in-bool-context warning
  2017-07-14 20:17     ` Arnd Bergmann
@ 2017-07-14 21:40       ` Dmitry Torokhov
  0 siblings, 0 replies; 4+ messages in thread
From: Dmitry Torokhov @ 2017-07-14 21:40 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Linus Torvalds, Linux Kernel Mailing List, Michael Hennerich,
	Greg Kroah-Hartman, Tejun Heo, Guenter Roeck, IDE-ML,
	Linux Media Mailing List, Andrew Morton, DRI,
	linux-input@vger.kernel.org

On Fri, Jul 14, 2017 at 10:17:10PM +0200, Arnd Bergmann wrote:
> On Fri, Jul 14, 2017 at 9:24 PM, Linus Torvalds
> <torvalds@linux-foundation.org> wrote:
> > On Fri, Jul 14, 2017 at 2:25 AM, Arnd Bergmann <arnd@arndb.de> wrote:
> >> FIFO_MODE is an macro expression with a '<<' operator, which
> >> gcc points out could be misread as a '<':
> >
> > Yeah, no, NAK again.
> >
> > We don't make the code look worse just because gcc is being a f*cking
> > moron about things.
> >
> > This warning is clearly pure garbage.
> >
> 
> I looked at this one again and found a better approach, matching the
> check that is done a few lines later. Unless you find something wrong
> with that one, I'd resubmit it with the fixup below.
> 
>       Arnd
> 
> --- a/drivers/input/misc/adxl34x.c
> +++ b/drivers/input/misc/adxl34x.c
> @@ -789,21 +789,21 @@ struct adxl34x *adxl34x_probe(struct device *dev, int irq,
>                 __set_bit(pdata->ev_code_ff, input_dev->keybit);
>         }
> 
>         if (pdata->ev_code_act_inactivity)
>                 __set_bit(pdata->ev_code_act_inactivity, input_dev->keybit);
> 
>         ac->int_mask |= ACTIVITY | INACTIVITY;
> 
>         if (pdata->watermark) {
>                 ac->int_mask |= WATERMARK;
> -               if (FIFO_MODE(pdata->fifo_mode) == 0)
> +               if (FIFO_MODE(pdata->fifo_mode) == FIFO_BYPASS)

This is better, not because of GCC, but it makes sense logically; 0 is
not a special value here.

Still, I am not sure that GCC is being that helpful here. Checking
result of shift for 0/non 0 with "!" is very common pattern.

Thanks.

-- 
Dmitry

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

end of thread, other threads:[~2017-07-14 21:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20170714092540.1217397-1-arnd@arndb.de>
2017-07-14  9:25 ` [PATCH 08/14] Input: adxl34x - fix gcc-7 -Wint-in-bool-context warning Arnd Bergmann
2017-07-14 19:24   ` Linus Torvalds
2017-07-14 20:17     ` Arnd Bergmann
2017-07-14 21:40       ` Dmitry Torokhov

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