From nobody Sun Feb 8 15:30:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1581212006466620.4119006142572; Sat, 8 Feb 2020 17:33:26 -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-37-xsbe4jg9P8-3ZYBM6cbeGA-1; Sat, 08 Feb 2020 20:33:23 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 78C7BDB24; Sun, 9 Feb 2020 01:33:17 +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 52BE560BE1; Sun, 9 Feb 2020 01:33:17 +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 0DA48866C2; Sun, 9 Feb 2020 01:33:17 +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 0191WrAL021170 for ; Sat, 8 Feb 2020 20:32:53 -0500 Received: by smtp.corp.redhat.com (Postfix) id 625555C28F; Sun, 9 Feb 2020 01:32:53 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-20.brq.redhat.com [10.40.200.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7446C5C21B for ; Sun, 9 Feb 2020 01:32:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581212005; 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=BIMhghQtDbu8MRObGVUES9A9ibZrRTHpfhqhef1OKQs=; b=P5Gs0cwwpN7P7546GZksOWCd1ZyEk5vaLxGiq2WBrZch5IhibwCxBzPKV+ertIidED2Z49 UkjnZGTkPTxJZXEDIVIpdxxH04ZnqhVDbqB7LNps0iU2NGq6FVpyIMoEr/h/V3Bk100k/9 3yIc4/S3XYoopPhGFLv85x8lashy8lo= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 3/7] testutils: use g_autoptr Date: Sun, 9 Feb 2020 02:32:33 +0100 Message-Id: <535abdabeb7a47f447ce22d313c53d747226ac1f.1581211907.git.jtomko@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.79 on 10.5.11.12 X-MC-Unique: xsbe4jg9P8-3ZYBM6cbeGA-1 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" Use g_autoptr where possible. virTestCapsBuildNUMATopology is not converted completely, because while the VIR_FREE call on cell_cpus is technically wrong, neither VIR_ALLOC_N nor virBitmapNew can return an allocation error now so it is effectively dead code. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Daniel P. Berrang=C3=A9 --- tests/testutils.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/tests/testutils.c b/tests/testutils.c index 75cba98eb3..e9431b9b5f 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -418,7 +418,7 @@ virTestRewrapFile(const char *filename) { int ret =3D -1; g_autofree char *script =3D NULL; - virCommandPtr cmd =3D NULL; + g_autoptr(virCommand) cmd =3D NULL; =20 if (!(virStringHasSuffix(filename, ".args") || virStringHasSuffix(filename, ".ldargs"))) @@ -432,7 +432,6 @@ virTestRewrapFile(const char *filename) =20 ret =3D 0; cleanup: - virCommandFree(cmd); return ret; } =20 @@ -1001,7 +1000,7 @@ void virTestClearCommandPath(char *cmdset) =20 virCapsPtr virTestGenericCapsInit(void) { - virCapsPtr caps; + g_autoptr(virCaps) caps =3D NULL; virCapsGuestPtr guest; =20 if ((caps =3D virCapabilitiesNew(VIR_ARCH_X86_64, @@ -1047,10 +1046,9 @@ virCapsPtr virTestGenericCapsInit(void) VIR_TEST_DEBUG("Generic driver capabilities:\n%s", caps_str); } =20 - return caps; + return g_steal_pointer(&caps); =20 error: - virObjectUnref(caps); return NULL; } =20 @@ -1066,7 +1064,7 @@ virCapsPtr virTestGenericCapsInit(void) virCapsHostNUMAPtr virTestCapsBuildNUMATopology(int seq) { - virCapsHostNUMAPtr caps =3D virCapabilitiesHostNUMANew(); + g_autoptr(virCapsHostNUMA) caps =3D virCapabilitiesHostNUMANew(); virCapsHostNUMACellCPUPtr cell_cpus =3D NULL; int core_id, cell_id; int id; @@ -1096,10 +1094,9 @@ virTestCapsBuildNUMATopology(int seq) cell_cpus =3D NULL; } =20 - return caps; + return g_steal_pointer(&caps); =20 error: - virCapabilitiesHostNUMAUnref(caps); VIR_FREE(cell_cpus); return NULL; } --=20 2.21.1