[PATCH libinput 1/3] Return the length or a neg errno from libinput_device_get_keys()
Peter Hutterer
peter.hutterer at who-t.net
Thu Mar 20 21:13:20 PDT 2014
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 at who-t.net>
---
weston is not affected by this, it checks for < .
src/evdev.c | 6 +++++-
src/libinput.h | 2 ++
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/evdev.c b/src/evdev.c
index 5d01e3b..ba7c8b3 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -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 *
diff --git a/src/libinput.h b/src/libinput.h
index 9a9cd8c..d6bf9f8 100644
--- a/src/libinput.h
+++ b/src/libinput.h
@@ -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,
--
1.8.5.3
More information about the wayland-devel
mailing list