[PATCH v3 07/10] conf: Use VIR_AUTOUNREF in domain_conf

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

 



Let's make use of the auto __cleanup capabilities for virObjectUnref
consumers.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/conf/domain_conf.c | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index da2175713d..c04517dbd0 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1587,8 +1587,8 @@ void virDomainLeaseDefFree(virDomainLeaseDefPtr def)
 static virDomainVcpuDefPtr
 virDomainVcpuDefNew(virDomainXMLOptionPtr xmlopt)
 {
-    virObjectPtr priv = NULL;
     virDomainVcpuDefPtr ret = NULL;
+    VIR_AUTOUNREF(virObjectPtr) priv = NULL;
 
     if (xmlopt && xmlopt->privateData.vcpuNew &&
         !(priv = xmlopt->privateData.vcpuNew()))
@@ -1600,7 +1600,6 @@ virDomainVcpuDefNew(virDomainXMLOptionPtr xmlopt)
     VIR_STEAL_PTR(ret->privateData, priv);
 
  cleanup:
-    virObjectUnref(priv);
     return ret;
 }
 
@@ -19142,13 +19141,13 @@ virDomainCachetuneDefParse(virDomainDefPtr def,
                            unsigned int flags)
 {
     xmlNodePtr oldnode = ctxt->node;
-    virResctrlAllocPtr alloc = NULL;
     virDomainResctrlDefPtr resctrl = NULL;
     ssize_t i = 0;
     int n;
     int ret = -1;
     VIR_AUTOPTR(virBitmap) vcpus = NULL;
     VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
+    VIR_AUTOUNREF(virResctrlAllocPtr) alloc = NULL;
 
     ctxt->node = node;
 
@@ -19207,7 +19206,6 @@ virDomainCachetuneDefParse(virDomainDefPtr def,
  cleanup:
     ctxt->node = oldnode;
     virDomainResctrlDefFree(resctrl);
-    virObjectUnref(alloc);
     return ret;
 }
 
@@ -19353,10 +19351,10 @@ virDomainMemorytuneDefParse(virDomainDefPtr def,
                             unsigned int flags)
 {
     xmlNodePtr oldnode = ctxt->node;
-    virResctrlAllocPtr alloc = NULL;
     virDomainResctrlDefPtr resctrl = NULL;
     VIR_AUTOPTR(virBitmap) vcpus = NULL;
     VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
+    VIR_AUTOUNREF(virResctrlAllocPtr) alloc = NULL;
 
     ssize_t i = 0;
     int n;
@@ -19414,7 +19412,6 @@ virDomainMemorytuneDefParse(virDomainDefPtr def,
  cleanup:
     ctxt->node = oldnode;
     virDomainResctrlDefFree(resctrl);
-    virObjectUnref(alloc);
     return ret;
 }
 
@@ -30460,11 +30457,11 @@ virDomainNetBandwidthUpdate(virDomainNetDefPtr iface,
 int
 virDomainNetResolveActualType(virDomainNetDefPtr iface)
 {
-    virConnectPtr conn = NULL;
-    virNetworkPtr net = NULL;
     virNetworkDefPtr def = NULL;
     int ret = -1;
     VIR_AUTOFREE(char *) xml = NULL;
+    VIR_AUTOUNREF(virConnectPtr) conn = NULL;
+    VIR_AUTOUNREF(virNetworkPtr) net = NULL;
 
     if (iface->type != VIR_DOMAIN_NET_TYPE_NETWORK)
         return iface->type;
@@ -30531,8 +30528,6 @@ virDomainNetResolveActualType(virDomainNetDefPtr iface)
 
  cleanup:
     virNetworkDefFree(def);
-    virObjectUnref(conn);
-    virObjectUnref(net);
     return ret;
 }
 
@@ -30656,13 +30651,13 @@ virDomainDiskTranslateISCSIDirect(virDomainDiskDefPtr def,
 int
 virDomainDiskTranslateSourcePool(virDomainDiskDefPtr def)
 {
-    virConnectPtr conn = NULL;
-    virStoragePoolPtr pool = NULL;
-    virStorageVolPtr vol = NULL;
     virStorageVolInfo info;
     int ret = -1;
     VIR_AUTOPTR(virStoragePoolDef) pooldef = NULL;
     VIR_AUTOFREE(char *) poolxml = NULL;
+    VIR_AUTOUNREF(virConnectPtr) conn = NULL;
+    VIR_AUTOUNREF(virStoragePoolPtr) pool = NULL;
+    VIR_AUTOUNREF(virStorageVolPtr) vol = NULL;
 
     if (def->src->type != VIR_STORAGE_TYPE_VOLUME)
         return 0;
@@ -30817,9 +30812,6 @@ virDomainDiskTranslateSourcePool(virDomainDiskDefPtr def)
 
     ret = 0;
  cleanup:
-    virObjectUnref(conn);
-    virObjectUnref(pool);
-    virObjectUnref(vol);
     return ret;
 }
 
-- 
2.20.1

--
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