From nobody Mon Feb 9 00:30:10 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1529500644110294.58078531962883; Wed, 20 Jun 2018 06:17:24 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5EB38550CF; Wed, 20 Jun 2018 13:17:22 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0FA6C308BDAE; Wed, 20 Jun 2018 13:17:22 +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 A4E6C24F62; Wed, 20 Jun 2018 13:17:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5KDHBL1012571 for ; Wed, 20 Jun 2018 09:17:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id 583E320180F2; Wed, 20 Jun 2018 13:17:11 +0000 (UTC) Received: from dhcp-17-130.bos.redhat.com (dhcp-17-130.bos.redhat.com [10.18.17.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4068E2026D6B; Wed, 20 Jun 2018 13:17:11 +0000 (UTC) From: Anya Harter To: libvir-list@redhat.com Date: Wed, 20 Jun 2018 09:16:59 -0400 Message-Id: <96628e00423dba389523e593ee7018758917bbe6.1529441081.git.aharter@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Cc: Anya Harter Subject: [libvirt] [PATCH 1/2] qemu: use virBuffer in qemuBuildSCSIiSCSIHostdevDrvStr 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 20 Jun 2018 13:17:23 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Instead of source to enable use of virBuffer functions in string construction. Signed-off-by: Anya Harter --- src/qemu/qemu_command.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index e05b106a5e..a99240992a 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4657,7 +4657,8 @@ static char * qemuBuildSCSIiSCSIHostdevDrvStr(virDomainHostdevDefPtr dev, virQEMUCapsPtr qemuCaps) { - char *source =3D NULL; + virBuffer buf =3D VIR_BUFFER_INITIALIZER; + char *netsource =3D NULL; virJSONValuePtr srcprops =3D NULL; virDomainHostdevSubsysSCSIPtr scsisrc =3D &dev->source.subsys.u.scsi; @@ -4670,21 +4671,25 @@ qemuBuildSCSIiSCSIHostdevDrvStr(virDomainHostdevDef= Ptr dev, goto cleanup; if (!(netsource =3D virQEMUBuildDriveCommandlineFromJSON(srcprops)= )) goto cleanup; - if (virAsprintf(&source, "%s,if=3Dnone,format=3Draw", netsource) <= 0) - goto cleanup; + virBufferAsprintf(&buf, "%s,if=3Dnone,format=3Draw", netsource); } else { /* Rather than pull what we think we want - use the network disk c= ode */ if (!(netsource =3D qemuBuildNetworkDriveStr(iscsisrc->src, srcPri= v ? srcPriv->secinfo : NULL= ))) goto cleanup; - if (virAsprintf(&source, "file=3D%s,if=3Dnone,format=3Draw", netso= urce) < 0) - goto cleanup; + virBufferAsprintf(&buf, "file=3D%s,if=3Dnone,format=3Draw", netsou= rce); } =20 + if (virBufferCheckError(&buf) < 0) + goto cleanup; + + return virBufferContentAndReset(&buf); + cleanup: VIR_FREE(netsource); virJSONValueFree(srcprops); - return source; + virBufferFreeAndReset(&buf); + return NULL; } =20 char * --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list