[PATCH libevdev 02/13] Use libevdev_get_event_type_max from libevdev_get_event_code_name
Peter Hutterer
peter.hutterer at who-t.net
Sun Aug 25 16:27:22 PDT 2013
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 at who-t.net>
---
libevdev/libevdev.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/libevdev/libevdev.c b/libevdev/libevdev.c
index 0d315ec..80dee1a 100644
--- a/libevdev/libevdev.c
+++ b/libevdev/libevdev.c
@@ -1023,10 +1023,9 @@ libevdev_get_event_type_name(unsigned int type)
const char*
libevdev_get_event_code_name(unsigned int type, unsigned int code)
{
- if (type > EV_MAX)
- return NULL;
+ int max = libevdev_get_event_type_max(type);
- if (code > ev_max[type])
+ if (max == -1 || code > (unsigned int)max)
return NULL;
return event_type_map[type][code];
--
1.8.2.1
More information about the Input-tools
mailing list