[PATCH 4/8] evdev-touchpad: Iterate over the touchpad spec table correctly

Kristian Høgsberg hoegsberg at gmail.com
Tue Oct 9 19:53:00 PDT 2012


On Tue, Oct 09, 2012 at 06:44:32PM +0100, Rob Bradford wrote:
> From: Rob Bradford <rob at linux.intel.com>
> 
> The original code would overrun since the calculation of the range did not
> take into consideration the size of the entries in the table.

Oh oops.  I tweaked the patch to use the ARRAY_LENGTH macro instead.

Kristian

> Cc:Jonas Ådahl <jadahl at gmail.com>
> Signed-off-by: Rob Bradford <rob at linux.intel.com>
> ---
>  src/evdev-touchpad.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/src/evdev-touchpad.c b/src/evdev-touchpad.c
> index 4da37a5..8228f30 100644
> --- a/src/evdev-touchpad.c
> +++ b/src/evdev-touchpad.c
> @@ -134,7 +134,9 @@ get_touchpad_model(struct evdev_device *device)
>  	if (ioctl(device->fd, EVIOCGID, &id) < 0)
>  		return TOUCHPAD_MODEL_UNKNOWN;
>  
> -	for (i = 0; i < sizeof touchpad_spec_table; i++)
> +	for (i = 0;
> +	     i < sizeof touchpad_spec_table / sizeof touchpad_spec_table[0];
> +	     i++)
>  		if (touchpad_spec_table[i].vendor == id.vendor &&
>  		    (!touchpad_spec_table[i].product ||
>  		     touchpad_spec_table[i].product == id.product))
> -- 
> 1.7.11.2
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list