[libvirt] [PATCH] Cast callbacks to the correct type

# HG changeset patch # User john.levon@sun.com # Date 1229367890 28800 # Node ID 728f90c86f2cd950463923c80fc57754d6e762eb # Parent 6a8e82d7d2e166880fed8d7ad860a3e2e93d62be Cast callbacks to the correct type Avoid compiler warnings by performing the correct casts. Signed-off-by: John Levon <john.levon@sun.com> diff --git a/src/libvirt.c b/src/libvirt.c --- a/src/libvirt.c +++ b/src/libvirt.c @@ -5806,7 +5806,8 @@ virConnectDomainEventRegister(virConnect } if ((conn->driver) && (conn->driver->domainEventRegister)) - return conn->driver->domainEventRegister (conn, cb, opaque, freecb); + return conn->driver->domainEventRegister (conn, (void *)cb, + opaque, freecb); return -1; } @@ -5835,9 +5836,9 @@ virConnectDomainEventDeregister(virConne return (-1); } if ((conn->driver) && (conn->driver->domainEventDeregister)) - return conn->driver->domainEventDeregister (conn, cb); - - return -1; -} - - + return conn->driver->domainEventDeregister (conn, (void *)cb); + + return -1; +} + + diff --git a/src/remote_internal.c b/src/remote_internal.c --- a/src/remote_internal.c +++ b/src/remote_internal.c @@ -4735,7 +4735,7 @@ static int remoteDomainEventRegister (vi return -1; } if (virDomainEventCallbackListAdd(conn, priv->callbackList, - callback, opaque, freecb) < 0) { + (virConnectDomainEventCallback)callback, opaque, freecb) < 0) { error (conn, VIR_ERR_RPC, _("adding cb to list")); return -1; } @@ -4757,7 +4757,7 @@ static int remoteDomainEventDeregister ( struct private_data *priv = conn->privateData; if (virDomainEventCallbackListRemove(conn, priv->callbackList, - callback) < 0) { + (virConnectDomainEventCallback)callback) < 0) { error (conn, VIR_ERR_RPC, _("removing cb fron list")); return -1; } diff --git a/src/xen_unified.c b/src/xen_unified.c --- a/src/xen_unified.c +++ b/src/xen_unified.c @@ -1372,7 +1372,7 @@ xenUnifiedDomainEventRegister (virConnec conn->refs++; return virDomainEventCallbackListAdd(conn, priv->domainEventCallbacks, - callback, opaque, freefunc); + (virConnectDomainEventCallback)callback, opaque, freefunc); } static int @@ -1387,7 +1387,7 @@ xenUnifiedDomainEventDeregister (virConn } ret = virDomainEventCallbackListRemove(conn, priv->domainEventCallbacks, - callback); + (virConnectDomainEventCallback)callback); virUnrefConnect(conn); return ret; }

On Mon, Dec 15, 2008 at 11:58:26AM -0800, john.levon@sun.com wrote:
# HG changeset patch # User john.levon@sun.com # Date 1229367890 28800 # Node ID 728f90c86f2cd950463923c80fc57754d6e762eb # Parent 6a8e82d7d2e166880fed8d7ad860a3e2e93d62be Cast callbacks to the correct type
Avoid compiler warnings by performing the correct casts.
Actually, the declaration in src/driver.h is the thing that is broken. It should be declaring it param as 'virConnectDomainEventCallback cb' instead of 'void *cb, then we'd avoid the need for casts in libvirt.c, or the drivers. Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
participants (2)
-
Daniel P. Berrange
-
john.levon@sun.com