Handle also WinSock errors in _dbus_error_from_errno
authorTor Lillqvist <tml@iki.fi>
Thu, 22 Oct 2009 10:19:23 +0000 (13:19 +0300)
committerRalf Habacker <ralf.habacker@freenet.de>
Tue, 1 Dec 2009 09:28:05 +0000 (10:28 +0100)
Handle those WinSock errors that match the errno values handled. Don't
bother handling those errors that are mapped to DBUS_ERROR_FAILED in
the switch as that is the default return value anyway.

dbus/dbus-sysdeps.c

index 68cea27..74be7db 100644 (file)
@@ -940,8 +940,8 @@ _dbus_generate_random_ascii (DBusString *str,
 }
 
 /**
- * Converts a UNIX or Windows errno
- * into a #DBusError name.
+ * Converts a UNIX errno, or Windows errno or WinSock error value into
+ * a #DBusError name.
  *
  * @todo should cover more errnos, specifically those
  * from open().
@@ -961,10 +961,18 @@ _dbus_error_from_errno (int error_number)
     case EPROTONOSUPPORT:
       return DBUS_ERROR_NOT_SUPPORTED;
 #endif
+#ifdef WSAEPROTONOSUPPORT
+    case WSAEPROTONOSUPPORT:
+      return DBUS_ERROR_NOT_SUPPORTED;
+#endif
 #ifdef EAFNOSUPPORT
     case EAFNOSUPPORT:
       return DBUS_ERROR_NOT_SUPPORTED;
 #endif
+#ifdef WSAEAFNOSUPPORT
+    case WSAEAFNOSUPPORT:
+      return DBUS_ERROR_NOT_SUPPORTED;
+#endif
 #ifdef ENFILE
     case ENFILE:
       return DBUS_ERROR_LIMITS_EXCEEDED; /* kernel out of memory */
@@ -989,42 +997,38 @@ _dbus_error_from_errno (int error_number)
     case ENOMEM:
       return DBUS_ERROR_NO_MEMORY;
 #endif
-#ifdef EINVAL
-    case EINVAL:
-      return DBUS_ERROR_FAILED;
-#endif
-#ifdef EBADF
-    case EBADF:
-      return DBUS_ERROR_FAILED;
-#endif
-#ifdef EFAULT
-    case EFAULT:
-      return DBUS_ERROR_FAILED;
-#endif
-#ifdef ENOTSOCK
-    case ENOTSOCK:
-      return DBUS_ERROR_FAILED;
-#endif
-#ifdef EISCONN
-    case EISCONN:
-      return DBUS_ERROR_FAILED;
-#endif
 #ifdef ECONNREFUSED
     case ECONNREFUSED:
       return DBUS_ERROR_NO_SERVER;
 #endif
+#ifdef WSAECONNREFUSED
+    case WSAECONNREFUSED:
+      return DBUS_ERROR_NO_SERVER;
+#endif
 #ifdef ETIMEDOUT
     case ETIMEDOUT:
       return DBUS_ERROR_TIMEOUT;
 #endif
+#ifdef WSAETIMEDOUT
+    case WSAETIMEDOUT:
+      return DBUS_ERROR_TIMEOUT;
+#endif
 #ifdef ENETUNREACH
     case ENETUNREACH:
       return DBUS_ERROR_NO_NETWORK;
 #endif
+#ifdef WSAENETUNREACH
+    case WSAENETUNREACH:
+      return DBUS_ERROR_NO_NETWORK;
+#endif
 #ifdef EADDRINUSE
     case EADDRINUSE:
       return DBUS_ERROR_ADDRESS_IN_USE;
 #endif
+#ifdef WSAEADDRINUSE
+    case WSAEADDRINUSE:
+      return DBUS_ERROR_ADDRESS_IN_USE;
+#endif
 #ifdef EEXIST
     case EEXIST:
       return DBUS_ERROR_FILE_EXISTS;