From 9bb7297ad72dbefed15da22cb22cf8ac3547b7ca Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Thu, 22 Oct 2009 13:19:23 +0300 Subject: [PATCH] Handle also WinSock errors in _dbus_error_from_errno 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 | 48 ++++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/dbus/dbus-sysdeps.c b/dbus/dbus-sysdeps.c index 68cea2730..74be7dbb7 100644 --- a/dbus/dbus-sysdeps.c +++ b/dbus/dbus-sysdeps.c @@ -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; -- 2.47.3