[libvirt] mingw warnings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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:

diff --git a/qemud/remote_protocol.c b/qemud/remote_protocol.c
index 68e9696..c8cf504 100644
--- a/qemud/remote_protocol.c
+++ b/qemud/remote_protocol.c
@@ -314,7 +314,7 @@ xdr_remote_node_get_info_ret (XDR *xdrs, remote_node_get_info_ret *objp)
                          return FALSE;
                  if (!xdr_quad_t (xdrs, &objp->memory))
                          return FALSE;
-                buf = XDR_INLINE (xdrs, 6 * BYTES_PER_XDR_UNIT);
+                buf = (void*)XDR_INLINE (xdrs, 6 * BYTES_PER_XDR_UNIT);
                 if (buf == NULL) {
                          if (!xdr_int (xdrs, &objp->cpus))
                                  return FALSE;
@@ -343,7 +343,7 @@ xdr_remote_node_get_info_ret (XDR *xdrs, remote_node_get_info_ret *objp)
                          return FALSE;
                  if (!xdr_quad_t (xdrs, &objp->memory))
                          return FALSE;
-                buf = XDR_INLINE (xdrs, 6 * BYTES_PER_XDR_UNIT);
+                buf = (void*)XDR_INLINE (xdrs, 6 * BYTES_PER_XDR_UNIT);
                 if (buf == NULL) {
                          if (!xdr_int (xdrs, &objp->cpus))
                                  return FALSE;

Better would be to fix the decl in xdr.h, but probably not feasible.
Alternatively, redefine XDR_INLINE for mingw, adding the void* cast in that.
But that means peeking inside (and copying) the current definition,
so I prefer the above.

So I'm leaning towards using the patch above.

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]