[vbox-dev] [PATCH 1/2] RTErrConvertTo/FromErrno: Add translation for some extra codes

Hans de Goede hdegoede at redhat.com
Tue Aug 1 15:19:01 GMT 2017


Some VERR_ codes require special error handling in userspace, make
sure that these survive being converted to an errno and back again.

Specifically this commit adds support for the following VERR_ codes:

VERR_NOT_FOUND
VERR_HGCM_SERVICE_NOT_FOUND
VERR_BUFFER_OVERFLOW
VERR_OUT_OF_RANGE

To RTErrConvertToErrno and RTErrConvertFromErrno.

Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
 src/VBox/Runtime/common/err/RTErrConvertFromErrno.cpp | 9 +++++----
 src/VBox/Runtime/common/err/RTErrConvertToErrno.cpp   | 9 +++++----
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/VBox/Runtime/common/err/RTErrConvertFromErrno.cpp b/src/VBox/Runtime/common/err/RTErrConvertFromErrno.cpp
index a79cda5..d0cb45b 100644
--- a/src/VBox/Runtime/common/err/RTErrConvertFromErrno.cpp
+++ b/src/VBox/Runtime/common/err/RTErrConvertFromErrno.cpp
@@ -34,6 +34,7 @@
 #include <iprt/log.h>
 #include <iprt/assert.h>
 #include <iprt/errno.h>
+#include <VBox/err.h>
 
 
 RTDECL(int)  RTErrConvertFromErrno(unsigned uNativeCode)
@@ -153,7 +154,7 @@ RTDECL(int)  RTErrConvertFromErrno(unsigned uNativeCode)
         case EDOM:              return VERR_INVALID_PARAMETER;  /** @todo fix duplicate error */
 #endif
 #ifdef ERANGE
-        case ERANGE:            return VERR_INVALID_PARAMETER;  /** @todo fix duplicate error */
+        case ERANGE:            return VERR_OUT_OF_RANGE;
 #endif
 #ifdef EDEADLK
         case EDEADLK:           return VERR_DEADLOCK;
@@ -175,10 +176,10 @@ RTDECL(int)  RTErrConvertFromErrno(unsigned uNativeCode)
 #endif
         //41??
 #ifdef ENOMSG
-        //case ENOMSG           42      /* No message of desired type */
+        case ENOMSG:            return VERR_NOT_FOUND;
 #endif
 #ifdef EIDRM
-        //case EIDRM            43      /* Identifier removed */
+        case EIDRM:             return VERR_HGCM_SERVICE_NOT_FOUND;
 #endif
 #ifdef ECHRNG
         //case ECHRNG           44      /* Channel number out of range */
@@ -272,7 +273,7 @@ RTDECL(int)  RTErrConvertFromErrno(unsigned uNativeCode)
         //case EBADMSG          74      /* Not a data message */
 #endif
 #ifdef EOVERFLOW
-        case EOVERFLOW:         return VERR_TOO_MUCH_DATA;   /** @todo fix duplicate error */
+        case EOVERFLOW:         return VERR_BUFFER_OVERFLOW;
 #endif
 #ifdef ENOTUNIQ
         case ENOTUNIQ:          return VERR_NET_NOT_UNIQUE_NAME;
diff --git a/src/VBox/Runtime/common/err/RTErrConvertToErrno.cpp b/src/VBox/Runtime/common/err/RTErrConvertToErrno.cpp
index 6e5823c..d32e7b5 100644
--- a/src/VBox/Runtime/common/err/RTErrConvertToErrno.cpp
+++ b/src/VBox/Runtime/common/err/RTErrConvertToErrno.cpp
@@ -34,6 +34,7 @@
 #include <iprt/assert.h>
 #include <iprt/err.h>
 #include <iprt/errno.h>
+#include <VBox/err.h>
 
 
 RTDECL(int) RTErrConvertToErrno(int iErr)
@@ -155,7 +156,7 @@ RTDECL(int) RTErrConvertToErrno(int iErr)
         //case VERR_INVALID_PARAMETER:    return EDOM;
 #endif
 #ifdef ERANGE
-        //case VERR_INVALID_PARAMETER:    return ERANGE;
+        case VERR_OUT_OF_RANGE:                     return ERANGE;
 #endif
 #ifdef EDEADLK
         case VERR_DEADLOCK:                         return EDEADLK;
@@ -178,10 +179,10 @@ RTDECL(int) RTErrConvertToErrno(int iErr)
 #endif
         //41??
 #ifdef ENOMSG
-        //case ENOMSG           42      /* No message of desired type */
+        case VERR_NOT_FOUND:                        return ENOMSG;
 #endif
 #ifdef EIDRM
-        //case EIDRM            43      /* Identifier removed */
+        case VERR_HGCM_SERVICE_NOT_FOUND:           return EIDRM;
 #endif
 #ifdef ECHRNG
         //case ECHRNG           44      /* Channel number out of range */
@@ -275,7 +276,7 @@ RTDECL(int) RTErrConvertToErrno(int iErr)
         //case EBADMSG          74      /* Not a data message */
 #endif
 #ifdef EOVERFLOW
-        //case VERR_TOO_MUCH_DATA:                    return EOVERFLOW;
+        case VERR_BUFFER_OVERFLOW:                  return EOVERFLOW;
 #endif
 #ifdef ENOTUNIQ
         case VERR_NET_NOT_UNIQUE_NAME:              return ENOTUNIQ;
-- 
2.9.4




More information about the vbox-dev mailing list