passwd = virXPathString(xpath, ctxt);
VIR_FREE(xpath);
- if (STREQ(scheme[iter], "vnc")) {
- /* VNC protocol handlers take their port number as
- * 'port' - 5900 */
- port -= 5900;
- }
-
/* Build up the full URI, starting with the scheme */
virBufferAsprintf(&buf, "%s://", scheme[iter]);
virBufferAsprintf(&buf, "%s", listen_addr);
/* Add the port */
- if (port)
+ if (port) {
+ if (STREQ(scheme[iter], "vnc")) {
+ /* VNC protocol handlers take their port number as
+ * 'port' - 5900 */
+ port -= 5900;
+ }
+
virBufferAsprintf(&buf, ":%d", port);
+ }
/* TLS Port */
if (tls_port) {