Return the length or a neg errno from libinput_device_get_keys()
authorPeter Hutterer <peter.hutterer@who-t.net>
Thu, 13 Mar 2014 05:54:47 +0000 (15:54 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Sun, 23 Mar 2014 23:07:57 +0000 (09:07 +1000)
Previous return value was the straight ioctl, we should try to avoid errno
mangling.

This changes the API, if not the ABI. Callers with code along the lines of
if (libinput_device_get_keys() == -1) will now break.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ã…dahl <jadahl@gmail.com>
src/evdev.c
src/libinput.h

index 5d01e3bcf418b63563bb478c452e4f0e4eb11ec6..ba7c8b34f91536e0450c2c745a206d20b835d76d 100644 (file)
@@ -715,8 +715,12 @@ err:
 int
 evdev_device_get_keys(struct evdev_device *device, char *keys, size_t size)
 {
+       int len;
+
        memset(keys, 0, size);
-       return ioctl(device->fd, EVIOCGKEY(size), keys);
+       len = ioctl(device->fd, EVIOCGKEY(size), keys);
+
+       return (len == -1) ? -errno : len;
 }
 
 const char *
index 9a9cd8c4aba6928290251db3869b2fe8734333b7..d6bf9f8649cd3e0ff3dfa642e59a1254f15248c6 100644 (file)
@@ -1169,6 +1169,8 @@ libinput_device_led_update(struct libinput_device *device,
  * @param device A current input device
  * @param keys An array filled with the bitmask for the keys
  * @param size Size of the keys array
+ *
+ * @return The number of valid bytes in keys, or a negative errno on failure
  */
 int
 libinput_device_get_keys(struct libinput_device *device,