Signed-off-by: Tim Wiederhake <twiederh(a)redhat.com>
---
src/conf/network_conf.c | 26 ++++++++++----------------
1 file changed, 10 insertions(+), 16 deletions(-)
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index c3c335135b..a9eadff29c 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -410,27 +410,21 @@ virNetworkDHCPLeaseTimeDefParseXML(virNetworkDHCPLeaseTimeDef
**lease,
xmlNodePtr node)
{
virNetworkDHCPLeaseTimeDef *new_lease = NULL;
- g_autofree char *expirystr = NULL;
- g_autofree char *unitstr = NULL;
unsigned long long expiry;
- int unit = VIR_NETWORK_DHCP_LEASETIME_UNIT_MINUTES;
+ virNetworkDHCPLeaseTimeUnitType unit;
+ int rc;
- if (!(expirystr = virXMLPropString(node, "expiry")))
+ if ((rc = virXMLPropULongLong(node, "expiry", 0, VIR_XML_PROP_NONE,
&expiry)) < 0)
+ return -1;
+
+ if (rc == 0)
return 0;
- if (virStrToLong_ull(expirystr, NULL, 10, &expiry) < 0) {
- virReportError(VIR_ERR_XML_ERROR,
- _("failed to parse expiry value '%s'"),
expirystr);
+ if (virXMLPropEnumDefault(node, "unit",
+ virNetworkDHCPLeaseTimeUnitTypeFromString,
+ VIR_XML_PROP_NONE, &unit,
+ VIR_NETWORK_DHCP_LEASETIME_UNIT_MINUTES) < 0)
return -1;
- }
-
- if ((unitstr = virXMLPropString(node, "unit"))) {
- if ((unit = virNetworkDHCPLeaseTimeUnitTypeFromString(unitstr)) < 0) {
- virReportError(VIR_ERR_XML_ERROR,
- _("Invalid unit: %s"), unitstr);
- return -1;
- }
- }
/* infinite */
if (expiry > 0) {
--
2.26.3