[PATCH 02/37] conf: domain: Automatically free 'def' and 'actual' in virDomainNetDefParseXML

Peter Krempa pkrempa at redhat.com
Mon Sep 19 08:54:47 UTC 2022


Convert the last two variables having inline cleanup to automatic
cleanup.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/conf/domain_conf.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 406c348a00..7f5efa205c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -8833,7 +8833,7 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt,
                         xmlXPathContextPtr ctxt,
                         unsigned int flags)
 {
-    virDomainNetDef *def;
+    g_autoptr(virDomainNetDef) def = NULL;
     virDomainHostdevDef *hostdev;
     xmlNodePtr source_node = NULL;
     xmlNodePtr virtualport_node = NULL;
@@ -8845,7 +8845,7 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt,
     xmlNodePtr tmpNode;
     xmlNodePtr mac_node = NULL;
     g_autoptr(GHashTable) filterparams = NULL;
-    virDomainActualNetDef *actual = NULL;
+    g_autoptr(virDomainActualNetDef) actual = NULL;
     VIR_XPATH_NODE_AUTORESTORE(ctxt)
     virDomainChrSourceReconnectDef reconnect = {0};
     int rv, val;
@@ -9571,13 +9571,10 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt,
     if (virNetworkPortOptionsParseXML(ctxt, &def->isolatedPort) < 0)
         goto error;

- cleanup:
-    virDomainActualNetDefFree(actual);
-    return def;
+    return g_steal_pointer(&def);

  error:
-    g_clear_pointer(&def, virDomainNetDefFree);
-    goto cleanup;
+    return NULL;
 }

 static int
-- 
2.37.1



More information about the libvir-list mailing list