Skip to contentSkip to conversation

cosmetic fix to libxc for NetBSD

PATCH In review Roger Pau Monne 2 participants 5 messages Jan 19, 2012 – Feb 20, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cosmetic fix to libxc for NetBSD

Just a cosmetic fix to NetBSD libxc hypercall and a comment explaining why we return hypercall->retval instead of the output from ioctl.

#1 lore raw

PATCH 1/1 libxc/NetBSD: return ioctl return value on error

# HG changeset patch
# User Roger Pau Monne <[email protected]> # Date 1326968255 -3600
# Node ID d7d91b1eb79edf93230713d80ac6ac7738bdd71e # Parent f14765a3013a27f9e3948ee97fbdb798b057db04 libxc/NetBSD: return ioctl return value on error

NetBSD libxc hypercall implementation was returning -errno on error, instead of the actual error value from ioctl. Returning error is easier to understand, and the caller can always check errno.

tools/libxc/xc_netbsd.c +1 -1
diff -r f14765a3013a -r d7d91b1eb79e tools/libxc/xc_netbsd.c
@@ -97,7 +97,7 @@ static int netbsd_privcmd_hypercall(xc_i
     int error = ioctl(fd, IOCTL_PRIVCMD_HYPERCALL, hypercall);
 
     if (error < 0)
-        return -errno;
+        return error;
     else
         return hypercall->retval;
 }
#2 lore raw

PATCH 1/1 libxc: add comment to why NetBSD return hypercall->retval

In reply to Roger Pau Monne

# HG changeset patch
# User Roger Pau Monne <[email protected]> # Date 1326968470 -3600
# Node ID 484fb928e36c3150ed66cf102087565ded2769fd # Parent d7d91b1eb79edf93230713d80ac6ac7738bdd71e
libxc: add comment to why NetBSD return hypercall->retval

Added a comment that explains why NetBSD return hypercall->retval on success.

tools/libxc/xc_netbsd.c +6 -0
diff -r d7d91b1eb79e -r 484fb928e36c tools/libxc/xc_netbsd.c
@@ -96,6 +96,12 @@ static int netbsd_privcmd_hypercall(xc_i
     int fd = (int)h;
     int error = ioctl(fd, IOCTL_PRIVCMD_HYPERCALL, hypercall);
 
+    /*
+     * Since NetBSD ioctl can only return 0 on success or < 0 on
+     * error, if we want to return a value from ioctl we should
+     * do so by setting hypercall->retval, to mimic Linux ioctl
+     * implementation.
+     */
     if (error < 0)
         return error;
     else
#4 lore raw

Roger Pau Monné writes ("Re: [Xen-devel] [PATCH 0 of 2] cosmetic fix to libxc for NetBSD"):

Quoted 5 lines

I've forgot to add the Reported-by:... stuff, sorry, could someone add:

to both patches if they are to be committed to the repository?

Thanks, I have done that and applied both.

Ian.