mirror of
https://gitlab.freedesktop.org/libevdev/libevdev.git
synced 2025-12-26 02:50:07 +01: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
|
||||
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*
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue