Rewrite libevdev_is_event_code to avoid signed/unsigned comparison

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2013-08-23 10:25:08 +10:00
parent fa4cadae60
commit ce7e2f1516

View file

@ -1172,10 +1172,13 @@ libevdev_is_event_type(const struct input_event *ev, unsigned int type)
int
libevdev_is_event_code(const struct input_event *ev, unsigned int type, unsigned int code)
{
return type < EV_MAX &&
ev->type == type &&
(type == EV_SYN || code <= libevdev_get_event_type_max(type)) &&
ev->code == code;
int max;
if (!libevdev_is_event_type(ev, type))
return 0;
max = libevdev_get_event_type_max(type);
return (max > -1 && code <= (unsigned int)max && ev->code == code);
}
const char*