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(a)redhat.com>
---
src/conf/network_conf.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index 73011cb7a2..5add0ef902 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -605,7 +605,6 @@ virNetworkDHCPDefParseXML(const char *networkName,
xmlNodePtr node,
virNetworkIPDef *def)
{
- int ret = -1;
xmlNodePtr cur;
virNetworkDHCPRangeDef range;
virNetworkDHCPHostDef host;
@@ -619,7 +618,7 @@ virNetworkDHCPDefParseXML(const char *networkName,
virXMLNodeNameEqual(cur, "range")) {
if (virNetworkDHCPRangeDefParseXML(networkName, def, cur, &range) <
0)
- goto cleanup;
+ return -1;
VIR_APPEND_ELEMENT(def->ranges, def->nranges, range);
} else if (cur->type == XML_ELEMENT_NODE &&
@@ -627,7 +626,7 @@ virNetworkDHCPDefParseXML(const char *networkName,
if (virNetworkDHCPHostDefParseXML(networkName, def, cur,
&host, false) < 0)
- goto cleanup;
+ return -1;
VIR_APPEND_ELEMENT(def->hosts, def->nhosts, host);
} else if (VIR_SOCKET_ADDR_IS_FAMILY(&def->address, AF_INET) &&
cur->type == XML_ELEMENT_NODE &&
@@ -645,7 +644,7 @@ virNetworkDHCPDefParseXML(const char *networkName,
if (server &&
virSocketAddrParse(&inaddr, server, AF_UNSPEC) < 0) {
- goto cleanup;
+ return -1;
}
def->bootfile = g_steal_pointer(&file);
@@ -655,10 +654,7 @@ virNetworkDHCPDefParseXML(const char *networkName,
cur = cur->next;
}
- ret = 0;
- cleanup:
- virNetworkDHCPHostDefClear(&host);
- return ret;
+ return 0;
}
--
2.40.1