Skip to content

Commit a02dcde

Browse files
nathanchancedtor
authored andcommitted
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 <[email protected]> Reported-by: Nick Desaulniers <[email protected]> Reviewed-by: Nick Desaulniers <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent 3378a07 commit a02dcde

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

drivers/input/touchscreen.c

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

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

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

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

0 commit comments

Comments
 (0)