[PATCH 5/5] refactoring: Use the return value of virObjectRef directly

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

 



Use the return value of virObjectRef directly. This way, it's easier
for another reader to identify the reason why the additional reference
is required.

Signed-off-by: Marc Hartmayer <mhartmay@xxxxxxxxxxxxxxxxxx>
Reviewed-by: Bjoern Walk <bwalk@xxxxxxxxxxxxxxxxxx>
---
 src/datatypes.c              | 6 ++----
 src/rpc/virnetclientstream.c | 4 +---
 src/rpc/virnetserver.c       | 9 +++------
 tests/qemumonitortestutils.c | 3 +--
 4 files changed, 7 insertions(+), 15 deletions(-)

diff --git a/src/datatypes.c b/src/datatypes.c
index 3e3148d..59ba956 100644
--- a/src/datatypes.c
+++ b/src/datatypes.c
@@ -196,8 +196,7 @@ void virConnectCloseCallbackDataRegister(virConnectCloseCallbackDataPtr closeDat
         return;
     }
 
-    closeData->conn = conn;
-    virObjectRef(closeData->conn);
+    closeData->conn = virObjectRef(conn);
     closeData->callback = cb;
     closeData->opaque = opaque;
     closeData->freeCallback = freecb;
@@ -985,8 +984,7 @@ virAdmConnectCloseCallbackDataRegister(virAdmConnectCloseCallbackDataPtr cbdata,
         goto cleanup;
     }
 
-    virObjectRef(conn);
-    cbdata->conn = conn;
+    cbdata->conn = virObjectRef(conn);
     cbdata->callback = cb;
     cbdata->opaque = opaque;
     cbdata->freeCallback = freecb;
diff --git a/src/rpc/virnetclientstream.c b/src/rpc/virnetclientstream.c
index 34989a9..2105bd0 100644
--- a/src/rpc/virnetclientstream.c
+++ b/src/rpc/virnetclientstream.c
@@ -145,12 +145,10 @@ virNetClientStreamPtr virNetClientStreamNew(virNetClientProgramPtr prog,
     if (!(st = virObjectLockableNew(virNetClientStreamClass)))
         return NULL;
 
-    st->prog = prog;
+    st->prog = virObjectRef(prog);
     st->proc = proc;
     st->serial = serial;
 
-    virObjectRef(prog);
-
     return st;
 }
 
diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c
index f06643a..c02db74 100644
--- a/src/rpc/virnetserver.c
+++ b/src/rpc/virnetserver.c
@@ -213,8 +213,7 @@ static int virNetServerDispatchNewMessage(virNetServerClientPtr client,
         job->msg = msg;
 
         if (prog) {
-            virObjectRef(prog);
-            job->prog = prog;
+            job->prog = virObjectRef(prog);
             priority = virNetServerProgramGetPriority(prog, msg->header.proc);
         }
 
@@ -284,8 +283,7 @@ int virNetServerAddClient(virNetServerPtr srv,
 
     if (VIR_EXPAND_N(srv->clients, srv->nclients, 1) < 0)
         goto error;
-    srv->clients[srv->nclients-1] = client;
-    virObjectRef(client);
+    srv->clients[srv->nclients-1] = virObjectRef(client);
 
     if (virNetServerClientNeedAuth(client))
         virNetServerTrackPendingAuthLocked(srv);
@@ -695,8 +693,7 @@ int virNetServerAddService(virNetServerPtr srv,
         }
     }
 
-    srv->services[srv->nservices-1] = svc;
-    virObjectRef(svc);
+    srv->services[srv->nservices-1] = virObjectRef(svc);
 
     virNetServerServiceSetDispatcher(svc,
                                      virNetServerDispatchNewClient,
diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c
index 89857a6..5e30fb0 100644
--- a/tests/qemumonitortestutils.c
+++ b/tests/qemumonitortestutils.c
@@ -1064,8 +1064,7 @@ qemuMonitorCommonTestNew(virDomainXMLOptionPtr xmlopt,
         goto error;
 
     if (vm) {
-        virObjectRef(vm);
-        test->vm = vm;
+        test->vm = virObjectRef(vm);
     } else {
         test->vm = virDomainObjNew(xmlopt);
         if (!test->vm)
-- 
2.5.5

--
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]
  Powered by Linux