Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LV82L-0008Nt-GX for qemu-devel@nongnu.org; Thu, 05 Feb 2009 12:29:13 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LV82J-0008M5-DT for qemu-devel@nongnu.org; Thu, 05 Feb 2009 12:29:12 -0500 Received: from [199.232.76.173] (port=47895 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LV82J-0008Lp-40 for qemu-devel@nongnu.org; Thu, 05 Feb 2009 12:29:11 -0500 Received: from smtp02.citrix.com ([66.165.176.63]:39801) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LV82I-00059G-QO for qemu-devel@nongnu.org; Thu, 05 Feb 2009 12:29:10 -0500 Message-Id: <0104bb2c44d676227c906d807df9568c6a42238d.1233854876.git.Ian.Jackson@eu.citrix.com> In-Reply-To: <6f129132214575f261cb44404f901281ad6bd699.1233854876.git.Ian.Jackson@eu.citrix.com> References: <6f129132214575f261cb44404f901281ad6bd699.1233854876.git.Ian.Jackson@eu.citrix.com> From: Ian Jackson Date: Wed, 4 Feb 2009 15:28:38 +0000 Subject: [Qemu-devel] [PATCH 3/5] usb-linux.c: somewhat improve some error and debugging messages Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: ian.jackson@eu.citrix.com 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 --- 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