From 9ce764872cc9730b17e823f4c40ff63b913afae5 Mon Sep 17 00:00:00 2001 From: Kirill Shchetiniuk Date: Tue, 22 Jul 2025 17:12:04 +0200 Subject: [PATCH] conf: virDomainChrDefParseTargetXML refactor Refactored the default case port option parsing logic to use the appropriate virXMLPropInt function. Signed-off-by: Kirill Shchetiniuk Signed-off-by: Michal Privoznik Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ba0d4a7b12..4f2045c213 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,11 @@ 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.47.2