From 36dd0bd88af9388107bf2ab4f5f9af24a91dc66a Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Sat, 4 Jan 2014 15:12:34 -0700 Subject: [PATCH] event: make network events easier to use without casts While comparing network and domain events, I noticed that the test driver had to do a cast in one place and not the other. For consistency, we should hide the necessary casting as low as possible in the stack, with everything else using saner types. * src/conf/network_event.h (virNetworkEventStateRegisterID): Alter type. * src/conf/network_event.c (virNetworkEventStateRegisterID): Hoist cast here. * src/test/test_driver.c (testConnectNetworkEventRegisterAny): Simplify callers. * src/remote/remote_driver.c (remoteConnectNetworkEventRegisterAny): Likewise. * src/network/bridge_driver.c (networkConnectNetworkEventRegisterAny): Likewise. Signed-off-by: Eric Blake --- src/conf/network_event.c | 5 +++-- src/conf/network_event.h | 3 ++- src/network/bridge_driver.c | 3 +-- src/remote/remote_driver.c | 3 +-- src/test/test_driver.c | 3 +-- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/conf/network_event.c b/src/conf/network_event.c index 38c74d1ab7..3cd884d2f8 100644 --- a/src/conf/network_event.c +++ b/src/conf/network_event.c @@ -143,7 +143,7 @@ virNetworkEventStateRegisterID(virConnectPtr conn, virObjectEventStatePtr state, virNetworkPtr net, int eventID, - virConnectObjectEventGenericCallback cb, + virConnectNetworkEventGenericCallback cb, void *opaque, virFreeCallback freecb, int *callbackID) @@ -153,7 +153,8 @@ virNetworkEventStateRegisterID(virConnectPtr conn, return virObjectEventStateRegisterID(conn, state, net ? net->uuid : NULL, virNetworkEventClass, eventID, - cb, opaque, freecb, callbackID); + VIR_OBJECT_EVENT_CALLBACK(cb), + opaque, freecb, callbackID); } diff --git a/src/conf/network_event.h b/src/conf/network_event.h index a1afbc5e0d..843faf9b72 100644 --- a/src/conf/network_event.h +++ b/src/conf/network_event.h @@ -1,6 +1,7 @@ /* * network_event.h: network event queue processing helpers * + * Copyright (C) 2014 Red Hat, Inc. * Copyright (C) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany. * * This library is free software; you can redistribute it and/or @@ -32,7 +33,7 @@ virNetworkEventStateRegisterID(virConnectPtr conn, virObjectEventStatePtr state, virNetworkPtr net, int eventID, - virConnectObjectEventGenericCallback cb, + virConnectNetworkEventGenericCallback cb, void *opaque, virFreeCallback freecb, int *callbackID); diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 9dc1f7e22f..95e4b658d7 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -2310,8 +2310,7 @@ networkConnectNetworkEventRegisterAny(virConnectPtr conn, goto cleanup; if (virNetworkEventStateRegisterID(conn, driver->networkEventState, - net, eventID, - VIR_OBJECT_EVENT_CALLBACK(callback), + net, eventID, callback, opaque, freecb, &ret) < 0) ret = -1; diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 7e48c59efe..fecb9b2e6a 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -2928,8 +2928,7 @@ remoteConnectNetworkEventRegisterAny(virConnectPtr conn, remoteDriverLock(priv); if ((count = virNetworkEventStateRegisterID(conn, priv->eventState, - net, eventID, - VIR_OBJECT_EVENT_CALLBACK(callback), + net, eventID, callback, opaque, freecb, &callbackID)) < 0) goto done; diff --git a/src/test/test_driver.c b/src/test/test_driver.c index da76666a82..cde82a1990 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -6113,8 +6113,7 @@ testConnectNetworkEventRegisterAny(virConnectPtr conn, testDriverLock(driver); if (virNetworkEventStateRegisterID(conn, driver->eventState, - net, eventID, - VIR_OBJECT_EVENT_CALLBACK(callback), + net, eventID, callback, opaque, freecb, &ret) < 0) ret = -1; testDriverUnlock(driver); -- GitLab