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

[libvirt] [PATCH 12/2] 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 <eblake redhat com>
---
 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 38c74d1..3cd884d 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 a1afbc5..843faf9 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 9dc1f7e..95e4b65 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 f311544..74da726 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 da76666..cde82a1 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);
-- 
1.8.4.2


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