From nobody Mon Feb 9 16:53:56 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.81 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=1573543722; cv=none; d=zoho.com; s=zohoarc; b=YwqP0r7Xuj/roQpkQoF5v3qQk95LoHYuvlykRdN1xVkL4CEEePAaWSl3DNtvWNn04UQ/jel9dSu1k0We+zV1egUX/siZxUNcVts7DE25a7fFZeBf+ilqaVKIte5nn4cMdssFksUpV2aj1x7+suy66X8nuJuy0wBoht3feKcmGt8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573543722; 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=aG3nV3k/mYEFC1ssoqbpbZ1BIwgMn8ir6VRtDTwmUiE=; b=h90j7UftLgweNuNFXwzIJFH+NkyzOZ+1viq6SzS1kLxkHAGg/6CjLrgcjFhGnR0xWtuqk6CzjDbQZ7QO3WZtFeSZ6XqWKEzGaVEHO91sVG3ufZ+FSTIuD/7dn3cwi98wVVWm2/R/slXVemkiVtaSfZ4Wamm8bkXDsHfjxpXhIMw= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.81 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-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1573543722522413.55026506102126; Mon, 11 Nov 2019 23:28:42 -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-401-4wVRZ9_lN-WIY4k8G78HWA-1; Tue, 12 Nov 2019 02:28:39 -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 E5CDEDB68; Tue, 12 Nov 2019 07:28:33 +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 BF02228D19; Tue, 12 Nov 2019 07:28:33 +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 7D1604E571; Tue, 12 Nov 2019 07:28:33 +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 xAC7RwBk011403 for ; Tue, 12 Nov 2019 02:27:58 -0500 Received: by smtp.corp.redhat.com (Postfix) id D9BCCBEA63; Tue, 12 Nov 2019 07:27:58 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6586D62671 for ; Tue, 12 Nov 2019 07:27:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573543721; 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=aG3nV3k/mYEFC1ssoqbpbZ1BIwgMn8ir6VRtDTwmUiE=; b=hEdPVz/rp3cnLXG5ClEXuDImIkAQpYUnuKEh0rPkk7wzh9PhGc+xh6il1q5rO4jzIXx5Pi xttp+UHcqlDM11u/tQDvoUdKdbQHQxydQ8suyHEp6MwZSlJqsAbt4D0dDRE1+4Xe8OM1ie lcy8ccPrhTyJuXn3tZ53QNhWHEUqKIo= From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 12 Nov 2019 08:27:46 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 09/10] conf: caps: Modernize virCapabilitiesFormatCaches 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 X-MC-Unique: 4wVRZ9_lN-WIY4k8G78HWA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Use automatic memory freeing and use virXMLFormatElement instead of open coding it. Signed-off-by: Peter Krempa --- src/conf/capabilities.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index 0a0de447b5..1ab389bc65 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -938,7 +938,6 @@ virCapabilitiesFormatCaches(virBufferPtr buf, { size_t i =3D 0; size_t j =3D 0; - virBuffer childrenBuf =3D VIR_BUFFER_INITIALIZER; if (!cache->nbanks) return 0; @@ -947,6 +946,8 @@ virCapabilitiesFormatCaches(virBufferPtr buf, virBufferAdjustIndent(buf, 2); for (i =3D 0; i < cache->nbanks; i++) { + g_auto(virBuffer) attrBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) childrenBuf =3D VIR_BUFFER_INITIALIZER; virCapsHostCacheBankPtr bank =3D cache->banks[i]; g_autofree char *cpus_str =3D virBitmapFormat(bank->cpus); const char *unit =3D NULL; @@ -959,8 +960,8 @@ virCapabilitiesFormatCaches(virBufferPtr buf, * Let's just *hope* the size is aligned to KiBs so that it does n= ot * bite is back in the future */ - virBufferAsprintf(buf, - "id, bank->level, virCacheTypeToString(bank->type), @@ -1006,13 +1007,7 @@ virCapabilitiesFormatCaches(virBufferPtr buf, controls->max_allocation); } - if (virBufferUse(&childrenBuf)) { - virBufferAddLit(buf, ">\n"); - virBufferAddBuffer(buf, &childrenBuf); - virBufferAddLit(buf, "\n"); - } else { - virBufferAddLit(buf, "/>\n"); - } + virXMLFormatElement(buf, "bank", &attrBuf, &childrenBuf); } if (virCapabilitiesFormatResctrlMonitor(buf, cache->monitor) < 0) --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list