From nobody Sun Feb 8 21:48:07 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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=1591628825; cv=none; d=zohomail.com; s=zohoarc; b=Upn0t8xdZD9YurcSVjPiYy2+TzQMvfvanXVb1qmF13PPdmfhRO2VTxsEV3Bp+cxcbhHKI2CQG927JZlJUcHs+HBjRr98nH9f+UCxX11ohNow6xlGnmNB9w0H175dXK0BdrEEhE2fQF2d7bsK3hOVpex6J9NaGyBBY0vmWvyoYd4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591628825; 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=Px57Bu/MgJEI6dTHZQtPtdmJhndQwCK4ORuOwTYwJM0=; b=I2/AVWZXRrCKmk+ybCNCiEk9rDmK2nM+3A1El2OBQakgzTVnA//ZxsARgcPq5+O5TrzXiVDvrwRg50Hr/x5lIEn4O/UfXb2ZgRh6Mgc+MOPlPR+GZek8NRESFXccTrhiWYzchkPW1eOcgg4uR0eyzjPWaIbPSrCt9+3bMAk9iWE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1591628825338772.269723788065; Mon, 8 Jun 2020 08:07:05 -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-391-8HNR1fu6M2OxOX0Y11Jk-w-1; Mon, 08 Jun 2020 11:06:41 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 306C518A0724; Mon, 8 Jun 2020 15:06:36 +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 1320E79598; Mon, 8 Jun 2020 15:06:36 +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 D787E1809563; Mon, 8 Jun 2020 15:06:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 058F6S1q004836 for ; Mon, 8 Jun 2020 11:06:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1449410013D4; Mon, 8 Jun 2020 15:06:28 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.5]) by smtp.corp.redhat.com (Postfix) with ESMTP id 87DF810013C1 for ; Mon, 8 Jun 2020 15:06:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591628823; 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=Px57Bu/MgJEI6dTHZQtPtdmJhndQwCK4ORuOwTYwJM0=; b=ZE6XjrBSvZgMMg/34a8jo/32xi0sswt5z8moFNaBEjKlLKNgcnGYJeBbkXRe+Gf4WF2EqB kjYQp9TcfLeg3LJwd4JF1OJR9NubuPiZ8MihcA37tSfrV70SsK5u1rGsYgmRf+qMQ7LKxM nDbhCxrD3x2SOrLjwJ36jSZHGQe9F3k= X-MC-Unique: 8HNR1fu6M2OxOX0Y11Jk-w-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 3/7] testSysinfo: Use more g_auto*() Date: Mon, 8 Jun 2020 17:06:17 +0200 Message-Id: <862d74e07847f9a9d63cf72b539ea0adcdd7777d.1591628594.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.11 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" Some variables defined in the function can be freed automatically when going out of scope. This renders @result variable and cleanup label needless. Signed-off-by: Michal Privoznik --- tests/sysinfotest.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/tests/sysinfotest.c b/tests/sysinfotest.c index a8a0d0869e..4807c5b1ba 100644 --- a/tests/sysinfotest.c +++ b/tests/sysinfotest.c @@ -47,34 +47,24 @@ struct testSysinfoData { static int testSysinfo(const void *data) { - int result =3D -1; const char *sysfsActualData; - virSysinfoDefPtr ret =3D NULL; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virSysinfoDefPtr) ret =3D NULL; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; const struct testSysinfoData *testdata =3D data; =20 virSysinfoSetup(testdata->decoder, testdata->sysinfo, testdata->cpuinf= o); =20 if (!testdata->expected || !(ret =3D testdata->func())) - goto cleanup; + return -1; =20 if (virSysinfoFormat(&buf, ret) < 0) - goto cleanup; + return -1; =20 if (!(sysfsActualData =3D virBufferCurrentContent(&buf))) - goto cleanup; + return -1; =20 - if (virTestCompareToFile(sysfsActualData, testdata->expected) < 0) - goto cleanup; - - result =3D 0; - - cleanup: - virSysinfoDefFree(ret); - virBufferFreeAndReset(&buf); - - return result; + return virTestCompareToFile(sysfsActualData, testdata->expected); } =20 static int --=20 2.26.2