From nobody Sun Feb 8 21:33:24 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=1672907766; cv=none; d=zohomail.com; s=zohoarc; b=DmpWKRQApj3Vixjrm1Yhh0jSDPPYoVQnfCgpfUDNHjdZp9qol0AvLBVDsJQtmh3N2O2NELU09PTUnL+pC1L6bZJXutQ9WBrhMve7hZTbEPO1jDktjwJ9tp0qkXJSz+/Bu9kJXVwyq95pZ8EXNzCz6HMxKzBvdwvZuMa2yvYFRRg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672907766; 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=HA3YLMAdnSmlFZ/TpG2uJOLo0SM51xZTk9A/ebQzWnA=; b=TrwLurYci7QbxgCbI0hPNT9m41+6rxwzWPAGJZ5OvuxUp5Zn5RAJOOsziYYDR/HOO6pav5FKVHpNorm6d7UgONcZuR8rd4hrmIwsMIZ7nh3DTHrL0OPxSNbLy2mH8EjlEktZQxZfLsMPunxB2pSRJ0P0bA6GKvFqeAI2zI1BnlE= 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 1672907766759151.2277907471414; Thu, 5 Jan 2023 00:36:06 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-58-QHGYKFb5PHKxBHtM5cxJfQ-1; Thu, 05 Jan 2023 03:35:11 -0500 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 05A943C1024D; Thu, 5 Jan 2023 08:35:08 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 914D7492B06; Thu, 5 Jan 2023 08:35:05 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C758C1946597; Thu, 5 Jan 2023 08:35:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E1C231946586 for ; Thu, 5 Jan 2023 08:35:03 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D24D0492B07; Thu, 5 Jan 2023 08:35:03 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A597492B06 for ; Thu, 5 Jan 2023 08:35:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672907765; 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=HA3YLMAdnSmlFZ/TpG2uJOLo0SM51xZTk9A/ebQzWnA=; b=K6e/gkwPXgI1zH29f4x09AlYGfyMOR6uUw5o38X/pihclPMd0PxXgy23Zxq1OUA8tLKF3c HboSt5PDh7YCgih6sjMZszpV92uQvo7jzXwwkJCstMkuGqC7JB7dUj+P9wc3b29fWYIL7G ZRtW6hg/mkoFNplKw02tqT7/5BSSUds= X-MC-Unique: QHGYKFb5PHKxBHtM5cxJfQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 1/7] virDomainCapsEnumFormat: Switch to virXMLFormatElement() Date: Thu, 5 Jan 2023 09:34:55 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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: 1672907767897100001 Content-Type: text/plain; charset="utf-8"; x-default="true" We are formatting element and its children using virBufferAddLit(), virBufferAsprintf(), virBufferAdjustIndent(), etc. Well, we can avoid that when switching to virXMLFormatElement(). Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/conf/domain_capabilities.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c index 4e412c0fd8..b464298003 100644 --- a/src/conf/domain_capabilities.c +++ b/src/conf/domain_capabilities.c @@ -269,18 +269,14 @@ virDomainCapsEnumFormat(virBuffer *buf, const char *capsEnumName, virDomainCapsValToStr valToStr) { + virBuffer attrBuf =3D VIR_BUFFER_INITIALIZER; + virBuffer childBuf =3D VIR_BUFFER_INIT_CHILD(buf); size_t i; =20 if (!capsEnum->report) return 0; =20 - virBufferAsprintf(buf, "values) { - virBufferAddLit(buf, "/>\n"); - return 0; - } - virBufferAddLit(buf, ">\n"); - virBufferAdjustIndent(buf, 2); + virBufferAsprintf(&attrBuf, " name=3D'%s'", capsEnumName); =20 for (i =3D 0; i < sizeof(capsEnum->values) * CHAR_BIT; i++) { const char *val; @@ -289,11 +285,10 @@ virDomainCapsEnumFormat(virBuffer *buf, continue; =20 if ((val =3D (valToStr)(i))) - virBufferAsprintf(buf, "%s\n", val); + virBufferAsprintf(&childBuf, "%s\n", val); } - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); =20 + virXMLFormatElement(buf, "enum", &attrBuf, &childBuf); return 0; } =20 --=20 2.38.2