From 4721354f44d09d4b99a12294f88fde09f1d69ba6 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Thu, 15 Sep 2022 15:52:21 +0200 Subject: [PATCH] conf: domain: Automatically free 'def' and 'actual' in virDomainNetDefParseXML MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Convert the last two variables having inline cleanup to automatic cleanup. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- 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