]> git.baikalelectronics.ru Git - kernel.git/commit
Input: touchscreen - avoid bitwise vs logical OR warning
authorNathan Chancellor <nathan@kernel.org>
Fri, 15 Oct 2021 20:13:06 +0000 (13:13 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Sat, 16 Oct 2021 05:22:54 +0000 (22:22 -0700)
commitb77b9e6258f52ef209d260931d3317a43e573d9a
tree24fdcd33767fb1d1c5da58ea711c28eafa7c0a2d
parentc94e6ec711805704d8d8be00150bf6cc61b1f47c
Input: touchscreen - avoid bitwise vs logical OR warning

A new warning in clang points out a few places in this driver where a
bitwise OR is being used with boolean types:

drivers/input/touchscreen.c:81:17: warning: use of bitwise '|' with boolean operands [-Wbitwise-instead-of-logical]
        data_present = touchscreen_get_prop_u32(dev, "touchscreen-min-x",
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This use of a bitwise OR is intentional, as bitwise operations do not
short circuit, which allows all the calls to touchscreen_get_prop_u32()
to happen so that the last parameter is initialized while coalescing the
results of the calls to make a decision after they are all evaluated.

To make this clearer to the compiler, use the '|=' operator to assign
the result of each touchscreen_get_prop_u32() call to data_present,
which keeps the meaning of the code the same but makes it obvious that
every one of these calls is expected to happen.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Reported-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Link: https://lore.kernel.org/r/20211014205757.3474635-1-nathan@kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/touchscreen.c