[libvirt] PATCH: Fix a small bug in rpcgen_fix.pl script

Richard W.M. Jones rjones at redhat.com
Thu May 22 17:47:05 UTC 2008


There's a warning about type-punning in CVS libvirt.

We normally rewrite the code generated by glibc rpcgen to avoid these
warnings, but because the variable in question has a name containing
an uppercase letter, and because the regexp we're using is
case-sensitive and only matches lowercase identifiers, the rewrite
wasn't happening.

Attached patch fixes this.

Rich.

-- 
Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://et.redhat.com/~rjones/virt-top
-------------- next part --------------
Index: qemud/remote_protocol.c
===================================================================
RCS file: /data/cvs/libvirt/qemud/remote_protocol.c,v
retrieving revision 1.11
diff -u -r1.11 remote_protocol.c
--- qemud/remote_protocol.c	22 May 2008 15:20:25 -0000	1.11
+++ qemud/remote_protocol.c	22 May 2008 17:01:20 -0000
@@ -400,8 +400,9 @@
 bool_t
 xdr_remote_node_get_cells_free_memory_ret (XDR *xdrs, remote_node_get_cells_free_memory_ret *objp)
 {
+        char **objp_cpp0 = (char **) (void *) &objp->freeMems.freeMems_val;
 
-         if (!xdr_array (xdrs, (char **)&objp->freeMems.freeMems_val, (u_int *) &objp->freeMems.freeMems_len, REMOTE_NODE_MAX_CELLS,
+         if (!xdr_array (xdrs, objp_cpp0, (u_int *) &objp->freeMems.freeMems_len, REMOTE_NODE_MAX_CELLS,
                 sizeof (quad_t), (xdrproc_t) xdr_quad_t))
                  return FALSE;
         return TRUE;
Index: qemud/rpcgen_fix.pl
===================================================================
RCS file: /data/cvs/libvirt/qemud/rpcgen_fix.pl,v
retrieving revision 1.2
diff -u -r1.2 rpcgen_fix.pl
--- qemud/rpcgen_fix.pl	22 May 2008 15:20:25 -0000	1.2
+++ qemud/rpcgen_fix.pl	22 May 2008 17:01:22 -0000
@@ -46,7 +46,7 @@
 	my %uses = ();
 	my $i = 0;
 	foreach (@function) {
-	    $uses{$1} = $i++ if m/\(char \*\*\)\&(objp->[a-z_.]+_val)/;
+	    $uses{$1} = $i++ if m/\(char \*\*\)\&(objp->[a-z_.]+_val)/i;
 	}
 	if (keys %uses >= 1) {
 	    my $i = 1;
@@ -59,7 +59,7 @@
 	    }
 	    @function =
 		map { s{\(char \*\*\)\&(objp->[a-z_.]+_val)}
-		       {objp_cpp$uses{$1}}g; $_ } @function;
+		       {objp_cpp$uses{$1}}gi; $_ } @function;
 	}
 
 	# The code uses 'IXDR_PUT_{U_,}LONG' but it's wrong in two


More information about the libvir-list mailing list