virNetworkDHCPDefParseXML: Refactor cleanup

There's nothing to clean up in the 'host' local variable on error as
the function which fills it makes sure to fill it only on success. In
such case it's also directly assigned to the array thus the 'host'
variable is cleared.

Remove the 'cleanup' label and 'ret' variable as we can now directly
return -1 on error.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2023-02-13 15:18:21 +01:00
parent 355582e3df
commit 4aafa900ce

View File

@ -605,7 +605,6 @@ virNetworkDHCPDefParseXML(const char *networkName,
xmlNodePtr node, xmlNodePtr node,
virNetworkIPDef *def) virNetworkIPDef *def)
{ {
int ret = -1;
xmlNodePtr cur; xmlNodePtr cur;
virNetworkDHCPRangeDef range; virNetworkDHCPRangeDef range;
virNetworkDHCPHostDef host; virNetworkDHCPHostDef host;
@ -619,7 +618,7 @@ virNetworkDHCPDefParseXML(const char *networkName,
virXMLNodeNameEqual(cur, "range")) { virXMLNodeNameEqual(cur, "range")) {
if (virNetworkDHCPRangeDefParseXML(networkName, def, cur, &range) < 0) if (virNetworkDHCPRangeDefParseXML(networkName, def, cur, &range) < 0)
goto cleanup; return -1;
VIR_APPEND_ELEMENT(def->ranges, def->nranges, range); VIR_APPEND_ELEMENT(def->ranges, def->nranges, range);
} else if (cur->type == XML_ELEMENT_NODE && } else if (cur->type == XML_ELEMENT_NODE &&
@ -627,7 +626,7 @@ virNetworkDHCPDefParseXML(const char *networkName,
if (virNetworkDHCPHostDefParseXML(networkName, def, cur, if (virNetworkDHCPHostDefParseXML(networkName, def, cur,
&host, false) < 0) &host, false) < 0)
goto cleanup; return -1;
VIR_APPEND_ELEMENT(def->hosts, def->nhosts, host); VIR_APPEND_ELEMENT(def->hosts, def->nhosts, host);
} else if (VIR_SOCKET_ADDR_IS_FAMILY(&def->address, AF_INET) && } else if (VIR_SOCKET_ADDR_IS_FAMILY(&def->address, AF_INET) &&
cur->type == XML_ELEMENT_NODE && cur->type == XML_ELEMENT_NODE &&
@ -645,7 +644,7 @@ virNetworkDHCPDefParseXML(const char *networkName,
if (server && if (server &&
virSocketAddrParse(&inaddr, server, AF_UNSPEC) < 0) { virSocketAddrParse(&inaddr, server, AF_UNSPEC) < 0) {
goto cleanup; return -1;
} }
def->bootfile = g_steal_pointer(&file); def->bootfile = g_steal_pointer(&file);
@ -655,10 +654,7 @@ virNetworkDHCPDefParseXML(const char *networkName,
cur = cur->next; cur = cur->next;
} }
ret = 0; return 0;
cleanup:
virNetworkDHCPHostDefClear(&host);
return ret;
} }