From: Kirill Shchetiniuk Date: Tue, 22 Jul 2025 15:12:04 +0000 (+0200) Subject: conf: virDomainChrDefParseTargetXML refactor X-Git-Tag: v11.6.0-rc1~42 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9ce764872cc9730b17e823f4c40ff63b913afae5;p=thirdparty%2Flibvirt.git 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 --- 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; }