From: Peter Krempa Date: Thu, 15 Sep 2022 13:52:21 +0000 (+0200) Subject: conf: domain: Automatically free 'def' and 'actual' in virDomainNetDefParseXML X-Git-Tag: v8.9.0-rc1~183 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4721354f44d09d4b99a12294f88fde09f1d69ba6;p=thirdparty%2Flibvirt.git conf: domain: Automatically free 'def' and 'actual' in virDomainNetDefParseXML Convert the last two variables having inline cleanup to automatic cleanup. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- 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