From 75849b75038cd788e644a10bfc248d9469b02016 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Thu, 6 Oct 2022 12:33:08 +0200 Subject: [PATCH] conf: domain: Refactor cleanup in virSysinfoParseXML MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use automatic pointer freeing to remove the 'error' label. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- src/conf/domain_conf.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 2537aa808f..25288cc5a3 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -12394,7 +12394,7 @@ virSysinfoParseXML(xmlNodePtr node, bool uuid_generated) { VIR_XPATH_NODE_AUTORESTORE(ctxt) - virSysinfoDef *def; + g_autoptr(virSysinfoDef) def = g_new0(virSysinfoDef, 1); ctxt->node = node; @@ -12404,32 +12404,26 @@ virSysinfoParseXML(xmlNodePtr node, return NULL; } - def = g_new0(virSysinfoDef, 1); - if (virXMLPropEnum(node, "type", virSysinfoTypeFromString, VIR_XML_PROP_REQUIRED, &def->type) < 0) - goto error; + return NULL; switch (def->type) { case VIR_SYSINFO_SMBIOS: if (virSysinfoParseSMBIOSDef(def, ctxt, domUUID, uuid_generated) < 0) - goto error; + return NULL; break; case VIR_SYSINFO_FWCFG: if (virSysinfoParseFWCfgDef(def, node, ctxt) < 0) - goto error; + return NULL; break; case VIR_SYSINFO_LAST: break; } - return def; - - error: - virSysinfoDefFree(def); - return NULL; + return g_steal_pointer(&def); } unsigned int