Skip to content

Commit 8980f19

Browse files
zx2c4dtor
authored andcommitted
Input: focaltech - use explicitly signed char type
The recent change of -funsigned-char causes additions of negative numbers to become additions of large positive numbers, leading to wrong calculations of mouse movement. Change these casts to be explicitly signed, to take into account negative offsets. Fixes: 3bc753c ("kbuild: treat char as always unsigned") Signed-off-by: Jason A. Donenfeld <[email protected]> Reviewed-by: Hans de Goede <[email protected]> Cc: [email protected] Link: https://bugzilla.kernel.org/show_bug.cgi?id=217211 Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent ffa6206 commit 8980f19

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

drivers/input/mouse/focaltech.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,8 @@ static void focaltech_process_rel_packet(struct psmouse *psmouse,
202202
state->pressed = packet[0] >> 7;
203203
finger1 = ((packet[0] >> 4) & 0x7) - 1;
204204
if (finger1 < FOC_MAX_FINGERS) {
205-
state->fingers[finger1].x += (char)packet[1];
206-
state->fingers[finger1].y += (char)packet[2];
205+
state->fingers[finger1].x += (s8)packet[1];
206+
state->fingers[finger1].y += (s8)packet[2];
207207
} else {
208208
psmouse_err(psmouse, "First finger in rel packet invalid: %d\n",
209209
finger1);
@@ -218,8 +218,8 @@ static void focaltech_process_rel_packet(struct psmouse *psmouse,
218218
*/
219219
finger2 = ((packet[3] >> 4) & 0x7) - 1;
220220
if (finger2 < FOC_MAX_FINGERS) {
221-
state->fingers[finger2].x += (char)packet[4];
222-
state->fingers[finger2].y += (char)packet[5];
221+
state->fingers[finger2].x += (s8)packet[4];
222+
state->fingers[finger2].y += (s8)packet[5];
223223
}
224224
}
225225

0 commit comments

Comments
 (0)