From 2a6c1d7a605e11189e4539db84b1c4da5707dbc6 Mon Sep 17 00:00:00 2001 From: Bryce Harrington Date: Thu, 12 Feb 2009 17:52:43 -0800 Subject: Add descriptive messages for device-has-changed errs As can be seen in e.g. bugs 19819 & 20025, it can be unclear what exactly caused a given "Device has changed - disabled" error. This patch adds some more specific messages to give a better clue on what exactly was seen to have changed. Signed-off-by: Peter Hutterer --- src/evdev.c | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/src/evdev.c b/src/evdev.c index e8c1e2c..408dafc 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -1226,54 +1226,66 @@ EvdevCacheCompare(InputInfoPtr pInfo, BOOL compare) goto error; } - if (compare && strcmp(pEvdev->name, name)) + if (compare && strcmp(pEvdev->name, name)) { + xf86Msg(X_ERROR, "%s: device name changed: %s != %s\n", pInfo->name, pEvdev->name, name); goto error; + } if (ioctl(pInfo->fd, EVIOCGBIT(0, sizeof(bitmask)), bitmask) < 0) { - xf86Msg(X_ERROR, "ioctl EVIOCGBIT failed: %s\n", strerror(errno)); + xf86Msg(X_ERROR, "%s: ioctl EVIOCGBIT failed: %s\n", pInfo->name, strerror(errno)); goto error; } - if (compare && memcmp(pEvdev->bitmask, bitmask, sizeof(bitmask))) + if (compare && memcmp(pEvdev->bitmask, bitmask, sizeof(bitmask))) { + xf86Msg(X_ERROR, "%s: device bitmask has changed\n", pInfo->name); goto error; + } if (ioctl(pInfo->fd, EVIOCGBIT(EV_REL, sizeof(rel_bitmask)), rel_bitmask) < 0) { - xf86Msg(X_ERROR, "ioctl EVIOCGBIT failed: %s\n", strerror(errno)); + xf86Msg(X_ERROR, "%s: ioctl EVIOCGBIT failed: %s\n", pInfo->name, strerror(errno)); goto error; } - if (compare && memcmp(pEvdev->rel_bitmask, rel_bitmask, sizeof(rel_bitmask))) + if (compare && memcmp(pEvdev->rel_bitmask, rel_bitmask, sizeof(rel_bitmask))) { + xf86Msg(X_ERROR, "%s: device rel_bitmask has changed\n", pInfo->name); goto error; + } if (ioctl(pInfo->fd, EVIOCGBIT(EV_ABS, sizeof(abs_bitmask)), abs_bitmask) < 0) { - xf86Msg(X_ERROR, "ioctl EVIOCGBIT failed: %s\n", strerror(errno)); + xf86Msg(X_ERROR, "%s: ioctl EVIOCGBIT failed: %s\n", pInfo->name, strerror(errno)); goto error; } - if (compare && memcmp(pEvdev->abs_bitmask, abs_bitmask, sizeof(abs_bitmask))) + if (compare && memcmp(pEvdev->abs_bitmask, abs_bitmask, sizeof(abs_bitmask))) { + xf86Msg(X_ERROR, "%s: device abs_bitmask has changed\n", pInfo->name); goto error; + } if (ioctl(pInfo->fd, EVIOCGBIT(EV_KEY, sizeof(key_bitmask)), key_bitmask) < 0) { - xf86Msg(X_ERROR, "ioctl EVIOCGBIT failed: %s\n", strerror(errno)); + xf86Msg(X_ERROR, "%s: ioctl EVIOCGBIT failed: %s\n", pInfo->name, strerror(errno)); goto error; } - if (compare && memcmp(pEvdev->key_bitmask, key_bitmask, sizeof(key_bitmask))) + if (compare && memcmp(pEvdev->key_bitmask, key_bitmask, sizeof(key_bitmask))) { + xf86Msg(X_ERROR, "%s: device key_bitmask has changed\n", pInfo->name); goto error; + } if (ioctl(pInfo->fd, EVIOCGBIT(EV_LED, sizeof(led_bitmask)), led_bitmask) < 0) { - xf86Msg(X_ERROR, "ioctl EVIOCGBIT failed: %s\n", strerror(errno)); + xf86Msg(X_ERROR, "%s: ioctl EVIOCGBIT failed: %s\n", pInfo->name, strerror(errno)); goto error; } - if (compare && memcmp(pEvdev->led_bitmask, led_bitmask, sizeof(led_bitmask))) + if (compare && memcmp(pEvdev->led_bitmask, led_bitmask, sizeof(led_bitmask))) { + xf86Msg(X_ERROR, "%s: device led_bitmask has changed\n", pInfo->name); goto error; + } memset(absinfo, 0, sizeof(absinfo)); @@ -1282,7 +1294,7 @@ EvdevCacheCompare(InputInfoPtr pInfo, BOOL compare) if (TestBit(i, abs_bitmask)) { if (ioctl(pInfo->fd, EVIOCGABS(i), &absinfo[i]) < 0) { - xf86Msg(X_ERROR, "ioctl EVIOCGABS failed: %s\n", strerror(errno)); + xf86Msg(X_ERROR, "%s: ioctl EVIOCGABS failed: %s\n", pInfo->name, strerror(errno)); goto error; } /* ignore current position (value) in comparison (bug #19819) */ @@ -1290,8 +1302,10 @@ EvdevCacheCompare(InputInfoPtr pInfo, BOOL compare) } } - if (compare && memcmp(pEvdev->absinfo, absinfo, sizeof(absinfo))) - goto error; + if (compare && memcmp(pEvdev->absinfo, absinfo, sizeof(absinfo))) { + xf86Msg(X_ERROR, "%s: device absinfo has changed\n", pInfo->name); + goto error; + } /* cache info */ if (!compare) -- cgit v1.2.3