From nobody Fri Apr 19 10:44:51 2024 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=1560222231; cv=none; d=zoho.com; s=zohoarc; b=niTzwi95ob7J7IEoL7U4M3XP7YwQL9dLrESxWgCn2/nzA87YG8+c1y8+CUc6l9cmM50A+6n2QJHycgPJYepj25f4+3vENZ5BWTIQBl7HWGrnMfqU54conbWvQY+CXka6tmCBQg6PqgrcNzSp5BK4+/ZYBDnsWoy8xls0KxAYKA8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560222231; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=5sKYtXpOQUv2K2dvNWvGnscI4ZK+IMT0KfU43G5AbT8=; b=nAJEJ08BZj5O43v1o5hAyoqMSzrToG5Ajqi0/Uq5nYRSBKM6cVvXyOyYmdTEcDL6+zuHfA9T5/Ijm4QqmBBpWurCuvlVkZFH/M8Fq0gJrUnJfm3/Vp79esv8QD0ajO8NpSaEdXF2otENvH/8YnXj2hMXLBdj2rmXDZ4ct+L5pBg= 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 1560222231580221.4886850471089; Mon, 10 Jun 2019 20:03:51 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8CE6430BDE49; Tue, 11 Jun 2019 03:03:24 +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 8AAC210013D9; Tue, 11 Jun 2019 03:03:19 +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 E0F24206D1; Tue, 11 Jun 2019 03:03:14 +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 x5B338CC016405 for ; Mon, 10 Jun 2019 23:03:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9CEE15DD8C; Tue, 11 Jun 2019 03:03:08 +0000 (UTC) Received: from blue.redhat.com (ovpn-116-85.phx2.redhat.com [10.3.116.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4E07D5DD63; Tue, 11 Jun 2019 03:03:05 +0000 (UTC) From: Eric Blake To: libvir-list@redhat.com Date: Mon, 10 Jun 2019 22:03:05 -0500 Message-Id: <20190611030305.25141-1-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: pkrempa@redhat.com Subject: [libvirt] [RFC PATCH] qemumonitorjsontest: Use VIR_AUTOPTR for test cleanup 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.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Tue, 11 Jun 2019 03:03:48 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Everywhere else is switching, we might as well use it here, too. Signed-off-by: Eric Blake --- Partial patch - is it worth me continuing the cleanups on the rest of the file? --- tests/qemumonitortestutils.h | 3 +++ tests/qemumonitorjsontest.c | 35 +++++++++++++++-------------------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/tests/qemumonitortestutils.h b/tests/qemumonitortestutils.h index 8461c80caa..a2d2d30820 100644 --- a/tests/qemumonitortestutils.h +++ b/tests/qemumonitortestutils.h @@ -24,6 +24,7 @@ # include "qemu/qemu_conf.h" # include "qemu/qemu_monitor.h" # include "qemu/qemu_agent.h" +# include "virautoclean.h" typedef struct _qemuMonitorTest qemuMonitorTest; typedef qemuMonitorTest *qemuMonitorTestPtr; @@ -102,4 +103,6 @@ qemuMonitorPtr qemuMonitorTestGetMonitor(qemuMonitorTes= tPtr test); qemuAgentPtr qemuMonitorTestGetAgent(qemuMonitorTestPtr test); virDomainObjPtr qemuMonitorTestGetDomainObj(qemuMonitorTestPtr test); +VIR_DEFINE_AUTOPTR_FUNC(qemuMonitorTest, qemuMonitorTestFree); + #endif /* LIBVIRT_QEMUMONITORTESTUTILS_H */ diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index a7f64058d4..10bffce2a3 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -152,12 +152,11 @@ testQemuMonitorJSONGetStatus(const void *opaque) { const testGenericData *data =3D opaque; virDomainXMLOptionPtr xmlopt =3D data->xmlopt; - qemuMonitorTestPtr test =3D qemuMonitorTestNewSchema(xmlopt, data->sch= ema); - int ret =3D -1; + VIR_AUTOPTR(qemuMonitorTest) test =3D NULL; bool running =3D false; virDomainPausedReason reason =3D 0; - if (!test) + if (!(test =3D qemuMonitorTestNewSchema(xmlopt, data->schema))) return -1; if (qemuMonitorTestAddItem(test, "query-status", @@ -168,7 +167,7 @@ testQemuMonitorJSONGetStatus(const void *opaque) " \"running\": true " " } " "}") < 0) - goto cleanup; + return -1; if (qemuMonitorTestAddItem(test, "query-status", "{ " " \"return\": { " @@ -176,7 +175,7 @@ testQemuMonitorJSONGetStatus(const void *opaque) " \"running\": false " " } " "}") < 0) - goto cleanup; + return -1; if (qemuMonitorTestAddItem(test, "query-status", "{ " " \"return\": { " @@ -185,61 +184,57 @@ testQemuMonitorJSONGetStatus(const void *opaque) " \"running\": false " " } " "}") < 0) - goto cleanup; + return -1; if (qemuMonitorGetStatus(qemuMonitorTestGetMonitor(test), &running, &reason) < 0) - goto cleanup; + return -1; if (!running) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", "Running was not true"); - goto cleanup; + return -1; } if (reason !=3D VIR_DOMAIN_PAUSED_UNKNOWN) { virReportError(VIR_ERR_INTERNAL_ERROR, "Reason was unexpectedly set to %d", reason); - goto cleanup; + return -1; } if (qemuMonitorGetStatus(qemuMonitorTestGetMonitor(test), &running, &reason) < 0) - goto cleanup; + return -1; if (running) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", "Running was not false"); - goto cleanup; + return -1; } if (reason !=3D VIR_DOMAIN_PAUSED_UNKNOWN) { virReportError(VIR_ERR_INTERNAL_ERROR, "Reason was unexpectedly set to %d", reason); - goto cleanup; + return -1; } if (qemuMonitorGetStatus(qemuMonitorTestGetMonitor(test), &running, &reason) < 0) - goto cleanup; + return -1; if (running) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", "Running was not false"); - goto cleanup; + return -1; } if (reason !=3D VIR_DOMAIN_PAUSED_MIGRATION) { virReportError(VIR_ERR_INTERNAL_ERROR, "Reason was unexpectedly set to %d", reason); - goto cleanup; + return -1; } - ret =3D 0; - - cleanup: - qemuMonitorTestFree(test); - return ret; + return 0; } static int --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list