[PATCH evdev] Fix off-by-one error counting axes
Hans de Goede
hdegoede at redhat.com
Fri Oct 21 09:08:42 UTC 2016
Hi,
On 21-10-16 01:55, Peter Hutterer wrote:
> We stopped counting one too early, but still initialized that axis later,
> leading to a bug macro to trigger.
>
> https://bugs.freedesktop.org/show_bug.cgi?id=97956
>
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
LGTM:
Reviewed-by: Hans de Goede <hdegoede at redhat.com>
Regards,
Hans
> ---
> src/evdev.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/src/evdev.c b/src/evdev.c
> index 5ace238..96fd97d 100644
> --- a/src/evdev.c
> +++ b/src/evdev.c
> @@ -1238,7 +1238,7 @@ EvdevCountMTAxes(EvdevPtr pEvdev, int *num_mt_axes_total,
> return;
>
> /* Absolute multitouch axes: adjust mapping and axes counts. */
> - for (axis = ABS_MT_SLOT; axis < ABS_MAX; axis++)
> + for (axis = ABS_MT_SLOT; axis <= ABS_MAX; axis++)
> {
> int j;
> Bool skip = FALSE;
> @@ -1288,7 +1288,7 @@ EvdevAddAbsValuatorClass(DeviceIntPtr device, int num_scroll_axes)
> goto out;
>
> /* Find number of absolute axis, including MT ones, will decrease later. */
> - for (i = 0; i < ABS_MAX; i++)
> + for (i = 0; i <= ABS_MAX; i++)
> if (libevdev_has_event_code(pEvdev->dev, EV_ABS, i))
> num_axes++;
>
> @@ -1456,7 +1456,7 @@ EvdevAddAbsValuatorClass(DeviceIntPtr device, int num_scroll_axes)
> }
>
> for (i = 0; i < num_touches; i++) {
> - for (axis = ABS_MT_TOUCH_MAJOR; axis < ABS_MAX; axis++) {
> + for (axis = ABS_MT_TOUCH_MAJOR; axis <= ABS_MAX; axis++) {
> if (pEvdev->abs_axis_map[axis] >= 0) {
> int val = pEvdev->mtdev ? 0 : libevdev_get_current_slot(pEvdev->dev);
> /* XXX: read initial values from mtdev when it adds support
> @@ -1669,7 +1669,7 @@ EvdevAddRelValuatorClass(DeviceIntPtr device, int num_scroll_axes)
> if (!libevdev_has_event_type(pEvdev->dev, EV_REL))
> goto out;
>
> - for (i = 0; i < REL_MAX; i++) {
> + for (i = 0; i <= REL_MAX; i++) {
> if (i == REL_WHEEL || i == REL_HWHEEL || i == REL_DIAL)
> continue;
>
>
More information about the xorg-devel
mailing list