From a8897ca8cab38d15d19d2e0fdc86df7815b2f04f Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Tue, 17 May 2016 17:18:09 +0200 Subject: [PATCH 1/2] tools: hidpp20-dump: prevent segfault when called on non HID++ device Signed-off-by: Benjamin Tissoires --- tools/hidpp20-dump-page.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/hidpp20-dump-page.c b/tools/hidpp20-dump-page.c index f733902a..05ceb649 100644 --- a/tools/hidpp20-dump-page.c +++ b/tools/hidpp20-dump-page.c @@ -111,6 +111,8 @@ main(int argc, char **argv) hidpp_device_init(&base, fd); dev = hidpp20_device_new(&base, 0xff); + if (!dev) + error(1, 0, "Failed to open %s as a HID++ 2.0 device", path); if (argc == 2) rc = dump_everything(dev); From d54d77c3955989de7059d38e5f0e5848b10d97b7 Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Sat, 14 May 2016 09:42:57 +0200 Subject: [PATCH 2/2] hidpp20drv: ignore errors of PAGE_ADJUSTABLE_DPI The G602 seems to fail here, but it is safe to continue. Signed-off-by: Benjamin Tissoires --- src/driver-hidpp20.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/driver-hidpp20.c b/src/driver-hidpp20.c index 4cb0037e..526c0be1 100644 --- a/src/driver-hidpp20.c +++ b/src/driver-hidpp20.c @@ -668,13 +668,13 @@ hidpp20drv_init_feature(struct ratbag_device *device, uint16_t feature) } case HIDPP_PAGE_ADJUSTABLE_DPI: { log_debug(ratbag, "device has adjustable dpi\n"); - ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_SWITCHABLE_RESOLUTION); - drv_data->capabilities |= HIDPP_CAP_SWITCHABLE_RESOLUTION_2201; /* we read the profile once to get the correct number of * supported resolutions. */ rc = hidpp20drv_read_resolution_dpi_2201(device); if (rc < 0) - return rc; + return 0; /* this is not a hard failure */ + ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_SWITCHABLE_RESOLUTION); + drv_data->capabilities |= HIDPP_CAP_SWITCHABLE_RESOLUTION_2201; break; } case HIDPP_PAGE_SPECIAL_KEYS_BUTTONS: {