mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-02-03 20:30:27 +01:00
test: abort when no default value is available for an axis
And fix the cases where the default value isn't filled in correctly Issue found because of the following ubsan error: ../src/evdev-tablet.c:182:19: runtime error: signed integer overflow: 0 - -214783648 cannot be represented in type 'int' Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
09e97a5231
commit
657842093c
4 changed files with 25 additions and 4 deletions
|
|
@ -58,6 +58,9 @@ static int
|
|||
get_axis_default(struct litest_device *d, unsigned int evcode, int32_t *value)
|
||||
{
|
||||
switch (evcode) {
|
||||
case ABS_DISTANCE:
|
||||
*value = 0;
|
||||
return 0;
|
||||
case ABS_PRESSURE:
|
||||
*value = 100;
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -58,6 +58,9 @@ static int
|
|||
get_axis_default(struct litest_device *d, unsigned int evcode, int32_t *value)
|
||||
{
|
||||
switch (evcode) {
|
||||
case ABS_DISTANCE:
|
||||
*value = 0;
|
||||
return 0;
|
||||
case ABS_PRESSURE:
|
||||
*value = 100;
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ static int
|
|||
get_axis_default(struct litest_device *d, unsigned int evcode, int32_t *value)
|
||||
{
|
||||
switch (evcode) {
|
||||
case ABS_Z:
|
||||
case ABS_TILT_X:
|
||||
case ABS_TILT_Y:
|
||||
*value = 0;
|
||||
|
|
|
|||
|
|
@ -1776,8 +1776,16 @@ litest_auto_assign_value(struct litest_device *d,
|
|||
break;
|
||||
default:
|
||||
if (!axis_replacement_value(d, axes, ev->code, &value) &&
|
||||
d->interface->get_axis_default)
|
||||
d->interface->get_axis_default(d, ev->code, &value);
|
||||
d->interface->get_axis_default) {
|
||||
int error = d->interface->get_axis_default(d,
|
||||
ev->code,
|
||||
&value);
|
||||
if (error) {
|
||||
litest_abort_msg("Failed to get default axis value for %s (%d)\n",
|
||||
libevdev_event_code_get_name(EV_ABS, ev->code),
|
||||
ev->code);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -2152,8 +2160,14 @@ auto_assign_tablet_value(struct litest_device *d,
|
|||
break;
|
||||
default:
|
||||
if (!axis_replacement_value(d, axes, ev->code, &value) &&
|
||||
d->interface->get_axis_default)
|
||||
d->interface->get_axis_default(d, ev->code, &value);
|
||||
d->interface->get_axis_default) {
|
||||
int error = d->interface->get_axis_default(d, ev->code, &value);
|
||||
if (error) {
|
||||
litest_abort_msg("Failed to get default axis value for %s (%d)\n",
|
||||
libevdev_event_code_get_name(EV_ABS, ev->code),
|
||||
ev->code);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue