[libvirt PATCH 2/8] Use g_auto for freeing virCaps

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

 



Convert all the users who unref their virCaps object unconditionally.

Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx>
---
 src/bhyve/bhyve_driver.c |  9 +++------
 src/ch/ch_driver.c       |  3 +--
 src/lxc/lxc_driver.c     | 21 +++++++--------------
 src/lxc/lxc_process.c    |  3 +--
 4 files changed, 12 insertions(+), 24 deletions(-)

diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index 250e10b9d0..e445c8cadf 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -140,7 +140,7 @@ static char *
 bhyveConnectGetCapabilities(virConnectPtr conn)
 {
     struct _bhyveConn *privconn = conn->privateData;
-    virCaps *caps;
+    g_autoptr(virCaps) caps = NULL;
     char *xml = NULL;
 
     if (virConnectGetCapabilitiesEnsureACL(conn) < 0)
@@ -156,7 +156,6 @@ bhyveConnectGetCapabilities(virConnectPtr conn)
         goto cleanup;
 
  cleanup:
-    virObjectUnref(caps);
     return xml;
 }
 
@@ -508,7 +507,7 @@ bhyveDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flag
     g_autoptr(virDomainDef) oldDef = NULL;
     virDomainObj *vm = NULL;
     virObjectEvent *event = NULL;
-    virCaps *caps = NULL;
+    g_autoptr(virCaps) caps = NULL;
     unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE;
 
     virCheckFlags(VIR_DOMAIN_DEFINE_VALIDATE, NULL);
@@ -554,7 +553,6 @@ bhyveDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flag
     dom = virGetDomain(conn, vm->def->name, vm->def->uuid, vm->def->id);
 
  cleanup:
-    virObjectUnref(caps);
     virDomainObjEndAPI(&vm);
     virObjectEventStateQueue(privconn->domainEventState, event);
 
@@ -1434,7 +1432,7 @@ bhyveConnectCompareCPU(virConnectPtr conn,
 {
     struct _bhyveConn *driver = conn->privateData;
     int ret = VIR_CPU_COMPARE_ERROR;
-    virCaps *caps = NULL;
+    g_autoptr(virCaps) caps = NULL;
     bool failIncompatible;
     bool validateXML;
 
@@ -1466,7 +1464,6 @@ bhyveConnectCompareCPU(virConnectPtr conn,
     }
 
  cleanup:
-    virObjectUnref(caps);
     return ret;
 }
 
diff --git a/src/ch/ch_driver.c b/src/ch/ch_driver.c
index 108644e503..06cfb1c5ef 100644
--- a/src/ch/ch_driver.c
+++ b/src/ch/ch_driver.c
@@ -187,7 +187,7 @@ static int chNodeGetInfo(virConnectPtr conn,
 static char *chConnectGetCapabilities(virConnectPtr conn)
 {
     virCHDriver *driver = conn->privateData;
-    virCaps *caps;
+    g_autoptr(virCaps) caps = NULL;
     char *xml;
 
     if (virConnectGetCapabilitiesEnsureACL(conn) < 0)
@@ -198,7 +198,6 @@ static char *chConnectGetCapabilities(virConnectPtr conn)
 
     xml = virCapabilitiesFormatXML(caps);
 
-    virObjectUnref(caps);
     return xml;
 }
 
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index d86147cc28..92ae22ef2b 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -197,7 +197,7 @@ static int lxcConnectIsAlive(virConnectPtr conn G_GNUC_UNUSED)
 
 static char *lxcConnectGetCapabilities(virConnectPtr conn) {
     virLXCDriver *driver = conn->privateData;
-    virCaps *caps;
+    g_autoptr(virCaps) caps = NULL;
     char *xml;
 
     if (virConnectGetCapabilitiesEnsureACL(conn) < 0)
@@ -208,7 +208,6 @@ static char *lxcConnectGetCapabilities(virConnectPtr conn) {
 
     xml = virCapabilitiesFormatXML(caps);
 
-    virObjectUnref(caps);
     return xml;
 }
 
@@ -405,7 +404,7 @@ lxcDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags)
     virObjectEvent *event = NULL;
     g_autoptr(virDomainDef) oldDef = NULL;
     virLXCDriverConfig *cfg = virLXCDriverGetConfig(driver);
-    virCaps *caps = NULL;
+    g_autoptr(virCaps) caps = NULL;
     unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE;
 
     virCheckFlags(VIR_DOMAIN_DEFINE_VALIDATE, NULL);
@@ -459,7 +458,6 @@ lxcDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags)
  cleanup:
     virDomainObjEndAPI(&vm);
     virObjectEventStateQueue(driver->domainEventState, event);
-    virObjectUnref(caps);
     virObjectUnref(cfg);
     return dom;
 }
@@ -937,7 +935,7 @@ static char *lxcConnectDomainXMLFromNative(virConnectPtr conn,
     char *xml = NULL;
     g_autoptr(virDomainDef) def = NULL;
     virLXCDriver *driver = conn->privateData;
-    virCaps *caps = virLXCDriverGetCapabilities(driver, false);
+    g_autoptr(virCaps) caps = virLXCDriverGetCapabilities(driver, false);
 
     virCheckFlags(0, NULL);
 
@@ -956,7 +954,6 @@ static char *lxcConnectDomainXMLFromNative(virConnectPtr conn,
     xml = virDomainDefFormat(def, driver->xmlopt, 0);
 
  cleanup:
-    virObjectUnref(caps);
     return xml;
 }
 
@@ -1082,7 +1079,7 @@ lxcDomainCreateXMLWithFiles(virConnectPtr conn,
     virDomainPtr dom = NULL;
     virObjectEvent *event = NULL;
     virLXCDriverConfig *cfg = virLXCDriverGetConfig(driver);
-    virCaps *caps = NULL;
+    g_autoptr(virCaps) caps = NULL;
     unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE;
 
     virCheckFlags(VIR_DOMAIN_START_AUTODESTROY |
@@ -1150,7 +1147,6 @@ lxcDomainCreateXMLWithFiles(virConnectPtr conn,
  cleanup:
     virDomainObjEndAPI(&vm);
     virObjectEventStateQueue(driver->domainEventState, event);
-    virObjectUnref(caps);
     virObjectUnref(cfg);
     virNWFilterUnlockFilterUpdates();
     return dom;
@@ -1229,7 +1225,7 @@ static int lxcNodeGetSecurityModel(virConnectPtr conn,
                                    virSecurityModelPtr secmodel)
 {
     virLXCDriver *driver = conn->privateData;
-    virCaps *caps = NULL;
+    g_autoptr(virCaps) caps = NULL;
     int ret = 0;
 
     memset(secmodel, 0, sizeof(*secmodel));
@@ -1268,7 +1264,6 @@ static int lxcNodeGetSecurityModel(virConnectPtr conn,
     }
 
  cleanup:
-    virObjectUnref(caps);
     return ret;
 }
 
@@ -1807,7 +1802,7 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom,
                                      unsigned int flags)
 {
     virLXCDriver *driver = dom->conn->privateData;
-    virCaps *caps = NULL;
+    g_autoptr(virCaps) caps = NULL;
     size_t i;
     virDomainObj *vm = NULL;
     virDomainDef *def = NULL;
@@ -1925,7 +1920,6 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom,
 
  cleanup:
     virDomainObjEndAPI(&vm);
-    virObjectUnref(caps);
     virObjectUnref(cfg);
     return ret;
 }
@@ -4456,7 +4450,7 @@ static int lxcDomainDetachDeviceFlags(virDomainPtr dom,
                                       unsigned int flags)
 {
     virLXCDriver *driver = dom->conn->privateData;
-    virCaps *caps = NULL;
+    g_autoptr(virCaps) caps = NULL;
     virDomainObj *vm = NULL;
     g_autoptr(virDomainDef) vmdef = NULL;
     virDomainDeviceDef *dev = NULL;
@@ -4540,7 +4534,6 @@ static int lxcDomainDetachDeviceFlags(virDomainPtr dom,
         virDomainDeviceDefFree(dev_copy);
     virDomainDeviceDefFree(dev);
     virDomainObjEndAPI(&vm);
-    virObjectUnref(caps);
     virObjectUnref(cfg);
     return ret;
 }
diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
index d262128a50..501f418557 100644
--- a/src/lxc/lxc_process.c
+++ b/src/lxc/lxc_process.c
@@ -1207,7 +1207,7 @@ int virLXCProcessStart(virConnectPtr conn,
     int nsInheritFDs[VIR_LXC_DOMAIN_NAMESPACE_LAST];
     virCommand *cmd = NULL;
     virLXCDomainObjPrivate *priv = vm->privateData;
-    virCaps *caps = NULL;
+    g_autoptr(virCaps) caps = NULL;
     virErrorPtr err = NULL;
     virLXCDriverConfig *cfg = virLXCDriverGetConfig(driver);
     g_autoptr(virCgroup) selfcgroup = NULL;
@@ -1579,7 +1579,6 @@ int virLXCProcessStart(virConnectPtr conn,
     for (i = 0; i < G_N_ELEMENTS(handshakefds); i++)
         VIR_FORCE_CLOSE(handshakefds[i]);
     virObjectUnref(cfg);
-    virObjectUnref(caps);
 
     virErrorRestore(&err);
 
-- 
2.31.1




[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