From nobody Mon Feb 9 19:30:39 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1556180423; cv=none; d=zoho.com; s=zohoarc; b=jHG4IZ7KoX068j/M7YAiPv7DlGtv1t7lUr2L7VxRll3pJ12nYmrQWzArb0mymCnCQez2n4UKKtERiJ5/WDuWJH1o1gphL7Vv7ubDp2kNDMZ1HST3TosMrqaoctzsZ85OggSkXuEV6HFrFVUv9iOP0DMdov80KeHcEr7iBywC/Sw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556180423; 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:ARC-Authentication-Results; bh=Al3xxFSw3FkWJ7WefX2gGaGSQA7Sgajdb9Wj5dsMy4c=; b=eCVeCn8U7/Lz9/FKXs0bYAmMSLcnFx1LrQVHpQzuGPqFNRbWr9SCs70eNFjfwriOmgjsoUb7i13J/wZVyRA2qMwdNCXgqDK7AQNnH4H9w4jwQGEd5u4zdOH4TS0VB74L0d2z45wwYn97V4hYKfA9NJ8kzMYd4Iwy8ZodRHZyVNw= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1556180423217679.3970166027756; Thu, 25 Apr 2019 01:20:23 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 93E4B81254; Thu, 25 Apr 2019 08:20:21 +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 6024F5F9AC; Thu, 25 Apr 2019 08:20:21 +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 0E19E181B9EF; Thu, 25 Apr 2019 08:20:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x3P8KCs8013855 for ; Thu, 25 Apr 2019 04:20:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6125460C8E; Thu, 25 Apr 2019 08:20:12 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id DEE3C60BE5 for ; Thu, 25 Apr 2019 08:20:11 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 25 Apr 2019 10:19:42 +0200 Message-Id: <5dffaf34683c45678da27dd6f9a0b59aa13f7d71.1556179410.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v4 06/25] qemusecuritytest: Use AUTOFREE/AUTOUNREF 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 25 Apr 2019 08:20:22 +0000 (UTC) Content-Type: text/plain; charset="utf-8" This simplifies the code a bit and removes the need for cleanup label in one case. In the other case the label is kept because it's going to be used later. Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- tests/qemusecuritytest.c | 50 +++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 29 deletions(-) diff --git a/tests/qemusecuritytest.c b/tests/qemusecuritytest.c index 993b532329..e7121837a1 100644 --- a/tests/qemusecuritytest.c +++ b/tests/qemusecuritytest.c @@ -37,29 +37,29 @@ struct testData { static int prepareObjects(virQEMUDriverPtr driver, const char *xmlname, - virDomainObjPtr *vm) + virDomainObjPtr *vm_ret) { qemuDomainObjPrivatePtr priv; - char *filename =3D NULL; - char *domxml =3D NULL; - int ret =3D -1; + VIR_AUTOUNREF(virDomainObjPtr) vm =3D NULL; + VIR_AUTOFREE(char *) filename =3D NULL; + VIR_AUTOFREE(char *) domxml =3D NULL; =20 if (virAsprintf(&filename, "%s/qemuxml2argvdata/%s.xml", abs_srcdir, x= mlname) < 0) return -1; =20 if (virTestLoadFile(filename, &domxml) < 0) - goto cleanup; + return -1; =20 - if (!(*vm =3D virDomainObjNew(driver->xmlopt))) - goto cleanup; + if (!(vm =3D virDomainObjNew(driver->xmlopt))) + return -1; =20 - (*vm)->pid =3D -1; - priv =3D (*vm)->privateData; + vm->pid =3D -1; + priv =3D vm->privateData; priv->chardevStdioLogd =3D false; priv->rememberOwner =3D true; =20 if (!(priv->qemuCaps =3D virQEMUCapsNew())) - goto cleanup; + return -1; =20 virQEMUCapsSetList(priv->qemuCaps, QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, @@ -75,24 +75,17 @@ prepareObjects(virQEMUDriverPtr driver, QEMU_CAPS_LAST); =20 if (qemuTestCapsCacheInsert(driver->qemuCapsCache, priv->qemuCaps) < 0) - goto cleanup; + return -1; =20 - if (!((*vm)->def =3D virDomainDefParseString(domxml, - driver->caps, - driver->xmlopt, - NULL, - 0))) - goto cleanup; + if (!(vm->def =3D virDomainDefParseString(domxml, + driver->caps, + driver->xmlopt, + NULL, + 0))) + return -1; =20 - ret =3D 0; - cleanup: - if (ret < 0) { - virObjectUnref(*vm); - *vm =3D NULL; - } - VIR_FREE(domxml); - VIR_FREE(filename); - return ret; + VIR_STEAL_PTR(*vm_ret, vm); + return 0; } =20 =20 @@ -100,7 +93,7 @@ static int testDomain(const void *opaque) { const struct testData *data =3D opaque; - virDomainObjPtr vm =3D NULL; + VIR_AUTOUNREF(virDomainObjPtr) vm =3D NULL; int ret =3D -1; =20 if (prepareObjects(data->driver, data->file, &vm) < 0) @@ -109,7 +102,7 @@ testDomain(const void *opaque) /* Mocking is enabled only when this env variable is set. * See mock code for explanation. */ if (setenv(ENVVAR, "1", 0) < 0) - goto cleanup; + return -1; =20 if (qemuSecuritySetAllLabel(data->driver, vm, NULL) < 0) goto cleanup; @@ -122,7 +115,6 @@ testDomain(const void *opaque) ret =3D 0; cleanup: unsetenv(ENVVAR); - virObjectUnref(vm); freePaths(); return ret; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list