]> xenbits.xensource.com Git - people/sstabellini/xen-unstable.git/.git/commitdiff
libs/foreignmem: Fix/simplify errno handling for map_resource
authorAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 3 Feb 2021 15:43:35 +0000 (15:43 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 3 Feb 2021 19:25:35 +0000 (19:25 +0000)
Simplify the FreeBSD and Linux logic, left in this state by the previous
change.  No functional change.

Duplicate the FreeBSD logic for NetBSD, to maintain the uniform ABI for
callers that EOPNOTSUPP covers all Xen/Kernel support.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Ian Jackson <iwj@xenproject.org>
Release-Acked-by: Ian Jackson <iwj@xenproject.org>
tools/libs/foreignmemory/freebsd.c
tools/libs/foreignmemory/linux.c
tools/libs/foreignmemory/netbsd.c

index 04bfa806b08e15f5295afb030ebd9cff2399955e..d94ea078622244f6f73ccb27a7c8cc96bc155cca 100644 (file)
@@ -133,9 +133,7 @@ int osdep_xenforeignmemory_map_resource(xenforeignmemory_handle *fmem,
     {
         int saved_errno;
 
-        if ( errno != ENOSYS )
-            ;
-        else
+        if ( errno == ENOSYS )
             errno = EOPNOTSUPP;
 
         if ( fres->addr )
index 050b9ed3a548df68adf0461b4c8e09397d544ebe..c1f35e2db7114c489dd9b649acbeedfce89eb011 100644 (file)
@@ -325,9 +325,7 @@ int osdep_xenforeignmemory_map_resource(
     {
         int saved_errno;
 
-        if ( errno != fmem->unimpl_errno && errno != EOPNOTSUPP )
-            ;
-        else
+        if ( errno == fmem->unimpl_errno )
             errno = EOPNOTSUPP;
 
         if ( fres->addr )
index 565682e064cb8eb6ece649d7f3554fab7769eeb1..c0b1b8f79d9d919ed890da36ce1ccc6689b92e6e 100644 (file)
@@ -147,6 +147,9 @@ int osdep_xenforeignmemory_map_resource(
     rc = ioctl(fmem->fd, IOCTL_PRIVCMD_MMAP_RESOURCE, &mr);
     if ( rc )
     {
+        if ( errno == ENOSYS )
+            errno = EOPNOTSUPP;
+
         if ( fres->addr )
         {
             int saved_errno = errno;