From nobody Thu May 15 16:40:45 2025 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1503588148995345.9604066543253; Thu, 24 Aug 2017 08:22:28 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E7CCA68B5; Thu, 24 Aug 2017 15:22:26 +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 A32907EE61; Thu, 24 Aug 2017 15:22:26 +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 2BB881806106; Thu, 24 Aug 2017 15:22:26 +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 v7OFMJPo014767 for ; Thu, 24 Aug 2017 11:22:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id E0950700B4; Thu, 24 Aug 2017 15:22:19 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 674217F48C for ; Thu, 24 Aug 2017 15:22:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E7CCA68B5 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Date: Thu, 24 Aug 2017 17:22:06 +0200 Message-Id: <8c71aaa7e14dabb7e7b152aca404fe5612eb62ae.1503588082.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/3] util: introduce virBufferSetChildIndent macro 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.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 24 Aug 2017 15:22:27 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina --- src/conf/capabilities.c | 3 +-- src/conf/cpu_conf.c | 3 +-- src/conf/domain_conf.c | 26 +++++++++++--------------- src/util/virbuffer.h | 9 +++++++++ 4 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index 69af3911a0..ba554535ae 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -872,7 +872,6 @@ virCapabilitiesFormatCaches(virBufferPtr buf, { size_t i =3D 0; size_t j =3D 0; - int indent =3D virBufferGetIndent(buf, false); virBuffer controlBuf =3D VIR_BUFFER_INITIALIZER; =20 if (!ncaches) @@ -903,7 +902,7 @@ virCapabilitiesFormatCaches(virBufferPtr buf, cpus_str); VIR_FREE(cpus_str); =20 - virBufferAdjustIndent(&controlBuf, indent + 4); + virBufferSetChildIndent(&controlBuf, buf); for (j =3D 0; j < bank->ncontrols; j++) { bool min_kilos =3D !(bank->controls[j]->granularity % 1024); =20 diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index cdb8583647..c21d11d244 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -599,7 +599,6 @@ virCPUDefFormatBufFull(virBufferPtr buf, int ret =3D -1; virBuffer attributeBuf =3D VIR_BUFFER_INITIALIZER; virBuffer childrenBuf =3D VIR_BUFFER_INITIALIZER; - int indent =3D virBufferGetIndent(buf, false); =20 if (!def) return 0; @@ -636,7 +635,7 @@ virCPUDefFormatBufFull(virBufferPtr buf, } =20 /* Format children */ - virBufferAdjustIndent(&childrenBuf, indent + 2); + virBufferSetChildIndent(&childrenBuf, buf); if (def->type =3D=3D VIR_CPU_TYPE_HOST && def->arch) virBufferAsprintf(&childrenBuf, "%s\n", virArchToString(def->arch)); diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 478feb92d8..b8867fd1ea 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -22004,7 +22004,7 @@ virDomainControllerDefFormat(virBufferPtr buf, const char *modelName =3D NULL; virBuffer childBuf =3D VIR_BUFFER_INITIALIZER; =20 - virBufferAdjustIndent(&childBuf, virBufferGetIndent(buf, false) + 2); + virBufferSetChildIndent(&childBuf, buf); =20 if (!type) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -23287,7 +23287,7 @@ virDomainSmartcardDefFormat(virBufferPtr buf, virBuffer childBuf =3D VIR_BUFFER_INITIALIZER; size_t i; =20 - virBufferAdjustIndent(&childBuf, virBufferGetIndent(buf, false) + 2); + virBufferSetChildIndent(&childBuf, buf); =20 if (!mode) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -23396,7 +23396,7 @@ virDomainSoundDefFormat(virBufferPtr buf, virBuffer childBuf =3D VIR_BUFFER_INITIALIZER; size_t i; =20 - virBufferAdjustIndent(&childBuf, virBufferGetIndent(buf, false) + 2); + virBufferSetChildIndent(&childBuf, buf); =20 if (!model) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -23432,7 +23432,6 @@ virDomainMemballoonDefFormat(virBufferPtr buf, { const char *model =3D virDomainMemballoonModelTypeToString(def->model); virBuffer childrenBuf =3D VIR_BUFFER_INITIALIZER; - int indent =3D virBufferGetIndent(buf, false); =20 if (!model) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -23446,7 +23445,7 @@ virDomainMemballoonDefFormat(virBufferPtr buf, virBufferAsprintf(buf, " autodeflate=3D'%s'", virTristateSwitchTypeToString(def->autodeflate)); =20 - virBufferAdjustIndent(&childrenBuf, indent + 2); + virBufferSetChildIndent(&childrenBuf, buf); =20 if (def->period) virBufferAsprintf(&childrenBuf, "\n", def->p= eriod); @@ -23508,7 +23507,7 @@ virDomainWatchdogDefFormat(virBufferPtr buf, const char *action =3D virDomainWatchdogActionTypeToString(def->action= ); virBuffer childBuf =3D VIR_BUFFER_INITIALIZER; =20 - virBufferAdjustIndent(&childBuf, virBufferGetIndent(buf, false) + 2); + virBufferSetChildIndent(&childBuf, buf); =20 if (!model) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -23545,7 +23544,6 @@ static int virDomainPanicDefFormat(virBufferPtr buf, virDomainPanicDefPtr def) { virBuffer childrenBuf =3D VIR_BUFFER_INITIALIZER; - int indent =3D virBufferGetIndent(buf, false); =20 virBufferAddLit(buf, "model)); =20 - virBufferAdjustIndent(&childrenBuf, indent + 2); + virBufferSetChildIndent(&childrenBuf, buf); virDomainDeviceInfoFormat(&childrenBuf, &def->info, 0); =20 if (virBufferCheckError(&childrenBuf) < 0) @@ -23888,7 +23886,7 @@ virDomainInputDefFormat(virBufferPtr buf, virBufferAsprintf(buf, "virtio); if (virBufferCheckError(&driverBuf) < 0) return -1; @@ -24538,7 +24536,7 @@ virDomainHubDefFormat(virBufferPtr buf, const char *type =3D virDomainHubTypeToString(def->type); virBuffer childBuf =3D VIR_BUFFER_INITIALIZER; =20 - virBufferAdjustIndent(&childBuf, virBufferGetIndent(buf, false) + 2); + virBufferSetChildIndent(&childBuf, buf); =20 if (!type) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -24751,7 +24749,7 @@ virDomainCputuneDefFormat(virBufferPtr buf, virBuffer childrenBuf =3D VIR_BUFFER_INITIALIZER; int ret =3D -1; =20 - virBufferAdjustIndent(&childrenBuf, virBufferGetIndent(buf, false) + 2= ); + virBufferSetChildIndent(&childrenBuf, buf); =20 if (def->cputune.sharesSpecified) virBufferAsprintf(&childrenBuf, "%llu\n", @@ -24933,7 +24931,7 @@ virDomainIOMMUDefFormat(virBufferPtr buf, { virBuffer childBuf =3D VIR_BUFFER_INITIALIZER; =20 - virBufferAdjustIndent(&childBuf, virBufferGetIndent(buf, false) + 2); + virBufferSetChildIndent(&childBuf, buf); =20 if (iommu->intremap !=3D VIR_TRISTATE_SWITCH_ABSENT || iommu->caching_mode !=3D VIR_TRISTATE_SWITCH_ABSENT || @@ -24987,7 +24985,6 @@ virDomainDefFormatInternal(virDomainDefPtr def, int n; size_t i; virBuffer childrenBuf =3D VIR_BUFFER_INITIALIZER; - int indent; char *netprefix =3D NULL; =20 virCheckFlags(VIR_DOMAIN_DEF_FORMAT_COMMON_FLAGS | @@ -25065,8 +25062,7 @@ virDomainDefFormatInternal(virDomainDefPtr def, def->mem.cur_balloon); =20 /* start format blkiotune */ - indent =3D virBufferGetIndent(buf, false); - virBufferAdjustIndent(&childrenBuf, indent + 2); + virBufferSetChildIndent(&childrenBuf, buf); if (def->blkio.weight) virBufferAsprintf(&childrenBuf, "%u\n", def->blkio.weight); diff --git a/src/util/virbuffer.h b/src/util/virbuffer.h index f34217968b..6ad9c3ec54 100644 --- a/src/util/virbuffer.h +++ b/src/util/virbuffer.h @@ -102,6 +102,15 @@ void virBufferURIEncodeString(virBufferPtr buf, const = char *str); void virBufferAdjustIndent(virBufferPtr buf, int indent); void virBufferSetIndent(virBufferPtr, int indent); =20 +/** + * virBufferSetChildIndent + * + * Gets the parent indentation, increments it by 2 and sets it to + * child buffer. + */ +# define virBufferSetChildIndent(childBuf_, parentBuf_) \ + virBufferAdjustIndent(childBuf_, virBufferGetIndent(parentBuf_, false)= + 2) + int virBufferGetIndent(const virBuffer *buf, bool dynamic); =20 void virBufferTrim(virBufferPtr buf, const char *trim, int len); --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list