This makes some function names and arg lists for consistent with other
parse functions in network_conf.c. While modifying
virNetworkIPParseXML(), also change its "error" label to "cleanup",
since the code at that label is executed on success as well as
failure.
---
src/conf/network_conf.c | 86 ++++++++++++++++++++++++-------------------------
1 file changed, 43 insertions(+), 43 deletions(-)
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index 0edf0ee..0842b71 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -592,9 +592,9 @@ int virNetworkIpDefNetmask(const virNetworkIpDefPtr def,
static int
-virNetworkDHCPRangeDefParse(const char *networkName,
- xmlNodePtr node,
- virNetworkDHCPRangeDefPtr range)
+virNetworkDHCPRangeDefParseXML(const char *networkName,
+ xmlNodePtr node,
+ virNetworkDHCPRangeDefPtr range)
{
@@ -636,10 +636,10 @@ cleanup:
}
static int
-virNetworkDHCPHostDefParse(const char *networkName,
- xmlNodePtr node,
- virNetworkDHCPHostDefPtr host,
- bool partialOkay)
+virNetworkDHCPHostDefParseXML(const char *networkName,
+ xmlNodePtr node,
+ virNetworkDHCPHostDefPtr host,
+ bool partialOkay)
{
char *mac = NULL, *name = NULL, *ip = NULL;
virMacAddr addr;
@@ -723,9 +723,9 @@ cleanup:
}
static int
-virNetworkDHCPDefParse(const char *networkName,
- virNetworkIpDefPtr def,
- xmlNodePtr node)
+virNetworkDHCPDefParseXML(const char *networkName,
+ xmlNodePtr node,
+ virNetworkIpDefPtr def)
{
xmlNodePtr cur;
@@ -739,8 +739,8 @@ virNetworkDHCPDefParse(const char *networkName,
virReportOOMError();
return -1;
}
- if (virNetworkDHCPRangeDefParse(networkName, cur,
- &def->ranges[def->nranges]) < 0)
{
+ if (virNetworkDHCPRangeDefParseXML(networkName, cur,
+ &def->ranges[def->nranges]) <
0) {
return -1;
}
def->nranges++;
@@ -752,9 +752,9 @@ virNetworkDHCPDefParse(const char *networkName,
virReportOOMError();
return -1;
}
- if (virNetworkDHCPHostDefParse(networkName, cur,
- &def->hosts[def->nhosts],
- false) < 0) {
+ if (virNetworkDHCPHostDefParseXML(networkName, cur,
+ &def->hosts[def->nhosts],
+ false) < 0) {
return -1;
}
def->nhosts++;
@@ -1068,10 +1068,10 @@ cleanup:
}
static int
-virNetworkIPParseXML(const char *networkName,
- virNetworkIpDefPtr def,
- xmlNodePtr node,
- xmlXPathContextPtr ctxt)
+virNetworkIPDefParseXML(const char *networkName,
+ xmlNodePtr node,
+ xmlXPathContextPtr ctxt,
+ virNetworkIpDefPtr def)
{
/*
* virNetworkIpDef object is already allocated as part of an array.
@@ -1101,7 +1101,7 @@ virNetworkIPParseXML(const char *networkName,
virReportError(VIR_ERR_XML_ERROR,
_("Bad address '%s' in definition of network
'%s'"),
address, networkName);
- goto error;
+ goto cleanup;
}
}
@@ -1113,27 +1113,27 @@ virNetworkIPParseXML(const char *networkName,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("no family specified for non-IPv4 address '%s'
in network '%s'"),
address, networkName);
- goto error;
+ goto cleanup;
}
} else if (STREQ(def->family, "ipv4")) {
if (!VIR_SOCKET_ADDR_IS_FAMILY(&def->address, AF_INET)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("family 'ipv4' specified for non-IPv4 address
'%s' in network '%s'"),
address, networkName);
- goto error;
+ goto cleanup;
}
} else if (STREQ(def->family, "ipv6")) {
if (!VIR_SOCKET_ADDR_IS_FAMILY(&def->address, AF_INET6)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("family 'ipv6' specified for non-IPv6 address
'%s' in network '%s'"),
address, networkName);
- goto error;
+ goto cleanup;
}
} else {
virReportError(VIR_ERR_XML_ERROR,
_("Unrecognized family '%s' in definition of network
'%s'"),
def->family, networkName);
- goto error;
+ goto cleanup;
}
/* parse/validate netmask */
@@ -1143,14 +1143,14 @@ virNetworkIPParseXML(const char *networkName,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("netmask specified without address in network
'%s'"),
networkName);
- goto error;
+ goto cleanup;
}
if (!VIR_SOCKET_ADDR_IS_FAMILY(&def->address, AF_INET)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("netmask not supported for address '%s' in
network '%s' (IPv4 only)"),
address, networkName);
- goto error;
+ goto cleanup;
}
if (def->prefix > 0) {
@@ -1158,17 +1158,17 @@ virNetworkIPParseXML(const char *networkName,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("network '%s' cannot have both
prefix='%u' and a netmask"),
networkName, def->prefix);
- goto error;
+ goto cleanup;
}
if (virSocketAddrParse(&def->netmask, netmask, AF_UNSPEC) < 0)
- goto error;
+ goto cleanup;
if (!VIR_SOCKET_ADDR_IS_FAMILY(&def->netmask, AF_INET)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("network '%s' has invalid netmask '%s'
for address '%s' (both must be IPv4)"),
networkName, netmask, address);
- goto error;
+ goto cleanup;
}
}
@@ -1178,9 +1178,9 @@ virNetworkIPParseXML(const char *networkName,
while (cur != NULL) {
if (cur->type == XML_ELEMENT_NODE &&
xmlStrEqual(cur->name, BAD_CAST "dhcp")) {
- result = virNetworkDHCPDefParse(networkName, def, cur);
+ result = virNetworkDHCPDefParseXML(networkName, cur, def);
if (result)
- goto error;
+ goto cleanup;
} else if (cur->type == XML_ELEMENT_NODE &&
xmlStrEqual(cur->name, BAD_CAST "tftp")) {
@@ -1200,7 +1200,7 @@ virNetworkIPParseXML(const char *networkName,
result = 0;
-error:
+cleanup:
if (result < 0) {
virNetworkIpDefClear(def);
}
@@ -1237,7 +1237,7 @@ virNetworkPortGroupParseXML(virPortGroupDefPtr def,
if (!def->name) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("Missing required name attribute in portgroup"));
- goto error;
+ goto cleanup;
}
isDefault = virXPathString("string(./@default)", ctxt);
@@ -1246,21 +1246,21 @@ virNetworkPortGroupParseXML(virPortGroupDefPtr def,
virtPortNode = virXPathNode("./virtualport", ctxt);
if (virtPortNode &&
(!(def->virtPortProfile = virNetDevVPortProfileParse(virtPortNode, 0)))) {
- goto error;
+ goto cleanup;
}
bandwidth_node = virXPathNode("./bandwidth", ctxt);
if (bandwidth_node &&
!(def->bandwidth = virNetDevBandwidthParse(bandwidth_node))) {
- goto error;
+ goto cleanup;
}
vlanNode = virXPathNode("./vlan", ctxt);
if (vlanNode && virNetDevVlanParse(vlanNode, ctxt, &def->vlan) <
0)
- goto error;
+ goto cleanup;
result = 0;
-error:
+cleanup:
if (result < 0) {
virPortGroupDefClear(def);
}
@@ -1428,8 +1428,8 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
}
/* parse each addr */
for (ii = 0; ii < nIps; ii++) {
- int ret = virNetworkIPParseXML(def->name, &def->ips[ii],
- ipNodes[ii], ctxt);
+ int ret = virNetworkIPDefParseXML(def->name, ipNodes[ii],
+ ctxt, &def->ips[ii]);
if (ret < 0)
goto error;
def->nips++;
@@ -2498,7 +2498,7 @@ virNetworkDefUpdateIPDHCPHost(virNetworkDefPtr def,
/* parse the xml into a virNetworkDHCPHostDef */
if (command == VIR_NETWORK_UPDATE_COMMAND_MODIFY) {
- if (virNetworkDHCPHostDefParse(def->name, ctxt->node, &host, false)
< 0)
+ if (virNetworkDHCPHostDefParseXML(def->name, ctxt->node, &host, false)
< 0)
goto cleanup;
/* search for the entry with this (mac|name),
@@ -2531,7 +2531,7 @@ virNetworkDefUpdateIPDHCPHost(virNetworkDefPtr def,
} else if ((command == VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST) ||
(command == VIR_NETWORK_UPDATE_COMMAND_ADD_LAST)) {
- if (virNetworkDHCPHostDefParse(def->name, ctxt->node, &host, true) <
0)
+ if (virNetworkDHCPHostDefParseXML(def->name, ctxt->node, &host, true)
< 0)
goto cleanup;
/* log error if an entry with same name/address/ip already exists */
@@ -2565,7 +2565,7 @@ virNetworkDefUpdateIPDHCPHost(virNetworkDefPtr def,
}
} else if (command == VIR_NETWORK_UPDATE_COMMAND_DELETE) {
- if (virNetworkDHCPHostDefParse(def->name, ctxt->node, &host, false)
< 0)
+ if (virNetworkDHCPHostDefParseXML(def->name, ctxt->node, &host, false)
< 0)
goto cleanup;
/* find matching entry - all specified attributes must match */
@@ -2631,7 +2631,7 @@ virNetworkDefUpdateIPDHCPRange(virNetworkDefPtr def,
goto cleanup;
}
- if (virNetworkDHCPRangeDefParse(def->name, ctxt->node, &range) < 0)
+ if (virNetworkDHCPRangeDefParseXML(def->name, ctxt->node, &range) < 0)
goto cleanup;
/* check if an entry with same name/address/ip already exists */
--
1.7.11.7