Skip to content

Commit 8affa1b

Browse files
nathanchancegregkh
authored andcommitted
Input: touchscreen - avoid bitwise vs logical OR warning
commit a02dcde 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: 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> Signed-off-by: Anders Roxell <anders.roxell@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent aec5897 commit 8affa1b

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

drivers/input/touchscreen/of_touchscreen.c

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -79,39 +79,39 @@ void touchscreen_parse_properties(struct input_dev *input, bool multitouch,
7979

8080
data_present = touchscreen_get_prop_u32(dev, "touchscreen-min-x",
8181
input_abs_get_min(input, axis_x),
82-
&minimum) |
83-
touchscreen_get_prop_u32(dev, "touchscreen-size-x",
84-
input_abs_get_max(input,
85-
axis_x) + 1,
86-
&maximum) |
87-
touchscreen_get_prop_u32(dev, "touchscreen-fuzz-x",
88-
input_abs_get_fuzz(input, axis_x),
89-
&fuzz);
82+
&minimum);
83+
data_present |= touchscreen_get_prop_u32(dev, "touchscreen-size-x",
84+
input_abs_get_max(input,
85+
axis_x) + 1,
86+
&maximum);
87+
data_present |= touchscreen_get_prop_u32(dev, "touchscreen-fuzz-x",
88+
input_abs_get_fuzz(input, axis_x),
89+
&fuzz);
9090
if (data_present)
9191
touchscreen_set_params(input, axis_x, minimum, maximum - 1, fuzz);
9292

9393
data_present = touchscreen_get_prop_u32(dev, "touchscreen-min-y",
9494
input_abs_get_min(input, axis_y),
95-
&minimum) |
96-
touchscreen_get_prop_u32(dev, "touchscreen-size-y",
97-
input_abs_get_max(input,
98-
axis_y) + 1,
99-
&maximum) |
100-
touchscreen_get_prop_u32(dev, "touchscreen-fuzz-y",
101-
input_abs_get_fuzz(input, axis_y),
102-
&fuzz);
95+
&minimum);
96+
data_present |= touchscreen_get_prop_u32(dev, "touchscreen-size-y",
97+
input_abs_get_max(input,
98+
axis_y) + 1,
99+
&maximum);
100+
data_present |= touchscreen_get_prop_u32(dev, "touchscreen-fuzz-y",
101+
input_abs_get_fuzz(input, axis_y),
102+
&fuzz);
103103
if (data_present)
104104
touchscreen_set_params(input, axis_y, minimum, maximum - 1, fuzz);
105105

106106
axis = multitouch ? ABS_MT_PRESSURE : ABS_PRESSURE;
107107
data_present = touchscreen_get_prop_u32(dev,
108108
"touchscreen-max-pressure",
109109
input_abs_get_max(input, axis),
110-
&maximum) |
111-
touchscreen_get_prop_u32(dev,
112-
"touchscreen-fuzz-pressure",
113-
input_abs_get_fuzz(input, axis),
114-
&fuzz);
110+
&maximum);
111+
data_present |= touchscreen_get_prop_u32(dev,
112+
"touchscreen-fuzz-pressure",
113+
input_abs_get_fuzz(input, axis),
114+
&fuzz);
115115
if (data_present)
116116
touchscreen_set_params(input, axis, 0, maximum, fuzz);
117117

0 commit comments

Comments
 (0)