From nobody Mon Feb 9 10:32:23 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1646229424; cv=none; d=zohomail.com; s=zohoarc; b=EUtCJ0F3uGYH4Zd3WoVMGrtlcOwV0HpdIBtO/Ku38/GRs0N+l7uNscNVFzHdOsLv5SP83EximD2mxeLdLbXn7dSKvrrVzszSZ0nR6eNbQUUN+YJDlVwRe9qD5z7IQttiSZ1q0OKGrBQe7SR4DnBAp/6c2Y+FT3F9JpMvFLAUU0o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646229424; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YcHq2ELIQgKOzHlxn65D6/PHqY6cSJbpCfmcJYrrXB0=; b=fX+1eXJHUyJXxFjSFuXwDYv1WRtDbAQIaT01kaIUCMWpnUcejSnW6ooXholqOMSZ6CgiGrvuLwvV3MLWNyUubx/HmMX/DGVmve9dj9wY+J+44W9jm9Kte8rNxAKzxggw2W4qYXPjrm9MzNJg5o7PTxK9fU0pxvZCtgNBxQxjDp0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1646229424618121.90972948943875; Wed, 2 Mar 2022 05:57:04 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-315-a7dDujICNSy51JVo8CcjRw-1; Wed, 02 Mar 2022 08:56:27 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E3C5D1091DA2; Wed, 2 Mar 2022 13:56:21 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CB19B7B8D8; Wed, 2 Mar 2022 13:56:21 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A05841807D70; Wed, 2 Mar 2022 13:56:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 222DuGUM017901 for ; Wed, 2 Mar 2022 08:56:16 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7B3AD83780; Wed, 2 Mar 2022 13:56:16 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id D52F883788 for ; Wed, 2 Mar 2022 13:56:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646229423; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=YcHq2ELIQgKOzHlxn65D6/PHqY6cSJbpCfmcJYrrXB0=; b=TCdAVZJ+1mkItBEHO5ib/vYMCOUdGer1XXnBAztOdhelvTh5/H87kDx9uvi5r4H3bFCspD w6jJPbphAfLAM2JvheCR5MfAVaTyq7CYH9DKsUax18CcdyBHkQcv0HS+sbthl0rCJavYAs vXyymGIJIp0N3AP03M120SOm7RbxGEs= X-MC-Unique: a7dDujICNSy51JVo8CcjRw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 15/23] virshGetOneDisplay: Refactor formatting of URI params Date: Wed, 2 Mar 2022 14:55:14 +0100 Message-Id: <2daf0816e5879bc8c664629314327e1fb0b7563b.1646229194.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1646229425618100001 Content-Type: text/plain; charset="utf-8" Unconditionally format the start of the query ('?') and make delimiters ('&') part of the arguments. At the end we can trim off 1 char from the end of the buffer unconditionally. Signed-off-by: Peter Krempa --- tools/virsh-domain.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index d0f78798b5..ca1145428f 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -11678,7 +11678,6 @@ virshGetOneDisplay(vshControl *ctl, g_autofree char *type_conn =3D NULL; g_autofree char *sockpath =3D NULL; g_autofree char *passwd =3D NULL; - bool params =3D false; /* Attempt to get the port number for the current graphics scheme */ xpathPort =3D g_strdup_printf(xpath_fmt, scheme, "@port"); @@ -11781,22 +11780,20 @@ virshGetOneDisplay(vshControl *ctl, virBufferAsprintf(&buf, ":%d", port); } + /* format the parameters part of the uri */ + virBufferAddLit(&buf, "?"); + /* TLS Port */ if (tls_port) { - virBufferAsprintf(&buf, - "?tls-port=3D%d", - tls_port); - params =3D true; + virBufferAsprintf(&buf, "tls-port=3D%d&", tls_port); } if (STREQ(scheme, "spice") && passwd) { - virBufferAsprintf(&buf, - "%spassword=3D%s", - params ? "&" : "?", - passwd); - params =3D true; + virBufferAsprintf(&buf, "password=3D%s&", passwd); } + virBufferTrimLen(&buf, 1); + return virBufferContentAndReset(&buf); } --=20 2.35.1