[libvirt] mingw warnings

Richard W.M. Jones rjones at redhat.com
Mon Oct 27 09:59:08 UTC 2008


On Fri, Oct 24, 2008 at 07:50:13PM +0200, Jim Meyering wrote:
> I've been building with mingw to make sure that my gnulib-upgrade-and-extend
> patch doesn't break anything and found some compiler warnings.
> I fixed most of them, but this one is ugly:
> 
>   ../qemud/remote_protocol.c:317: warning: assignment from incompatible pointer type
>   ../qemud/remote_protocol.c:346: warning: assignment from incompatible pointer type
> 
> That's due to the fact that the mingw xdr.h header,
> /usr/i686-pc-mingw32/sys-root/mingw/include/rpc/xdr.h, defines this
> 
> #define	XDR_INLINE(xdrs, len)				\
> 	(*(xdrs)->x_ops->x_inline)(xdrs, len)
> 
> and has an x_inline member of type long*,
> 
> typedef struct {
> 	enum xdr_op	x_op;		/* operation; fast additional param */
> 	struct xdr_ops {
> 		bool_t	(*x_getlong)();	/* get a long from underlying stream */
> 		bool_t	(*x_putlong)();	/* put a long to " */
> 		bool_t	(*x_getbytes)();/* get some bytes from " */
> 		bool_t	(*x_putbytes)();/* put some bytes to " */
> 		u_int	(*x_getpostn)();/* returns bytes off from beginning */
> 		bool_t  (*x_setpostn)();/* lets you reposition the stream */
> 		long *	(*x_inline)();	/* buf quick ptr to buffered data */
> 
> while we're used to one with type matching buf: int32_t*:
> 
> If you're serious about getting rid of warnings even on mingw,
> here's one approach:

I guess I'd agree with Dan that the best place to fix this is in
PortableXDR itself.

Converting that 'long *' -> 'int32_t *' should be OK I think?  Unless
that x_inline member is used for other XDR types.

Rich.

PS. Windows is a strange platform in that when they moved to 64 bits,
they didn't go with LP64, but with LLP64.  So 'long' on Windows is
always 32 bits, even on Win64.  This is only a theoretical concern for
MinGW at the moment, but understanding it may help portability issues
in future.  In particular, all the places which use 'long' in the
libvirt public API are to be considered suspect.

-- 
Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into Xen guests.
http://et.redhat.com/~rjones/virt-p2v




More information about the libvir-list mailing list