mirror of
https://gitlab.freedesktop.org/libevdev/libevdev.git
synced 2026-05-08 10:08:07 +02:00
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:
parent
fa4cadae60
commit
ce7e2f1516
1 changed files with 7 additions and 4 deletions
|
|
@ -1172,10 +1172,13 @@ libevdev_is_event_type(const struct input_event *ev, unsigned int type)
|
||||||
int
|
int
|
||||||
libevdev_is_event_code(const struct input_event *ev, unsigned int type, unsigned int code)
|
libevdev_is_event_code(const struct input_event *ev, unsigned int type, unsigned int code)
|
||||||
{
|
{
|
||||||
return type < EV_MAX &&
|
int max;
|
||||||
ev->type == type &&
|
|
||||||
(type == EV_SYN || code <= libevdev_get_event_type_max(type)) &&
|
if (!libevdev_is_event_type(ev, type))
|
||||||
ev->code == code;
|
return 0;
|
||||||
|
|
||||||
|
max = libevdev_get_event_type_max(type);
|
||||||
|
return (max > -1 && code <= (unsigned int)max && ev->code == code);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char*
|
const char*
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue