From nobody Sun Feb 8 21:33:26 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=1635159492; cv=none; d=zohomail.com; s=zohoarc; b=A7czUV4oalZ9ep4lGbUjUTu1Ea/yffmG/cfD400pe8vmv5Cq8K1QaWhAf6J5Yif3KIR4VeY4ytEUFSKPRsaw9KK4DJYUnaHW/4m/sXbEXRamILNFCRdLldHY/Pfn1TKBBakD6+N4YOoVBY6A3J2/uINxA6Ff9GIzgibB5nGkLrc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635159492; 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=adbXTynd/33wTSECI3hoCAxBRT4YTuVx1Vh+cgU/C28=; b=nhvyrIeWmK8fzvpPd7ftfdw/fg7SA+8D6iG+Dj0quCXSZX/7et76BMLU6fie8+YsMMAwdOtpA5G3hB5QQQgxBuD63N5pr7O/n3BCz0bUz8NseaW7g0/kUI2gtmueo5laK5FHRg+2VxpnbqfozxgCuSRW4T4TVBwW0L2xOyO04jY= 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 1635159492502474.02868210542124; Mon, 25 Oct 2021 03:58:12 -0700 (PDT) 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-438-iSQv4hZqNEyWhHE2HzvKOw-1; Mon, 25 Oct 2021 06:58:07 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4B58A802B78; Mon, 25 Oct 2021 10:58:03 +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 261F55D705; Mon, 25 Oct 2021 10:58:03 +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 E780C1832DD6; Mon, 25 Oct 2021 10:58:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 19PAvsS9016879 for ; Mon, 25 Oct 2021 06:57:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 72905ADCD; Mon, 25 Oct 2021 10:57:54 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id EED885DAA5 for ; Mon, 25 Oct 2021 10:57:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635159491; 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=adbXTynd/33wTSECI3hoCAxBRT4YTuVx1Vh+cgU/C28=; b=GMR4IQSmuRGtHcB++avil9IkcpE1l+d0jJfubiEAOAvDA4QHk1EQdI3ih90qCUgavF2kZR qFIlS7ZJd17LgHO4JhBaPg9w4Qm7vDUMfSjO5URdfPCtoY8pJWIHRBo7WA0w3pIZu4+0cG 5hh1Wk6utm5ELXs0RiH/UkAL3ZPY+1k= X-MC-Unique: iSQv4hZqNEyWhHE2HzvKOw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 07/13] qemu_monitor_json: Use g_autoptr() for virCPUData Date: Mon, 25 Oct 2021 12:57:31 +0200 Message-Id: <7dc7712c4da771a0974522a55e4e04c05c5b4fef.1635159386.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.79 on 10.5.11.15 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) X-ZM-MESSAGEID: 1635159494175100001 Content-Type: text/plain; charset="utf-8" We have g_autoptr() for virCPUData struct defined already. Let's use it in qemu_monitor_json.c and drop explicit free calls. Signed-off-by: Michal Privoznik --- src/qemu/qemu_monitor_json.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 655d2a022f..3d89afa6c6 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -7288,7 +7288,7 @@ qemuMonitorJSONParseCPUx86FeatureWord(virJSONValue *d= ata, static virCPUData * qemuMonitorJSONParseCPUx86Features(virJSONValue *data) { - virCPUData *cpudata =3D NULL; + g_autoptr(virCPUData) cpudata =3D NULL; virCPUx86DataItem item =3D { 0 }; size_t i; =20 @@ -7303,10 +7303,9 @@ qemuMonitorJSONParseCPUx86Features(virJSONValue *dat= a) goto error; } =20 - return cpudata; + return g_steal_pointer(&cpudata); =20 error: - virCPUDataFree(cpudata); return NULL; } =20 @@ -7418,8 +7417,8 @@ qemuMonitorJSONGetGuestCPUx86(qemuMonitor *mon, virCPUData **data, virCPUData **disabled) { - virCPUData *cpuEnabled =3D NULL; - virCPUData *cpuDisabled =3D NULL; + g_autoptr(virCPUData) cpuEnabled =3D NULL; + g_autoptr(virCPUData) cpuDisabled =3D NULL; int rc; =20 if ((rc =3D qemuMonitorJSONCheckCPUx86(mon)) < 0) @@ -7436,14 +7435,12 @@ qemuMonitorJSONGetGuestCPUx86(qemuMonitor *mon, &cpuDisabled) < 0) goto error; =20 - *data =3D cpuEnabled; + *data =3D g_steal_pointer(&cpuEnabled); if (disabled) - *disabled =3D cpuDisabled; + *disabled =3D g_steal_pointer(&cpuDisabled); return 0; =20 error: - virCPUDataFree(cpuEnabled); - virCPUDataFree(cpuDisabled); return -1; } =20 @@ -7554,8 +7551,8 @@ qemuMonitorJSONGetGuestCPU(qemuMonitor *mon, virCPUData **enabled, virCPUData **disabled) { - virCPUData *cpuEnabled =3D NULL; - virCPUData *cpuDisabled =3D NULL; + g_autoptr(virCPUData) cpuEnabled =3D NULL; + g_autoptr(virCPUData) cpuDisabled =3D NULL; int ret =3D -1; =20 if (!(cpuEnabled =3D virCPUDataNew(arch)) || @@ -7576,8 +7573,6 @@ qemuMonitorJSONGetGuestCPU(qemuMonitor *mon, ret =3D 0; =20 cleanup: - virCPUDataFree(cpuEnabled); - virCPUDataFree(cpuDisabled); return ret; } =20 --=20 2.32.0