From nobody Mon Feb 9 03:00:05 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 1551860471180215.3702940131467; Wed, 6 Mar 2019 00:21:11 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 56CCD30224BE; Wed, 6 Mar 2019 08:21:09 +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 280F11A91B; Wed, 6 Mar 2019 08:21:09 +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 D9E373FB12; Wed, 6 Mar 2019 08:21:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x268Kv8c032489 for ; Wed, 6 Mar 2019 03:20:57 -0500 Received: by smtp.corp.redhat.com (Postfix) id C4B391A91B; Wed, 6 Mar 2019 08:20:57 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 493501A267 for ; Wed, 6 Mar 2019 08:20:57 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 6 Mar 2019 09:20:32 +0100 Message-Id: <07f58c4d21b815f507685fc0f538c2605a3715d1.1551859940.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 07/23] conf: Refactor formatting of 'driver' in virDomainRNGDefFormat 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: , 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.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Wed, 06 Mar 2019 08:21:09 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Use virXMLFormatElement to format the internals along with simplifying cleanup code paths. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 766846a557..71e0c8679b 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -25982,8 +25982,7 @@ virDomainRNGDefFormat(virBufferPtr buf, { const char *model =3D virDomainRNGModelTypeToString(def->model); const char *backend =3D virDomainRNGBackendTypeToString(def->backend); - virBuffer driverBuf =3D VIR_BUFFER_INITIALIZER; - int ret =3D -1; + VIR_AUTOCLEAN(virBuffer) driverAttrBuf =3D VIR_BUFFER_INITIALIZER; virBufferAsprintf(buf, "\n", model); virBufferAdjustIndent(buf, 2); @@ -26002,11 +26001,11 @@ virDomainRNGDefFormat(virBufferPtr buf, case VIR_DOMAIN_RNG_BACKEND_EGD: if (virDomainChrAttrsDefFormat(buf, def->source.chardev, false) < = 0) - goto cleanup; + return -1; virBufferAddLit(buf, ">\n"); virBufferAdjustIndent(buf, 2); if (virDomainChrSourceDefFormat(buf, def->source.chardev, flags) <= 0) - goto cleanup; + return -1; virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); @@ -26014,28 +26013,18 @@ virDomainRNGDefFormat(virBufferPtr buf, break; } - virDomainVirtioOptionsFormat(&driverBuf, def->virtio); - if (virBufferCheckError(&driverBuf) < 0) - goto cleanup; + virDomainVirtioOptionsFormat(&driverAttrBuf, def->virtio); - if (virBufferUse(&driverBuf)) { - virBufferAddLit(buf, "\n"); - } + if (virXMLFormatElement(buf, "driver", &driverAttrBuf, NULL) < 0) + return -1; if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) - goto cleanup; + return -1; virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); - ret =3D 0; - - cleanup: - virBufferFreeAndReset(&driverBuf); - - return ret; + return 0; } void --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list