Require data be NULL when enabling a non-EV_ABS axis
authorPeter Hutterer <peter.hutterer@who-t.net>
Sun, 30 Jun 2013 23:35:16 +0000 (09:35 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Sun, 30 Jun 2013 23:35:16 +0000 (09:35 +1000)
In the future this may change, but for now enforce that callers use NULL.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
libevdev/libevdev.c
libevdev/libevdev.h

index 4a9ab0e..fe23ce6 100644 (file)
@@ -813,6 +813,9 @@ libevdev_enable_event_code(struct libevdev *dev, unsigned int type,
        if (libevdev_enable_event_type(dev, type))
                return -1;
 
+       if (type != EV_ABS && data != NULL)
+               return -1;
+
        max = type_to_mask(dev, type, &mask);
 
        if (code > max)
index ec3c12e..d8f04f4 100644 (file)
@@ -757,9 +757,9 @@ int libevdev_disable_event_type(struct libevdev *dev, unsigned int type);
  * report such events, it will now return true for libevdev_has_event_code().
  *
  * The last argument depends on the type and code:
- * - If type is EV_ABS, the vararg must be a pointer to a struct input_absinfo
+ * - If type is EV_ABS, data must be a pointer to a struct input_absinfo
  * containing the data for this axis.
- * - For all other types, the argument is ignored.
+ * - For all other types, the argument must be NULL.
  *
  * This function calls libevdev_enable_event_type() if necessary.
  *
@@ -769,7 +769,8 @@ int libevdev_disable_event_type(struct libevdev *dev, unsigned int type);
  * @param dev The evdev device, already initialized with libevdev_set_fd()
  * @param type The event type to enable (EV_ABS, EV_KEY, ...)
  * @param code The event code to enable (ABS_X, REL_X, etc.)
- * @param data Axis/key data, depending on type and code
+ * @param data If type is EV_ABS, data points to a struct input_absinfo. Otherwise, data must be
+ * NULL
  *
  * @return 0 on success or -1 otherwise
  *