[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 3/5] usb-linux.c: somewhat improve some error and de
From: |
Ian Jackson |
Subject: |
[Qemu-devel] [PATCH 3/5] usb-linux.c: somewhat improve some error and debugging messages |
Date: |
Wed, 4 Feb 2009 15:28:38 +0000 |
Firstly, always print strerror(errno) (when relevant) rather than
numerical errno. Numerical errno values are not very useful and the
libc provides us with strerror especially for this purpose.
Secondly, distinguish previously-identical messages relating to
control and data transfers.
Signed-off-by: Ian Jackson <address@hidden>
---
usb-linux.c | 23 ++++++++++++-----------
1 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/usb-linux.c b/usb-linux.c
index 3019a13..8498b1d 100644
--- a/usb-linux.c
+++ b/usb-linux.c
@@ -258,7 +258,7 @@ static void async_complete(void *opaque)
return;
}
- dprintf("husb: async. reap urb failed errno %d\n", errno);
+ dprintf("husb: async. reap urb failed: %s\n", strerror(errno));
return;
}
@@ -302,7 +302,7 @@ static void async_cancel(USBPacket *unused, void *opaque)
int r = ioctl(s->fd, USBDEVFS_DISCARDURB, aurb);
if (r < 0) {
- dprintf("husb: async. discard urb failed errno %d\n", errno);
+ dprintf("husb: async. discard urb failed: %s\n", strerror(errno));
}
}
@@ -444,7 +444,7 @@ static int usb_host_handle_data(USBHostDevice *s, USBPacket
*p)
aurb = async_alloc();
if (!aurb) {
- dprintf("husb: async malloc failed\n");
+ dprintf("husb: async malloc (data) failed\n");
return USB_RET_NAK;
}
aurb->hdev = s;
@@ -460,8 +460,8 @@ static int usb_host_handle_data(USBHostDevice *s, USBPacket
*p)
if (is_halted(s, p->devep)) {
ret = ioctl(s->fd, USBDEVFS_CLEAR_HALT, &urb->endpoint);
if (ret < 0) {
- dprintf("husb: failed to clear halt. ep 0x%x errno %d\n",
- urb->endpoint, errno);
+ dprintf("husb: failed to clear halt. ep 0x%x: %s\n",
+ urb->endpoint, strerror(errno));
return USB_RET_NAK;
}
clear_halt(s, p->devep);
@@ -485,7 +485,7 @@ static int usb_host_handle_data(USBHostDevice *s, USBPacket
*p)
dprintf("husb: data submit. ep 0x%x len %u aurb %p\n", urb->endpoint,
p->len, aurb);
if (ret < 0) {
- dprintf("husb: submit failed. errno %d\n", errno);
+ dprintf("husb: submit data failed: %s\n", strerror(errno));
async_free(aurb);
switch(errno) {
@@ -522,7 +522,8 @@ static int usb_host_set_config(USBHostDevice *s, int config)
int ret = ioctl(s->fd, USBDEVFS_SETCONFIGURATION, &config);
- dprintf("husb: ctrl set config %d ret %d errno %d\n", config, ret, errno);
+ dprintf("husb: ctrl set config %d ret %d: %s\n", config, ret,
+ ret < 0 ? strerror(errno) : "ok");
if (ret < 0)
return ctrl_error();
@@ -540,8 +541,8 @@ static int usb_host_set_interface(USBHostDevice *s, int
iface, int alt)
si.altsetting = alt;
ret = ioctl(s->fd, USBDEVFS_SETINTERFACE, &si);
- dprintf("husb: ctrl set iface %d altset %d ret %d errno %d\n",
- iface, alt, ret, errno);
+ dprintf("husb: ctrl set iface %d altset %d ret %d: %s\n",
+ iface, alt, ret, ret < 0 ? strerror(errno): "ok");
if (ret < 0)
return ctrl_error();
@@ -585,7 +586,7 @@ static int usb_host_handle_control(USBHostDevice *s,
USBPacket *p)
aurb = async_alloc();
if (!aurb) {
- dprintf("husb: async malloc failed\n");
+ dprintf("husb: async malloc (ctrl) failed\n");
return USB_RET_NAK;
}
aurb->hdev = s;
@@ -614,7 +615,7 @@ static int usb_host_handle_control(USBHostDevice *s,
USBPacket *p)
dprintf("husb: submit ctrl. len %u aurb %p\n", urb->buffer_length, aurb);
if (ret < 0) {
- dprintf("husb: submit failed. errno %d\n", errno);
+ dprintf("husb: submit ctrl failed: %s\n", strerror(errno));
async_free(aurb);
switch(errno) {
--
1.4.4.4
- [Qemu-devel] [PATCH 1/5] usb-linux.c: allow full-size control transfers, do not overrun buffer, Ian Jackson, 2009/02/05
- [Qemu-devel] [PATCH 5/5] usb-linux.c: fix handling of asynchronous isochronous completion, Ian Jackson, 2009/02/05
- [Qemu-devel] [PATCH 3/5] usb-linux.c: somewhat improve some error and debugging messages,
Ian Jackson <=
- [Qemu-devel] [PATCH 2/5] usb-linux.c: set urb->type correctly for control and interrupt transfers, Ian Jackson, 2009/02/05
- [Qemu-devel] [PATCH 4/5] usb-linux.c: more improved debugging messages (endpoint table), Ian Jackson, 2009/02/05
- Re: [Qemu-devel] [PATCH 1/5] usb-linux.c: allow full-size control transfers, do not overrun buffer, malc, 2009/02/05