From f92674df1c436078a9116e00b157838de0ce7457 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 20 Aug 2015 16:04:43 +1000 Subject: [PATCH] hidraw: make sure we're comparing products of the same int type hidraw_devinfo.product is 16-bit signed, input_id.product is 16 bit unsigned. Move the hidraw info over to a input_id, then compare. Signed-off-by: Peter Hutterer --- src/libratbag-hidraw.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/libratbag-hidraw.c b/src/libratbag-hidraw.c index a7b399c9..0c32bee2 100644 --- a/src/libratbag-hidraw.c +++ b/src/libratbag-hidraw.c @@ -41,6 +41,7 @@ ratbag_open_hidraw(struct ratbag_device *ratbag) struct hidraw_devinfo info; int fd, res; const char *devnode; + struct input_id hid_id; if (!ratbag->udev_hidraw) return -EINVAL; @@ -58,19 +59,23 @@ ratbag_open_hidraw(struct ratbag_device *ratbag) goto err; } + hid_id.bustype = info.bustype; + hid_id.vendor = info.vendor; + hid_id.product = info.product; + /* Check if the device actually matches the input node */ - if (info.bustype != ratbag->ids.bustype || - info.vendor != ratbag->ids.vendor) { + if (hid_id.bustype != ratbag->ids.bustype || + hid_id.vendor != ratbag->ids.vendor) { errno -EINVAL; goto err; } /* On the Logitech receiver, the hid device has the pid of the * receiver, not of the actual device */ - if (info.product != ratbag->ids.product && - (info.vendor == USB_VENDOR_ID_LOGITECH && - info.product != (int16_t)USB_DEVICE_ID_UNIFYING_RECEIVER && - info.product != (int16_t)USB_DEVICE_ID_UNIFYING_RECEIVER2)) { + if (hid_id.product != ratbag->ids.product && + (hid_id.vendor == USB_VENDOR_ID_LOGITECH && + hid_id.product != USB_DEVICE_ID_UNIFYING_RECEIVER && + hid_id.product != USB_DEVICE_ID_UNIFYING_RECEIVER2)) { errno = -EINVAL; goto err; }