qemu-devel
[Top][All Lists]
Advanced

[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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]