The virNetServer class is passing a pointer to itself to the
virNetServerClient as a 'void *' pointer. This is presumably due to fact
that the virnetserverclient.h file doesn't see the virNetServerPtr
typedef. The typedef is easily movable though, which lets us get
typesafe parameter passing, removing the confusion of passing two
distinct 'void *' pointers to one method.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/rpc/virnetserver.c | 6 +++---
src/rpc/virnetserverclient.c | 14 +++++++-------
src/rpc/virnetserverclient.h | 9 ++++++---
src/rpc/virnetserverprogram.h | 3 ---
4 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c
index 77a4c0b8dc..5e50b58be8 100644
--- a/src/rpc/virnetserver.c
+++ b/src/rpc/virnetserver.c
@@ -540,12 +540,12 @@ virNetServerPtr virNetServerNewPostExecRestart(virJSONValuePtr
object,
goto error;
}
- if (!(client = virNetServerClientNewPostExecRestart(child,
+ if (!(client = virNetServerClientNewPostExecRestart(srv,
+ child,
clientPrivNewPostExecRestart,
clientPrivPreExecRestart,
clientPrivFree,
- clientPrivOpaque,
- srv)))
+ clientPrivOpaque)))
goto error;
if (virNetServerAddClient(srv, client) < 0) {
diff --git a/src/rpc/virnetserverclient.c b/src/rpc/virnetserverclient.c
index 1f335d3b1e..d81a3892ff 100644
--- a/src/rpc/virnetserverclient.c
+++ b/src/rpc/virnetserverclient.c
@@ -479,12 +479,12 @@ virNetServerClientPtr virNetServerClientNew(unsigned long long id,
}
-virNetServerClientPtr virNetServerClientNewPostExecRestart(virJSONValuePtr object,
+virNetServerClientPtr virNetServerClientNewPostExecRestart(virNetServerPtr srv,
+ virJSONValuePtr object,
virNetServerClientPrivNewPostExecRestart privNew,
virNetServerClientPrivPreExecRestart privPreExecRestart,
virFreeCallback privFree,
- void *privOpaque,
- void *opaque)
+ void *privOpaque)
{
virJSONValuePtr child;
virNetServerClientPtr client = NULL;
@@ -540,12 +540,12 @@ virNetServerClientPtr
virNetServerClientNewPostExecRestart(virJSONValuePtr objec
if (!virJSONValueObjectHasKey(object, "id")) {
/* no ID found in, a new one must be generated */
- id = virNetServerNextClientID((virNetServerPtr) opaque);
+ id = virNetServerNextClientID(srv);
} else {
if (virJSONValueObjectGetNumberUlong(object, "id", &id) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Malformed id field in JSON state document"));
- return NULL;
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Malformed id field in JSON state document"));
+ return NULL;
}
}
diff --git a/src/rpc/virnetserverclient.h b/src/rpc/virnetserverclient.h
index 14ace9e522..3c48759abc 100644
--- a/src/rpc/virnetserverclient.h
+++ b/src/rpc/virnetserverclient.h
@@ -30,6 +30,9 @@
# include "virobject.h"
# include "virjson.h"
+typedef struct _virNetServer virNetServer;
+typedef virNetServer *virNetServerPtr;
+
typedef struct _virNetServerClient virNetServerClient;
typedef virNetServerClient *virNetServerClientPtr;
@@ -71,12 +74,12 @@ virNetServerClientPtr virNetServerClientNew(unsigned long long id,
virFreeCallback privFree,
void *privOpaque);
-virNetServerClientPtr virNetServerClientNewPostExecRestart(virJSONValuePtr object,
+virNetServerClientPtr virNetServerClientNewPostExecRestart(virNetServerPtr srv,
+ virJSONValuePtr object,
virNetServerClientPrivNewPostExecRestart privNew,
virNetServerClientPrivPreExecRestart privPreExecRestart,
virFreeCallback privFree,
- void *privOpaque,
- void *opaque);
+ void *privOpaque);
virJSONValuePtr virNetServerClientPreExecRestart(virNetServerClientPtr client);
diff --git a/src/rpc/virnetserverprogram.h b/src/rpc/virnetserverprogram.h
index 1731c9e1d1..c2a5635c95 100644
--- a/src/rpc/virnetserverprogram.h
+++ b/src/rpc/virnetserverprogram.h
@@ -31,9 +31,6 @@
typedef struct _virNetDaemon virNetDaemon;
typedef virNetDaemon *virNetDaemonPtr;
-typedef struct _virNetServer virNetServer;
-typedef virNetServer *virNetServerPtr;
-
typedef struct _virNetServerService virNetServerService;
typedef virNetServerService *virNetServerServicePtr;
--
2.14.3