mirror of
https://gitlab.freedesktop.org/libevdev/libevdev.git
synced 2026-05-05 18:08:07 +02:00
Use libevdev_get_event_type_max from libevdev_get_event_code_name
This will check for invalid types for us, and we can do a better check for signed/unsigned comparison. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
4b715dd928
commit
fa4cadae60
1 changed files with 2 additions and 3 deletions
|
|
@ -1190,10 +1190,9 @@ libevdev_get_event_type_name(unsigned int type)
|
||||||
const char*
|
const char*
|
||||||
libevdev_get_event_code_name(unsigned int type, unsigned int code)
|
libevdev_get_event_code_name(unsigned int type, unsigned int code)
|
||||||
{
|
{
|
||||||
if (type > EV_MAX)
|
int max = libevdev_get_event_type_max(type);
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (code > ev_max[type])
|
if (max == -1 || code > (unsigned int)max)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return event_type_map[type][code];
|
return event_type_map[type][code];
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue