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 <mhart...@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiu...@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bw...@linux.vnet.ibm.com>
---
 src/qemu/qemu_process.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 5a364730c8c1..c17a6e9abfc6 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -299,9 +299,8 @@ qemuProcessHandleMonitorEOF(qemuMonitorPtr mon,
         goto cleanup;
 
     processEvent->eventType = QEMU_PROCESS_EVENT_MONITOR_EOF;
-    processEvent->vm = vm;
+    processEvent->vm = virObjectRef(vm);
 
-    virObjectRef(vm);
     if (virThreadPoolSendJob(driver->workerPool, 0, processEvent) < 0) {
         ignore_value(virObjectUnref(vm));
         VIR_FREE(processEvent);
@@ -911,11 +910,10 @@ qemuProcessHandleWatchdog(qemuMonitorPtr mon 
ATTRIBUTE_UNUSED,
         if (VIR_ALLOC(processEvent) == 0) {
             processEvent->eventType = QEMU_PROCESS_EVENT_WATCHDOG;
             processEvent->action = VIR_DOMAIN_WATCHDOG_ACTION_DUMP;
-            processEvent->vm = vm;
             /* Hold an extra reference because we can't allow 'vm' to be
              * deleted before handling watchdog event is finished.
              */
-            virObjectRef(vm);
+            processEvent->vm = virObjectRef(vm);
             if (virThreadPoolSendJob(driver->workerPool, 0, processEvent) < 0) 
{
                 if (!virObjectUnref(vm))
                     vm = NULL;
@@ -1349,12 +1347,12 @@ qemuProcessHandleGuestPanic(qemuMonitorPtr mon 
ATTRIBUTE_UNUSED,
 
     processEvent->eventType = QEMU_PROCESS_EVENT_GUESTPANIC;
     processEvent->action = vm->def->onCrash;
-    processEvent->vm = vm;
     processEvent->data = info;
     /* Hold an extra reference because we can't allow 'vm' to be
      * deleted before handling guest panic event is finished.
      */
-    virObjectRef(vm);
+    processEvent->vm = virObjectRef(vm);
+
     if (virThreadPoolSendJob(driver->workerPool, 0, processEvent) < 0) {
         if (!virObjectUnref(vm))
             vm = NULL;
@@ -1395,9 +1393,8 @@ qemuProcessHandleDeviceDeleted(qemuMonitorPtr mon 
ATTRIBUTE_UNUSED,
     if (VIR_STRDUP(data, devAlias) < 0)
         goto error;
     processEvent->data = data;
-    processEvent->vm = vm;
+    processEvent->vm = virObjectRef(vm);
 
-    virObjectRef(vm);
     if (virThreadPoolSendJob(driver->workerPool, 0, processEvent) < 0) {
         ignore_value(virObjectUnref(vm));
         goto error;
@@ -1544,9 +1541,8 @@ qemuProcessHandleNicRxFilterChanged(qemuMonitorPtr mon 
ATTRIBUTE_UNUSED,
     if (VIR_STRDUP(data, devAlias) < 0)
         goto error;
     processEvent->data = data;
-    processEvent->vm = vm;
+    processEvent->vm = virObjectRef(vm);
 
-    virObjectRef(vm);
     if (virThreadPoolSendJob(driver->workerPool, 0, processEvent) < 0) {
         ignore_value(virObjectUnref(vm));
         goto error;
@@ -1587,9 +1583,8 @@ qemuProcessHandleSerialChanged(qemuMonitorPtr mon 
ATTRIBUTE_UNUSED,
         goto error;
     processEvent->data = data;
     processEvent->action = connected;
-    processEvent->vm = vm;
+    processEvent->vm = virObjectRef(vm);
 
-    virObjectRef(vm);
     if (virThreadPoolSendJob(driver->workerPool, 0, processEvent) < 0) {
         ignore_value(virObjectUnref(vm));
         goto error;
-- 
2.13.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to