From nobody Sun Feb 8 21:06:44 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1630788686; cv=none; d=zohomail.com; s=zohoarc; b=P/ivJv5pFLWM5hmxmtbHH/KaF0CJ6iBqjrKBbeQ8DmrGjZsthnqOAIyuh1weeGS/WGS9Mav34kp4DbrvD6p8NTW5P8lT9yUTgjhEcnhXJlQxos8qZx+HO2d9iXHC0c7E/zorrc1sNuMZWQL18teYwMpSoK53gCGpRZm9CLjNkz4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630788686; 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=3j5W/KPj7Pk4umQsrZddmqxJe6xAYOw4ZXVGN4ummCs=; b=YhrUehWtXzGAmXhSS5Xa+286XFFio1pNglMpnFWGtckMqwAMNZ5MAEEMG/Xdo1pmknQRm7JiZn+M3Yi7i/tIjqLBdrOZeWh/p/0ZyUNqIzcSuYVmcwilBI9aWoanotfTIWBmXNU3hQLHDA26S2SQ8TGrarmqWPpefXpbP3zkq6s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1630788686951207.09676449099481; Sat, 4 Sep 2021 13:51:26 -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-153-mT7xa4x7O0a87HDSlcFRag-1; Sat, 04 Sep 2021 16:51:24 -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 495D5824FAA; Sat, 4 Sep 2021 20:51:18 +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 2CDEB18432; Sat, 4 Sep 2021 20:51:18 +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 F34A41800B9C; Sat, 4 Sep 2021 20:51:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 184KiVNT008749 for ; Sat, 4 Sep 2021 16:44:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id CDD322619D; Sat, 4 Sep 2021 20:44:31 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 578701F4 for ; Sat, 4 Sep 2021 20:44:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630788685; 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=3j5W/KPj7Pk4umQsrZddmqxJe6xAYOw4ZXVGN4ummCs=; b=Wztvj8fiQDld1uV8YsIkZZrwBICkaKAbMbSBxpPqZvo2kEEwCqekP6EuTOer6GEYqlzntj l7akeYY2tqmXIojnfbIfzn0e4jlXKyNiahhOL4KVUo3U6+qva0YbIWh/1nAx4K7mHpWe6z PjqcJuez7Y9Xreccr71aPU8T+hWGjNU= X-MC-Unique: mT7xa4x7O0a87HDSlcFRag-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 05/24] tests: qemu: use g_autofree Date: Sat, 4 Sep 2021 22:44:03 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1630788688890100001 Signed-off-by: J=C3=A1n Tomko --- tests/qemucapsprobemock.c | 6 ++--- tests/qemucommandutiltest.c | 3 +-- tests/qemumonitorjsontest.c | 48 +++++++++++++------------------------ tests/qemuxml2argvtest.c | 3 +-- 4 files changed, 20 insertions(+), 40 deletions(-) diff --git a/tests/qemucapsprobemock.c b/tests/qemucapsprobemock.c index 3c05a80ca2..00670101ce 100644 --- a/tests/qemucapsprobemock.c +++ b/tests/qemucapsprobemock.c @@ -58,7 +58,7 @@ int qemuMonitorSend(qemuMonitor *mon, qemuMonitorMessage *msg) { - char *reformatted; + g_autofree char *reformatted =3D NULL; =20 REAL_SYM(realQemuMonitorSend); =20 @@ -73,7 +73,6 @@ qemuMonitorSend(qemuMonitor *mon, printLineSkipEmpty("\n", stdout); =20 printLineSkipEmpty(reformatted, stdout); - VIR_FREE(reformatted); =20 return realQemuMonitorSend(mon, msg); } @@ -89,7 +88,7 @@ qemuMonitorJSONIOProcessLine(qemuMonitor *mon, qemuMonitorMessage *msg) { virJSONValue *value =3D NULL; - char *json =3D NULL; + g_autofree char *json =3D NULL; int ret; =20 REAL_SYM(realQemuMonitorJSONIOProcessLine); @@ -116,7 +115,6 @@ qemuMonitorJSONIOProcessLine(qemuMonitor *mon, } =20 cleanup: - VIR_FREE(json); virJSONValueFree(value); return ret; } diff --git a/tests/qemucommandutiltest.c b/tests/qemucommandutiltest.c index 33f92d2935..6b5e477849 100644 --- a/tests/qemucommandutiltest.c +++ b/tests/qemucommandutiltest.c @@ -39,7 +39,7 @@ testQemuCommandBuildFromJSON(const void *opaque) const testQemuCommandBuildObjectFromJSONData *data =3D opaque; virJSONValue *val =3D NULL; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; - char *result =3D NULL; + g_autofree char *result =3D NULL; int ret =3D -1; =20 if (!(val =3D virJSONValueFromString(data->props))) { @@ -66,7 +66,6 @@ testQemuCommandBuildFromJSON(const void *opaque) ret =3D 0; cleanup: virJSONValueFree(val); - VIR_FREE(result); return ret; } =20 diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index 9ec5f06981..c64c5c6b6f 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -650,8 +650,8 @@ qemuMonitorJSONTestAttachOneChardev(virDomainXMLOption = *xmlopt, =20 { struct qemuMonitorJSONTestAttachChardevData data =3D {0}; - char *jsonreply =3D NULL; - char *fulllabel =3D NULL; + g_autofree char *jsonreply =3D NULL; + g_autofree char *fulllabel =3D NULL; int ret =3D -1; =20 if (!reply) @@ -680,8 +680,6 @@ qemuMonitorJSONTestAttachOneChardev(virDomainXMLOption = *xmlopt, =20 cleanup: qemuMonitorTestFree(data.test); - VIR_FREE(jsonreply); - VIR_FREE(fulllabel); return ret; } =20 @@ -1723,7 +1721,7 @@ testQemuMonitorJSONqemuMonitorJSONGetMigrationStats(c= onst void *opaque) virDomainXMLOption *xmlopt =3D data->xmlopt; int ret =3D -1; qemuMonitorMigrationStats stats, expectedStats; - char *error =3D NULL; + g_autofree char *error =3D NULL; g_autoptr(qemuMonitorTest) test =3D NULL; =20 if (!(test =3D qemuMonitorTestNewSchema(xmlopt, data->schema))) @@ -1784,7 +1782,6 @@ testQemuMonitorJSONqemuMonitorJSONGetMigrationStats(c= onst void *opaque) =20 ret =3D 0; cleanup: - VIR_FREE(error); return ret; } =20 @@ -2162,10 +2159,10 @@ testQemuMonitorJSONGetCPUData(const void *opaque) { const struct testCPUData *data =3D opaque; virCPUData *cpuData =3D NULL; - char *jsonFile =3D NULL; - char *dataFile =3D NULL; - char *jsonStr =3D NULL; - char *actual =3D NULL; + g_autofree char *jsonFile =3D NULL; + g_autofree char *dataFile =3D NULL; + g_autofree char *jsonStr =3D NULL; + g_autofree char *actual =3D NULL; int ret =3D -1; g_autoptr(qemuMonitorTest) test =3D NULL; =20 @@ -2211,10 +2208,6 @@ testQemuMonitorJSONGetCPUData(const void *opaque) =20 ret =3D 0; cleanup: - VIR_FREE(jsonFile); - VIR_FREE(dataFile); - VIR_FREE(jsonStr); - VIR_FREE(actual); virCPUDataFree(cpuData); return ret; } @@ -2409,12 +2402,12 @@ testQemuMonitorCPUInfo(const void *opaque) { const struct testCPUInfoData *data =3D opaque; virDomainObj *vm =3D NULL; - char *queryCpusFile =3D NULL; - char *queryHotpluggableFile =3D NULL; - char *dataFile =3D NULL; - char *queryCpusStr =3D NULL; - char *queryHotpluggableStr =3D NULL; - char *actual =3D NULL; + g_autofree char *queryCpusFile =3D NULL; + g_autofree char *queryHotpluggableFile =3D NULL; + g_autofree char *dataFile =3D NULL; + g_autofree char *queryCpusStr =3D NULL; + g_autofree char *queryHotpluggableStr =3D NULL; + g_autofree char *actual =3D NULL; const char *queryCpusFunction; qemuMonitorCPUInfo *vcpus =3D NULL; int rc; @@ -2468,12 +2461,6 @@ testQemuMonitorCPUInfo(const void *opaque) =20 ret =3D 0; cleanup: - VIR_FREE(queryCpusFile); - VIR_FREE(queryHotpluggableFile); - VIR_FREE(dataFile); - VIR_FREE(queryCpusStr); - VIR_FREE(queryHotpluggableStr); - VIR_FREE(actual); qemuMonitorCPUInfoFree(vcpus, data->maxvcpus); return ret; } @@ -2518,8 +2505,8 @@ testBlockNodeNameDetect(const void *opaque) { const char *testname =3D opaque; const char *pathprefix =3D "qemumonitorjsondata/qemumonitorjson-nodena= me-"; - char *resultFile =3D NULL; - char *actual =3D NULL; + g_autofree char *resultFile =3D NULL; + g_autofree char *actual =3D NULL; virJSONValue *namedNodesJson =3D NULL; virJSONValue *blockstatsJson =3D NULL; GHashTable *nodedata =3D NULL; @@ -2553,8 +2540,6 @@ testBlockNodeNameDetect(const void *opaque) ret =3D 0; =20 cleanup: - VIR_FREE(resultFile); - VIR_FREE(actual); virHashFree(nodedata); virJSONValueFree(namedNodesJson); virJSONValueFree(blockstatsJson); @@ -2943,7 +2928,7 @@ mymain(void) testQemuMonitorJSONSimpleFuncData simpleFunc; struct testQAPISchemaData qapiData; virJSONValue *metaschema =3D NULL; - char *metaschemastr =3D NULL; + g_autofree char *metaschemastr =3D NULL; =20 if (qemuTestDriverInit(&driver) < 0) return EXIT_FAILURE; @@ -3235,7 +3220,6 @@ mymain(void) DO_TEST(qemuMonitorJSONGetCPUModelBaseline); =20 cleanup: - VIR_FREE(metaschemastr); virJSONValueFree(metaschema); virHashFree(qapiData.schema); qemuTestDriverFree(&driver); diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 3b331d5fd4..90b7da8055 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -643,7 +643,7 @@ testCompareXMLToArgv(const void *data) virDomainChrSourceDef monitor_chr; g_autoptr(virConnect) conn =3D NULL; virError *err =3D NULL; - char *log =3D NULL; + g_autofree char *log =3D NULL; g_autoptr(virCommand) cmd =3D NULL; qemuDomainObjPrivate *priv =3D NULL; g_autoptr(xmlDoc) xml =3D NULL; @@ -815,7 +815,6 @@ testCompareXMLToArgv(const void *data) ret =3D 0; =20 cleanup: - VIR_FREE(log); virDomainChrSourceDefClear(&monitor_chr); virObjectUnref(vm); virIdentitySetCurrent(NULL); --=20 2.31.1