Skip to content
Snippets Groups Projects
Commit f6e9e7be authored by Nathan Chancellor's avatar Nathan Chancellor Committed by Greg Kroah-Hartman
Browse files

Input: touchscreen - avoid bitwise vs logical OR warning


commit a02dcde5 upstream.

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: default avatarNathan Chancellor <nathan@kernel.org>
Reported-by: default avatarNick Desaulniers <ndesaulniers@google.com>
Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
Link: https://lore.kernel.org/r/20211014205757.3474635-1-nathan@kernel.org


Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: default avatarAnders Roxell <anders.roxell@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3d45573d
No related branches found
No related tags found
No related merge requests found
...@@ -81,8 +81,8 @@ void touchscreen_parse_properties(struct input_dev *input, bool multitouch, ...@@ -81,8 +81,8 @@ void touchscreen_parse_properties(struct input_dev *input, bool multitouch,
touchscreen_get_prop_u32(dev, "touchscreen-size-x", touchscreen_get_prop_u32(dev, "touchscreen-size-x",
input_abs_get_max(input, input_abs_get_max(input,
axis) + 1, axis) + 1,
&maximum) | &maximum);
touchscreen_get_prop_u32(dev, "touchscreen-fuzz-x", data_present |= touchscreen_get_prop_u32(dev, "touchscreen-fuzz-x",
input_abs_get_fuzz(input, axis), input_abs_get_fuzz(input, axis),
&fuzz); &fuzz);
if (data_present) if (data_present)
...@@ -95,8 +95,8 @@ void touchscreen_parse_properties(struct input_dev *input, bool multitouch, ...@@ -95,8 +95,8 @@ void touchscreen_parse_properties(struct input_dev *input, bool multitouch,
touchscreen_get_prop_u32(dev, "touchscreen-size-y", touchscreen_get_prop_u32(dev, "touchscreen-size-y",
input_abs_get_max(input, input_abs_get_max(input,
axis) + 1, axis) + 1,
&maximum) | &maximum);
touchscreen_get_prop_u32(dev, "touchscreen-fuzz-y", data_present |= touchscreen_get_prop_u32(dev, "touchscreen-fuzz-y",
input_abs_get_fuzz(input, axis), input_abs_get_fuzz(input, axis),
&fuzz); &fuzz);
if (data_present) if (data_present)
...@@ -106,8 +106,8 @@ void touchscreen_parse_properties(struct input_dev *input, bool multitouch, ...@@ -106,8 +106,8 @@ void touchscreen_parse_properties(struct input_dev *input, bool multitouch,
data_present = touchscreen_get_prop_u32(dev, data_present = touchscreen_get_prop_u32(dev,
"touchscreen-max-pressure", "touchscreen-max-pressure",
input_abs_get_max(input, axis), input_abs_get_max(input, axis),
&maximum) | &maximum);
touchscreen_get_prop_u32(dev, data_present |= touchscreen_get_prop_u32(dev,
"touchscreen-fuzz-pressure", "touchscreen-fuzz-pressure",
input_abs_get_fuzz(input, axis), input_abs_get_fuzz(input, axis),
&fuzz); &fuzz);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment