From: Kirill Shchetiniuk <kshcheti(a)redhat.com>
Refactored the default case port option parsing logic to use the
appropriate virXMLPropInt function.
Signed-off-by: Kirill Shchetiniuk <kshcheti(a)redhat.com>
---
src/conf/domain_conf.c | 15 +--------------
1 file changed, 1 insertion(+), 14 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index bfc62b6270..42e3db5547 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -10469,7 +10469,6 @@ virDomainChrDefParseTargetXML(virDomainChrDef *def,
g_autofree char *targetType = virXMLPropString(cur, "type");
g_autofree char *targetModel = NULL;
g_autofree char *addrStr = NULL;
- g_autofree char *portStr = NULL;
VIR_XPATH_NODE_AUTORESTORE(ctxt)
ctxt->node = cur;
@@ -10540,20 +10539,8 @@ virDomainChrDefParseTargetXML(virDomainChrDef *def,
break;
default:
- portStr = virXMLPropString(cur, "port");
- if (portStr == NULL) {
- /* Set to negative value to indicate we should set it later */
- def->target.port = -1;
- break;
- }
-
- if (virStrToLong_ui(portStr, NULL, 10, &port) < 0) {
- virReportError(VIR_ERR_XML_ERROR,
- _("Invalid port number: %1$s"),
- portStr);
+ if (virXMLPropInt(cur, "port", 10, VIR_XML_PROP_NONNEGATIVE,
&def->target.port, -1) < 0)
return -1;
- }
- def->target.port = port;
break;
}
--
2.49.0