From nobody Sun Feb 8 07:26:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1606999026; cv=none; d=zohomail.com; s=zohoarc; b=X3c7NeJ2ZSjuxtU3Hbm4G409a9yeoBmDrv11IeEj+/YbwkNnaVlOIS89zJGh1B5gKQ/VKlTLoYjbrZid1nlyLAXsoLuNMd5XzY/2pCBKDSJgzC9AImvX4lYsQoxUAeWzI+iR57k/OPRSct/jxWTIZufKH+uIZAmoSbIrPym8/MA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606999026; 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=wLRzEng8wY7yoBxFO8bk/ukhEgthhHXX+Ros9kuvMoM=; b=kG2Or0jCzzQ9JuK1caSPfejbz2KyshTDHswQ6AoDkoU6sV92aUg0dnD3+z/A44QAOESkz6BlV1e1PVqYNS8CpL5jGy0JvkDfBJbSlL7I0OyUhGlZEZ1sUrsn6aeVyaBHqCxEjS+BOpYSpUST8d38Mg0tYalPRiIp/E5XsGVP4Ng= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1606999026723434.28587534387; Thu, 3 Dec 2020 04:37:06 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-24-aCAuOUx_PbK7UFVIXydPzg-1; Thu, 03 Dec 2020 07:37:02 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 514491081B29; Thu, 3 Dec 2020 12:36:57 +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 287541F470; Thu, 3 Dec 2020 12:36:57 +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 E5E3F4EE7F; Thu, 3 Dec 2020 12:36:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0B3CarYP002969 for ; Thu, 3 Dec 2020 07:36:54 -0500 Received: by smtp.corp.redhat.com (Postfix) id F03A65C1C2; Thu, 3 Dec 2020 12:36:53 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6F7A55C1CF for ; Thu, 3 Dec 2020 12:36:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606999025; 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=wLRzEng8wY7yoBxFO8bk/ukhEgthhHXX+Ros9kuvMoM=; b=IPi6zOPv1NMAxRUN67kUlMiFf383s+uGwayVvP/lyfv5vExLwHzAK24Nf4bThoQHhFFbLb NH3rNkiCVCOHzaPOF9yc9xgZQfaFpMnlEpP8qjb8ooP5R1Phj63IKv2fBptTxgk93MX8a7 bBKSeCg5X60jglCBx7EglBGBqmkQ00Q= X-MC-Unique: aCAuOUx_PbK7UFVIXydPzg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 08/27] virDomainMemorySourceDefFormat: Utilize virXMLFormatElement() Date: Thu, 3 Dec 2020 13:36:11 +0100 Message-Id: <5f3249a0723d7f4d683bc3efc2f1ca0e8fd46bc2.1606998426.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.84 on 10.5.11.23 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) Content-Type: text/plain; charset="utf-8" The virDomainMemorySourceDefFormat() uses good old style of formatting child buffer (virBufferAdjustIndent()). When switched to virXMLFormatElement() we can save a couple of lines. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/conf/domain_conf.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 2a2cfd24e0..bb0d9f4501 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -27839,37 +27839,32 @@ static int virDomainMemorySourceDefFormat(virBufferPtr buf, virDomainMemoryDefPtr def) { + g_auto(virBuffer) childBuf =3D VIR_BUFFER_INIT_CHILD(buf); g_autofree char *bitmap =3D NULL; =20 - if (!def->pagesize && !def->sourceNodes && !def->nvdimmPath) - return 0; - - virBufferAddLit(buf, "\n"); - virBufferAdjustIndent(buf, 2); - switch (def->model) { case VIR_DOMAIN_MEMORY_MODEL_DIMM: if (def->sourceNodes) { if (!(bitmap =3D virBitmapFormat(def->sourceNodes))) return -1; =20 - virBufferAsprintf(buf, "%s\n", bitmap); + virBufferAsprintf(&childBuf, "%s\n", bitm= ap); } =20 if (def->pagesize) - virBufferAsprintf(buf, "%llu= \n", + virBufferAsprintf(&childBuf, "%llu\n", def->pagesize); break; =20 case VIR_DOMAIN_MEMORY_MODEL_NVDIMM: - virBufferEscapeString(buf, "%s\n", def->nvdimmPath); + virBufferEscapeString(&childBuf, "%s\n", def->nvdimmP= ath); =20 if (def->alignsize) - virBufferAsprintf(buf, "%llu\n", + virBufferAsprintf(&childBuf, "%llu\n", def->alignsize); =20 if (def->nvdimmPmem) - virBufferAddLit(buf, "\n"); + virBufferAddLit(&childBuf, "\n"); break; =20 case VIR_DOMAIN_MEMORY_MODEL_NONE: @@ -27877,8 +27872,7 @@ virDomainMemorySourceDefFormat(virBufferPtr buf, break; } =20 - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); + virXMLFormatElement(buf, "source", NULL, &childBuf); =20 return 0; } --=20 2.26.2