[Libguestfs] [PATCH 3/3] lib: Add third, zero parameter to xdrproc_t

Margaret Lewicka margaret at meaningless.name
Thu Feb 12 17:28:48 UTC 2015


As advised by Daniel P. Berrange, the third parameter can be passed on all
platforms rather than specifically Mac.

Quoting a libvirt commit rationale after Daniel:

 commit 9fa3a8ab6fd82ad2f5a14b490696085061418718
 Author: Doug Goldstein <cardoe at cardoe.com>
 Date:   Wed Oct 30 11:22:58 2013 -0500

   MacOS: Handle changes to xdrproc_t definition

   With Mac OS X 10.9, xdrproc_t is no longer defined as:

   typedef bool_t (*xdrproc_t)(XDR *, ...);

   but instead as:

   typedef bool_t (*xdrproc_t)(XDR *, void *, unsigned int);

   For reference, Linux systems typically define it as:

   typedef bool_t (*xdrproc_t)(XDR *, void *, ...);

   The rationale explained in the header is that using a vararg is
   incorrect and has a potential to change the ABI slightly do to compiler
   optimizations taken and the undefined behavior. They decided
   to specify the exact number of parameters and for compatibility with old
   code decided to make the signature require 3 arguments. The third
   argument is ignored for cases that its not used and its recommended to
   supply a 0.
---
 src/proto.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/proto.c b/src/proto.c
index 92ae84d..e229abb 100644
--- a/src/proto.c
+++ b/src/proto.c
@@ -252,7 +252,7 @@ guestfs___send (guestfs_h *g, int proc_nr,
    * have no parameters.
    */
   if (xdrp) {
-    if (!(*xdrp) (&xdr, args)) {
+    if (!(*xdrp) (&xdr, args, 0)) {
       error (g, _("dispatch failed to marshal args"));
       return -1;
     }
@@ -681,7 +681,7 @@ guestfs___recv (guestfs_h *g, const char *fn,
       return -1;
     }
   } else {
-    if (xdrp && ret && !xdrp (&xdr, ret)) {
+    if (xdrp && ret && !xdrp (&xdr, ret, 0)) {
       error (g, "%s: failed to parse reply", fn);
       xdr_destroy (&xdr);
       return -1;
-- 
1.9.3




More information about the Libguestfs mailing list