[Spice-devel] [PATCH spice-gtk 4/4] usbredir: provide out own libusb_strerror for now

Hans de Goede hdegoede at redhat.com
Wed Aug 31 06:21:59 PDT 2011


libusb_strerror is not going upstream because of i18n worries, provide
our own for now.

Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
 gtk/channel-usbredir.c |   40 +++++++++++++++++++++++++++++++++++++---
 1 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/gtk/channel-usbredir.c b/gtk/channel-usbredir.c
index b567fcc..57b5a5a 100644
--- a/gtk/channel-usbredir.c
+++ b/gtk/channel-usbredir.c
@@ -33,8 +33,42 @@
 
 #include "spice-channel-priv.h"
 
-/* libusb_strerror is awaiting merging upstream */
-#define libusb_strerror(error) "unknown"
+/* libusb_strerror is not going upstream because of i18n worries, provide
+   our own for now */
+static const char* my_libusb_strerror(enum libusb_error errcode)
+{
+    switch (errcode) {
+    case LIBUSB_SUCCESS:
+        return "Success";
+    case LIBUSB_ERROR_IO:
+        return "Input/output error";
+    case LIBUSB_ERROR_INVALID_PARAM:
+        return "Invalid parameter";
+    case LIBUSB_ERROR_ACCESS:
+        return "Access denied (insufficient permissions)";
+    case LIBUSB_ERROR_NO_DEVICE:
+        return "No such device (it may have been disconnected)";
+    case LIBUSB_ERROR_NOT_FOUND:
+        return "Entity not found";
+    case LIBUSB_ERROR_BUSY:
+        return "Resource busy";
+    case LIBUSB_ERROR_TIMEOUT:
+        return "Operation timed out";
+    case LIBUSB_ERROR_OVERFLOW:
+        return "Overflow";
+    case LIBUSB_ERROR_PIPE:
+        return "Pipe error";
+    case LIBUSB_ERROR_INTERRUPTED:
+        return "System call interrupted (perhaps due to signal)";
+    case LIBUSB_ERROR_NO_MEM:
+        return "Insufficient memory";
+    case LIBUSB_ERROR_NOT_SUPPORTED:
+        return "Operation not supported or unimplemented on this platform";
+    case LIBUSB_ERROR_OTHER:
+        return "Other error";
+    }
+    return "Unknown error";
+}
 
 /**
  * SECTION:channel-usbredir
@@ -140,7 +174,7 @@ gboolean spice_usbredir_channel_connect(SpiceUsbredirChannel *channel,
     if (rc != 0) {
         g_set_error(err, SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
                     "Could not open usb device: %s [%i]",
-                    libusb_strerror(rc), rc);
+                    my_libusb_strerror(rc), rc);
         return FALSE;
     }
 
-- 
1.7.6.1



More information about the Spice-devel mailing list