[PATCH] Avoid scary error message on input device unplug
Bernardo Innocenti
bernie at codewiz.org
Wed Nov 14 12:49:36 PST 2007
Reading from evdev can fail when you hot-unplog a USB mouse. In this case,
read() returns -1 and errno is set to ENODEV.
This patch moves the test for this event before the test for the
abnormal error where read() returned something that doesn't match
the size of an event.
Signed-off-by: Bernardo Innocenti <bernie at codewiz.org>
---
src/evdev.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/evdev.c b/src/evdev.c
index dc801d0..20666a4 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -224,15 +224,15 @@ EvdevReadInput(InputInfoPtr pInfo)
while (xf86WaitForInput (pInfo->fd, 0) > 0) {
len = read(pInfo->fd, &ev, sizeof(ev));
if (len != sizeof(ev)) {
- /* The kernel promises that we always only read a complete
- * event, so len != sizeof ev is an error. */
- xf86Msg(X_ERROR, "Read error: %s (%d, %d != %zd)\n",
- strerror(errno), errno, len, sizeof (ev));
if (len < 0)
{
xf86DisableDevice(pInfo->dev, TRUE);
return;
}
+ /* The kernel promises that we always only read a complete
+ * event, so len != sizeof ev is an error. */
+ xf86Msg(X_ERROR, "Read error: %s (%d, %d != %zd)\n",
+ strerror(errno), errno, len, sizeof (ev));
break;
}
--
1.5.3.5.561.g140d
More information about the xorg
mailing list