From: Kirill Shchetiniuk <kshch...@redhat.com>

Refactored the default case port option parsing logic to use the
appropriate virXMLPropInt function.

Signed-off-by: Kirill Shchetiniuk <kshch...@redhat.com>
---
 src/conf/domain_conf.c | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index ba0d4a7b12..49d041706e 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -10473,7 +10473,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;
@@ -10544,20 +10543,9 @@ 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);
+        /* Set default to negative value to indicate we should set it later */
+        if (virXMLPropInt(cur, "port", 10, VIR_XML_PROP_NONNEGATIVE, 
&def->target.port, -1) < 0)
             return -1;
-        }
-        def->target.port = port;
         break;
     }
 
-- 
2.49.0

Reply via email to