From nobody Sun Feb 8 21:48:35 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=1629471005; cv=none; d=zohomail.com; s=zohoarc; b=OgRPX7DT0OtEqCCkOKgP8PFjW9e/A39DSj2xgz89CIjh1W/bWnwz5YCUCHU0Pfdn/2zrIHuKD3WoFZhoWb4DcHqhGiX5BJY8aufX1RrY2y0EgkwxxOR29qFs+8M01YkYDXJfpB/2jFoO/BCi5jhIsXTG/qaY8BQTTxotZCLQYOo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629471005; 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=ISNGZj/NHYizBB0uyj6AGuw0RuxemAm/3S9T8TeRTPU=; b=Gi0mTfeAtBhtWlUYdA/JK1J0P+9wDxrZkQ5LBq6OMRMK/4X9Pe1Z42atuCfMu3MS2Mmy8ERIv9wNI1iCtAD60czlpGz5wCj4JvUxzuj5novdkmAGgT01/hy1a5KDhHaT1NkXlF20UGSQ+WB/kRrEeMQQOAd5ojmnikdSKMtsRto= 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 1629471005060836.7583880717482; Fri, 20 Aug 2021 07:50: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-14-hG3FHaMiOyGWllgAd7ZnCA-1; Fri, 20 Aug 2021 10:49:28 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1AA121B2C987; Fri, 20 Aug 2021 14:49:21 +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 E3653E2FC; Fri, 20 Aug 2021 14:49:20 +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 AD7834A704; Fri, 20 Aug 2021 14:49:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17KEn3Ck025548 for ; Fri, 20 Aug 2021 10:49:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7B5026A8F7; Fri, 20 Aug 2021 14:49:03 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 048DA5D741 for ; Fri, 20 Aug 2021 14:49:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629471004; 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=ISNGZj/NHYizBB0uyj6AGuw0RuxemAm/3S9T8TeRTPU=; b=UWJUp+jjgdAwfsG70TAVOKUxofs6fpQuAF2fYNR42SXkoeCD4mJU4ezKG8ZVprF3P1bLV8 52ryzpxvM3byD8WuzSX/NCEGsGMu6Rx/72Dso0J35F8Afauy5wYlnSjuQopYx7Lo6HEAWq 23GWRosQ/GT7VMbhXQa96SdvZo1SpPA= X-MC-Unique: hG3FHaMiOyGWllgAd7ZnCA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 6/9] tests: cputest: use g_autofree Date: Fri, 20 Aug 2021 16:48:48 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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.84 on 10.5.11.23 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: 1629471128381100001 Signed-off-by: J=C3=A1n Tomko --- tests/cputest.c | 58 ++++++++++++++++--------------------------------- 1 file changed, 19 insertions(+), 39 deletions(-) diff --git a/tests/cputest.c b/tests/cputest.c index 9fd5b38b78..2dc7e2e5ae 100644 --- a/tests/cputest.c +++ b/tests/cputest.c @@ -138,8 +138,8 @@ cpuTestCompareXML(virArch arch, virCPUDef *cpu, const char *name) { - char *xml =3D NULL; - char *actual =3D NULL; + g_autofree char *xml =3D NULL; + g_autofree char *actual =3D NULL; int ret =3D -1; =20 xml =3D g_strdup_printf("%s/cputestdata/%s-%s.xml", abs_srcdir, @@ -154,8 +154,6 @@ cpuTestCompareXML(virArch arch, ret =3D 0; =20 cleanup: - VIR_FREE(xml); - VIR_FREE(actual); return ret; } =20 @@ -230,7 +228,7 @@ cpuTestGuestCPU(const void *arg) g_autoptr(virCPUDef) cpu =3D NULL; virCPUCompareResult cmpResult; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; - char *result =3D NULL; + g_autofree char *result =3D NULL; =20 if (!(host =3D cpuTestLoadXML(data->arch, data->host)) || !(cpu =3D cpuTestLoadXML(data->arch, data->name))) @@ -265,8 +263,6 @@ cpuTestGuestCPU(const void *arg) ret =3D 0; =20 cleanup: - VIR_FREE(result); - if (ret =3D=3D data->result) { /* We got the result we expected, whether it was * a success or a failure */ @@ -292,7 +288,7 @@ cpuTestBaseline(const void *arg) virCPUDef **cpus =3D NULL; virCPUDef *baseline =3D NULL; unsigned int ncpus =3D 0; - char *result =3D NULL; + g_autofree char *result =3D NULL; const char *suffix; size_t i; =20 @@ -356,7 +352,6 @@ cpuTestBaseline(const void *arg) VIR_FREE(cpus); } virCPUDefFree(baseline); - VIR_FREE(result); return ret; } =20 @@ -369,7 +364,7 @@ cpuTestUpdate(const void *arg) g_autoptr(virCPUDef) host =3D NULL; g_autoptr(virCPUDef) migHost =3D NULL; g_autoptr(virCPUDef) cpu =3D NULL; - char *result =3D NULL; + g_autofree char *result =3D NULL; =20 if (!(host =3D cpuTestLoadXML(data->arch, data->host)) || !(cpu =3D cpuTestLoadXML(data->arch, data->name))) @@ -386,7 +381,6 @@ cpuTestUpdate(const void *arg) ret =3D cpuTestCompareXML(data->arch, cpu, result); =20 cleanup: - VIR_FREE(result); return ret; } =20 @@ -544,10 +538,10 @@ cpuTestCPUID(bool guest, const void *arg) const struct data *data =3D arg; int ret =3D -1; g_autoptr(virCPUData) hostData =3D NULL; - char *hostFile =3D NULL; - char *host =3D NULL; + g_autofree char *hostFile =3D NULL; + g_autofree char *host =3D NULL; g_autoptr(virCPUDef) cpu =3D NULL; - char *result =3D NULL; + g_autofree char *result =3D NULL; virDomainCapsCPUModels *models =3D NULL; =20 hostFile =3D g_strdup_printf("%s/cputestdata/%s-cpuid-%s.xml", abs_src= dir, @@ -585,9 +579,6 @@ cpuTestCPUID(bool guest, const void *arg) ret =3D cpuTestCompareXML(data->arch, cpu, result); =20 cleanup: - VIR_FREE(hostFile); - VIR_FREE(host); - VIR_FREE(result); virObjectUnref(models); return ret; } @@ -636,8 +627,8 @@ cpuTestCPUIDSignature(const void *arg) { const struct data *data =3D arg; g_autoptr(virCPUData) hostData =3D NULL; - char *hostFile =3D NULL; - char *host =3D NULL; + g_autofree char *hostFile =3D NULL; + g_autofree char *host =3D NULL; int ret =3D -1; =20 hostFile =3D g_strdup_printf("%s/cputestdata/%s-cpuid-%s.xml", abs_src= dir, @@ -650,8 +641,6 @@ cpuTestCPUIDSignature(const void *arg) ret =3D cpuTestCompareSignature(data, hostData); =20 cleanup: - VIR_FREE(hostFile); - VIR_FREE(host); return ret; } =20 @@ -749,15 +738,15 @@ static int cpuTestUpdateLive(const void *arg) { const struct data *data =3D arg; - char *cpuFile =3D NULL; + g_autofree char *cpuFile =3D NULL; g_autoptr(virCPUDef) cpu =3D NULL; - char *enabledFile =3D NULL; - char *enabled =3D NULL; + g_autofree char *enabledFile =3D NULL; + g_autofree char *enabled =3D NULL; g_autoptr(virCPUData) enabledData =3D NULL; - char *disabledFile =3D NULL; - char *disabled =3D NULL; + g_autofree char *disabledFile =3D NULL; + g_autofree char *disabled =3D NULL; g_autoptr(virCPUData) disabledData =3D NULL; - char *expectedFile =3D NULL; + g_autofree char *expectedFile =3D NULL; g_autoptr(virCPUDef) expected =3D NULL; virDomainCapsCPUModels *hvModels =3D NULL; virDomainCapsCPUModels *models =3D NULL; @@ -826,12 +815,6 @@ cpuTestUpdateLive(const void *arg) ret =3D cpuTestUpdateLiveCompare(data->arch, cpu, expected); =20 cleanup: - VIR_FREE(cpuFile); - VIR_FREE(enabledFile); - VIR_FREE(enabled); - VIR_FREE(disabledFile); - VIR_FREE(disabled); - VIR_FREE(expectedFile); virObjectUnref(hvModels); virObjectUnref(models); return ret; @@ -845,7 +828,7 @@ cpuTestJSONCPUID(const void *arg) const struct data *data =3D arg; g_autoptr(virQEMUCaps) qemuCaps =3D NULL; g_autoptr(virCPUDef) cpu =3D NULL; - char *result =3D NULL; + g_autofree char *result =3D NULL; int ret =3D -1; =20 result =3D g_strdup_printf("cpuid-%s-json", data->host); @@ -865,7 +848,6 @@ cpuTestJSONCPUID(const void *arg) ret =3D cpuTestCompareXML(data->arch, cpu, result); =20 cleanup: - VIR_FREE(result); return ret; } =20 @@ -957,7 +939,7 @@ mymain(void) models =3D=3D NULL ? NULL : #models, \ flags, result \ }; \ - char *testLabel; \ + g_autofree char *testLabel =3D NULL; \ \ g_free(virTestLogContentAndReset());\ \ @@ -975,7 +957,6 @@ mymain(void) ret =3D -1; \ } \ \ - VIR_FREE(testLabel); \ } while (0) =20 #define DO_TEST_COMPARE(arch, host, cpu, result) \ @@ -997,7 +978,7 @@ mymain(void) #define DO_TEST_BASELINE(arch, name, flags, result) \ do { \ const char *suffix =3D ""; \ - char *label; \ + g_autofree char *label =3D NULL; \ if ((flags) & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) \ suffix =3D " (expanded)"; \ if ((flags) & VIR_CONNECT_BASELINE_CPU_MIGRATABLE) \ @@ -1005,7 +986,6 @@ mymain(void) label =3D g_strdup_printf("%s%s", name, suffix); \ DO_TEST(arch, cpuTestBaseline, label, NULL, \ "baseline-" name, NULL, flags, result); \ - VIR_FREE(label); \ } while (0) =20 #define DO_TEST_HASFEATURE(arch, host, feature, result) \ --=20 2.31.1