From nobody Fri May 3 12:48:53 2024 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=1630788407; cv=none; d=zohomail.com; s=zohoarc; b=RFSvhYouA7o6BxnWeyQWvRtcrjibsnAe/jxDDPKn3isR4rATAvzG2G5r20PkddAze51rPfpqzSGMcaY5MeXCkncsnu4s3SJXMrkiCQs3pASJ0WH2raWk119cKPXZynBqV8xt3sfLuhFZPgpocZRlGKbAZmawKY9MW/EOabQCY5Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630788407; 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=4HeVOgVs/zteCb9harNnQBpYIVFRvKc7TqIixqGOXpw=; b=LfsLuodby/ugkhNh99yYkncOyvigfLFQkO6wyFW1JrzVrsPswVoIXCNH/jLbuZo4ohUN7q1+s1pAKcEbGIEN5LKfrHtve48KjuKPpinaAgWEGaD78jtvmVKERU0ZJ03vHUEBCgk2xBQ+BX5V1sA3oXSgp3jWwkgg//Pmx6tR0I4= 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 1630788407951454.35903605658063; Sat, 4 Sep 2021 13:46:47 -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-571-4SWBY1UaOSKdFEDg5gHrBg-1; Sat, 04 Sep 2021 16:46:45 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3FE8A107ACCD; Sat, 4 Sep 2021 20:46:40 +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 ECA206091B; Sat, 4 Sep 2021 20:46:39 +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 7F3704EA62; Sat, 4 Sep 2021 20:46:39 +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 184KiS8k008713 for ; Sat, 4 Sep 2021 16:44:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id 98D9B2619D; Sat, 4 Sep 2021 20:44:28 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 22B331F4 for ; Sat, 4 Sep 2021 20:44:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630788406; 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=4HeVOgVs/zteCb9harNnQBpYIVFRvKc7TqIixqGOXpw=; b=hGGynJHWz3Wy5Vq2gLOGGC7Ouy8534Dabdm+Iaahzb/F9Lc3XMTN6dPNQozdDrh9j4x6Zt Ry7kH/IPxvAaujnsSvFTI/3QDefLnYXjSTY1ulSMknwlxID4JUi+shZK2934Y4yP8RLOId K4/O/beBBzm3MfMtt0Wa2o9+HaSsGJU= X-MC-Unique: 4SWBY1UaOSKdFEDg5gHrBg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 01/24] tests: virnetdaemontest: split variable declarations Date: Sat, 4 Sep 2021 22:43:59 +0200 Message-Id: <8b081195108c0c41b6c7a363b71cb1c9bc711092.1630788206.git.jtomko@redhat.com> 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.13 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: 1630788408276100001 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Laine Stump --- tests/virnetdaemontest.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/virnetdaemontest.c b/tests/virnetdaemontest.c index ce0384f026..f764268c50 100644 --- a/tests/virnetdaemontest.c +++ b/tests/virnetdaemontest.c @@ -270,8 +270,10 @@ static int testExecRestart(const void *opaque) int ret =3D -1; virNetDaemon *dmn =3D NULL; const struct testExecRestartData *data =3D opaque; - char *infile =3D NULL, *outfile =3D NULL; - char *injsonstr =3D NULL, *outjsonstr =3D NULL; + char *infile =3D NULL; + char *outfile =3D NULL; + char *injsonstr =3D NULL; + char *outjsonstr =3D NULL; virJSONValue *injson =3D NULL; virJSONValue *outjson =3D NULL; int fdclient[2] =3D { -1, -1 }, fdserver[2] =3D { -1, -1 }; --=20 2.31.1 From nobody Fri May 3 12:48:53 2024 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=1630788412; cv=none; d=zohomail.com; s=zohoarc; b=YUefnrJ1C6vvL2GxJH2sj2GxY6VK2qjlfPBdmbCBPVBQu3G6BZYaW5SwBLcemS28vZRZ41NCnbB9BdHPtZ6DYWo5El0eOy+qhZyNSt7s5yWpNYJkf5CHafEicKHPpbMHVQ5qXXQGdjwf83aeYpHTUJabgwwhS7Mdr51JszXM9/g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630788412; 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=Ksbm47KTR6/+lhDM/0N9XCw1NsqAAD4JCdt+wBxsf8Q=; b=NZNmHFDfuh/jNCRnRK4tOI3/Nn6CjeyB501tNMh0fzcWNzjsWstHGEXo9l47yWhQa7V7jNS6k/HmZMjE19FJF4wP6EUDHMqHn2UeXmZW/ET6bSj2rjVpoEQuqp/COtFAevZAKxPfAT+TQDM/IK8SqwHbPLiADl9HuQMEw+Dm25A= 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 1630788412302483.3664870107127; Sat, 4 Sep 2021 13:46:52 -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-45-qLM0PPU9PmiQAXW6X--wJA-1; Sat, 04 Sep 2021 16:46:49 -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 B508D107ACE8; Sat, 4 Sep 2021 20:46:44 +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 E07006B543; Sat, 4 Sep 2021 20:46:43 +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 89D2544A59; Sat, 4 Sep 2021 20:46:43 +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 184KiT2u008725 for ; Sat, 4 Sep 2021 16:44:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id 68B822619D; Sat, 4 Sep 2021 20:44:29 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id E6AE81F4 for ; Sat, 4 Sep 2021 20:44:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630788411; 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=Ksbm47KTR6/+lhDM/0N9XCw1NsqAAD4JCdt+wBxsf8Q=; b=OKqph4M+3klLT8vLL00PmWNwB+QJVybhT1ce04pb1joIvLwvvqyW6uKQQZFwXNjp+k443n 2WSHSLZ/PzCOPY7jbss9o4Qy96wtnRO2FgmA9V499XqouUMlcyiHu+yG/GHVyShsWl03us KM0Qrxl+Pkl0Fqh0jOHzobxAuD1i+TY= X-MC-Unique: qLM0PPU9PmiQAXW6X--wJA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 02/24] conf: add cleanup func for virNetworkXMLOption Date: Sat, 4 Sep 2021 22:44:00 +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: 1630788414481100001 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Laine Stump --- src/conf/network_conf.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h index 34007e1969..30958eff64 100644 --- a/src/conf/network_conf.h +++ b/src/conf/network_conf.h @@ -44,6 +44,7 @@ struct _virNetworkXMLOption { virXMLNamespace ns; }; typedef struct _virNetworkXMLOption virNetworkXMLOption; +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virNetworkXMLOption, virObjectUnref); =20 =20 typedef enum { --=20 2.31.1 From nobody Fri May 3 12:48:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1630789637; cv=none; d=zohomail.com; s=zohoarc; b=JMz9V7TYaZHgtzo6Pqtj69EgLB+sZ0aKL1+q5qu7/JCJlei9jJ2gJaIo2CtLkXZ7cwKQ5zvVP7L3QPCOYv6su2fkU4YEUZpeN7DqBQ9uQde0djRPWI6QurzhFCnOCqko5PI6q07kQ1t8tnF+T/BMep7XSJghc2cA2roCDJDL+pM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630789637; 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=fsthk3CgHLmNYT6gcrOIGpYbEW1LLI13Ddg+4Dlh7L8=; b=O1NovgHS5NyTxgVo0SFifDCJ9T3AODwohyvukH8MWso7GiOuhIgnWipj4KpXxhhBhcMgqXzHFktiOCdnGgabOMdAlgN7YSg9Smfhf+DA4FM8k03G/qRgpKjqpVVgXcLgICqmkQ78k3bbITeQPsMktUm82S3W0XhSOZmAe5Y+xKE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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 [170.10.133.124]) by mx.zohomail.com with SMTPS id 163078963752673.78292836261949; Sat, 4 Sep 2021 14:07:17 -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-276-x0LpOsxHMCmHEmOq_YIbxw-1; Sat, 04 Sep 2021 17:07:14 -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 BA63C801AC5; Sat, 4 Sep 2021 21:07:09 +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 0508669FC9; Sat, 4 Sep 2021 21:07:09 +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 084D24ED4D; Sat, 4 Sep 2021 21:07:08 +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 184KiUnK008734 for ; Sat, 4 Sep 2021 16:44:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3864A1F4; Sat, 4 Sep 2021 20:44:30 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id B62F726367 for ; Sat, 4 Sep 2021 20:44:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630789636; 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=fsthk3CgHLmNYT6gcrOIGpYbEW1LLI13Ddg+4Dlh7L8=; b=LtZt3p0tv1Osj5q+DZW5t3r/phaKUYK3+PAYed8gFOfUViHTQ08SvWvRlc5Qs4CNEuZsUb mVWXfpplKYthDs/nhelPnX1Ym0VVmOJ8FqFLkSpr3rL5j71r1AGPD2gQInI+lMvp+s6p4I EpLJMS8Hj3Gwji2wdSAbZ+/rU4zPFY8= X-MC-Unique: x0LpOsxHMCmHEmOq_YIbxw-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 03/24] conf: add cleanup func for virMacMap Date: Sat, 4 Sep 2021 22:44:01 +0200 Message-Id: <7a66725ea0a3ab74ec2f0b26487a4535a83de3df.1630788206.git.jtomko@redhat.com> 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.11 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: 1630789639934100001 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Laine Stump --- src/util/virmacmap.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/util/virmacmap.h b/src/util/virmacmap.h index 582c4a8bdf..c0efa2b20f 100644 --- a/src/util/virmacmap.h +++ b/src/util/virmacmap.h @@ -21,8 +21,10 @@ #pragma once =20 #include "internal.h" +#include "virobject.h" =20 typedef struct virMacMap virMacMap; +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virMacMap, virObjectUnref) =20 char * virMacMapFileName(const char *dnsmasqStateDir, --=20 2.31.1 From nobody Fri May 3 12:48:53 2024 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=1630788681; cv=none; d=zohomail.com; s=zohoarc; b=I52xi9LGQpjgzwpfB3qs3lFG9xtN0so4hYdIEmNWWFFAyBtx5nxlcteCqqWDhcw3RoghhSnqi+FD2exSFsN9QNBtADRwUo+uqapkTXBAfjV8whmFWwL2EzkKMhmFFGRFzezAtuOVwEBYESZt0q7mymFGV84VEe0ShjJRXOYJWKw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630788681; 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=Aa+nO9dwJ4pE6DzCQF4SDs3TzgBl9L9zmaC5tQuW7nM=; b=Z0VH0vN+v1YMYDc1GNcnCmVFOtPaGrHWHkGtgeqfKus7/ZGvTuO/EkaOKNLT7hB25aBlS4NsYRpbvp31QnUHzz0uFe20BDUJTjcni7Jn0n9NPbrU9n4NRhsgT4bT1T6HPdT8D5v+gCWg5gFpqamrlyiqVZ+bG9tzfFPzrrVWJMQ= 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 1630788681889349.2909352763694; Sat, 4 Sep 2021 13:51:21 -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-593-tuIyovtuOO2B1b91_W-wUg-1; Sat, 04 Sep 2021 16:51:19 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 44874824FAE; Sat, 4 Sep 2021 20:51:14 +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 2A98177BF1; Sat, 4 Sep 2021 20:51:14 +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 E7DD31809C98; Sat, 4 Sep 2021 20:51:13 +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 184KiV70008744 for ; Sat, 4 Sep 2021 16:44:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id 088F32619D; 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 865CE1F4 for ; Sat, 4 Sep 2021 20:44:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630788680; 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=Aa+nO9dwJ4pE6DzCQF4SDs3TzgBl9L9zmaC5tQuW7nM=; b=T/tpmNiV12lj6F5xf18dO+9m5JLx7rsVKirt8fcvdAbiwHzrgepPohMNUXD4Q7ucayTE/c 6zTIqF/PRj67hURl52KsNakJzciLh9Ke9XR1q7hK4vypOArzWGwpvvBx/iFCphvF1m7y4L aunnOYdYhujwhEIo32ZU8rK5vRfMzDI= X-MC-Unique: tuIyovtuOO2B1b91_W-wUg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 04/24] tests: use g_autoptr instead of virObjectUnref Date: Sat, 4 Sep 2021 22:44:02 +0200 Message-Id: <88fe3b8a51bfaf8164f80de89b07eff8bd309af4.1630788206.git.jtomko@redhat.com> 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.13 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: 1630788682796100001 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Laine Stump --- tests/cputest.c | 9 +++------ tests/domaincapstest.c | 6 ++---- tests/networkxml2conftest.c | 3 +-- tests/networkxml2xmltest.c | 3 +-- tests/vircapstest.c | 6 ++---- tests/virmacmaptest.c | 6 ++---- tests/virpcitest.c | 18 ++++++------------ tests/virresctrltest.c | 6 ++---- tests/virscsitest.c | 3 +-- tests/virusbtest.c | 3 +-- tests/xlconfigtest.c | 6 ++---- tests/xmconfigtest.c | 3 +-- 12 files changed, 24 insertions(+), 48 deletions(-) diff --git a/tests/cputest.c b/tests/cputest.c index 3e99b9486b..11305d56c5 100644 --- a/tests/cputest.c +++ b/tests/cputest.c @@ -526,7 +526,7 @@ cpuTestCPUID(bool guest, const void *arg) g_autofree char *host =3D NULL; g_autoptr(virCPUDef) cpu =3D NULL; g_autofree char *result =3D NULL; - virDomainCapsCPUModels *models =3D NULL; + g_autoptr(virDomainCapsCPUModels) models =3D NULL; =20 hostFile =3D g_strdup_printf("%s/cputestdata/%s-cpuid-%s.xml", abs_src= dir, virArchToString(data->arch), data->host); @@ -563,7 +563,6 @@ cpuTestCPUID(bool guest, const void *arg) ret =3D cpuTestCompareXML(data->arch, cpu, result); =20 cleanup: - virObjectUnref(models); return ret; } =20 @@ -728,8 +727,8 @@ cpuTestUpdateLive(const void *arg) g_autoptr(virCPUData) disabledData =3D NULL; g_autofree char *expectedFile =3D NULL; g_autoptr(virCPUDef) expected =3D NULL; - virDomainCapsCPUModels *hvModels =3D NULL; - virDomainCapsCPUModels *models =3D NULL; + g_autoptr(virDomainCapsCPUModels) hvModels =3D NULL; + g_autoptr(virDomainCapsCPUModels) models =3D NULL; int ret =3D -1; =20 cpuFile =3D g_strdup_printf("cpuid-%s-guest", data->host); @@ -795,8 +794,6 @@ cpuTestUpdateLive(const void *arg) ret =3D cpuTestUpdateLiveCompare(data->arch, cpu, expected); =20 cleanup: - virObjectUnref(hvModels); - virObjectUnref(models); return ret; } =20 diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c index ca29644dee..6ab14a0179 100644 --- a/tests/domaincapstest.c +++ b/tests/domaincapstest.c @@ -75,7 +75,7 @@ fillQemuCaps(virDomainCaps *domCaps, { int ret =3D -1; char *path =3D NULL; - virQEMUCaps *qemuCaps =3D NULL; + g_autoptr(virQEMUCaps) qemuCaps =3D NULL; virDomainCapsLoader *loader =3D &domCaps->os.loader; virDomainVirtType virtType; =20 @@ -127,7 +127,6 @@ fillQemuCaps(virDomainCaps *domCaps, =20 ret =3D 0; cleanup: - virObjectUnref(qemuCaps); VIR_FREE(path); return ret; } @@ -208,7 +207,7 @@ static int test_virDomainCapsFormat(const void *opaque) { const struct testData *data =3D opaque; - virDomainCaps *domCaps =3D NULL; + g_autoptr(virDomainCaps) domCaps =3D NULL; char *path =3D NULL; char *domCapsXML =3D NULL; int ret =3D -1; @@ -256,7 +255,6 @@ test_virDomainCapsFormat(const void *opaque) cleanup: VIR_FREE(domCapsXML); VIR_FREE(path); - virObjectUnref(domCaps); return ret; } =20 diff --git a/tests/networkxml2conftest.c b/tests/networkxml2conftest.c index 7444390b77..a2ecc6e80a 100644 --- a/tests/networkxml2conftest.c +++ b/tests/networkxml2conftest.c @@ -27,7 +27,7 @@ testCompareXMLToConfFiles(const char *inxml, const char *= outconf, virCommand *cmd =3D NULL; char *pidfile =3D NULL; dnsmasqContext *dctx =3D NULL; - virNetworkXMLOption *xmlopt =3D NULL; + g_autoptr(virNetworkXMLOption) xmlopt =3D NULL; =20 if (!(xmlopt =3D networkDnsmasqCreateXMLConf())) goto fail; @@ -85,7 +85,6 @@ testCompareXMLToConfFiles(const char *inxml, const char *= outconf, VIR_FREE(hostsfileactual); VIR_FREE(pidfile); virCommandFree(cmd); - virObjectUnref(xmlopt); virNetworkObjEndAPI(&obj); dnsmasqContextFree(dctx); return ret; diff --git a/tests/networkxml2xmltest.c b/tests/networkxml2xmltest.c index 3b0a0b7c95..e1b5cdc748 100644 --- a/tests/networkxml2xmltest.c +++ b/tests/networkxml2xmltest.c @@ -30,7 +30,7 @@ testCompareXMLToXMLFiles(const char *inxml, const char *o= utxml, int ret; testCompareNetXML2XMLResult result =3D TEST_COMPARE_NET_XML2XML_RESULT= _SUCCESS; virNetworkDef *dev =3D NULL; - virNetworkXMLOption *xmlopt =3D NULL; + g_autoptr(virNetworkXMLOption) xmlopt =3D NULL; =20 if (!(xmlopt =3D networkDnsmasqCreateXMLConf())) goto cleanup; @@ -72,7 +72,6 @@ testCompareXMLToXMLFiles(const char *inxml, const char *o= utxml, =20 VIR_FREE(actual); virNetworkDefFree(dev); - virObjectUnref(xmlopt); return ret; } =20 diff --git a/tests/vircapstest.c b/tests/vircapstest.c index 7ec5b85222..ebabbbb9a0 100644 --- a/tests/vircapstest.c +++ b/tests/vircapstest.c @@ -151,7 +151,7 @@ static int test_virCapsDomainDataLookupQEMU(const void *data G_GNUC_UNUSED) { int ret =3D 0; - virCaps *caps =3D NULL; + g_autoptr(virCaps) caps =3D NULL; =20 if (!(caps =3D testQemuCapsInit())) { ret =3D -1; @@ -196,7 +196,6 @@ test_virCapsDomainDataLookupQEMU(const void *data G_GNU= C_UNUSED) CAPS_EXPECT_ERR(-1, VIR_ARCH_NONE, VIR_DOMAIN_VIRT_VMWARE, NULL, "pc"); =20 out: - virObjectUnref(caps); return ret; } #endif /* WITH_QEMU */ @@ -206,7 +205,7 @@ static int test_virCapsDomainDataLookupLXC(const void *data G_GNUC_UNUSED) { int ret =3D 0; - virCaps *caps =3D NULL; + g_autoptr(virCaps) caps =3D NULL; =20 if (!(caps =3D testLXCCapsInit())) { ret =3D -1; @@ -221,7 +220,6 @@ test_virCapsDomainDataLookupLXC(const void *data G_GNUC= _UNUSED) VIR_DOMAIN_VIRT_LXC, "/usr/libexec/libvirt_lxc", NULL); =20 out: - virObjectUnref(caps); return ret; } #endif /* WITH_LXC */ diff --git a/tests/virmacmaptest.c b/tests/virmacmaptest.c index 1b536af1ab..4e78615029 100644 --- a/tests/virmacmaptest.c +++ b/tests/virmacmaptest.c @@ -35,7 +35,7 @@ static int testMACLookup(const void *opaque) { const struct testData *data =3D opaque; - virMacMap *mgr =3D NULL; + g_autoptr(virMacMap) mgr =3D NULL; GSList *macs; GSList *next; size_t i, j; @@ -79,7 +79,6 @@ testMACLookup(const void *opaque) ret =3D 0; cleanup: VIR_FREE(file); - virObjectUnref(mgr); return ret; } =20 @@ -88,7 +87,7 @@ static int testMACRemove(const void *opaque) { const struct testData *data =3D opaque; - virMacMap *mgr =3D NULL; + g_autoptr(virMacMap) mgr =3D NULL; GSList *macs; size_t i; char *file =3D NULL; @@ -117,7 +116,6 @@ testMACRemove(const void *opaque) ret =3D 0; cleanup: VIR_FREE(file); - virObjectUnref(mgr); return ret; } =20 diff --git a/tests/virpcitest.c b/tests/virpcitest.c index 0466e5a0f7..1cffe6e279 100644 --- a/tests/virpcitest.c +++ b/tests/virpcitest.c @@ -93,8 +93,8 @@ testVirPCIDeviceDetach(const void *opaque G_GNUC_UNUSED) int ret =3D -1; virPCIDevice *dev[] =3D {NULL, NULL, NULL}; size_t i, nDev =3D G_N_ELEMENTS(dev); - virPCIDeviceList *activeDevs =3D NULL; - virPCIDeviceList *inactiveDevs =3D NULL; + g_autoptr(virPCIDeviceList) activeDevs =3D NULL; + g_autoptr(virPCIDeviceList) inactiveDevs =3D NULL; int count; =20 if (!(activeDevs =3D virPCIDeviceListNew()) || @@ -126,8 +126,6 @@ testVirPCIDeviceDetach(const void *opaque G_GNUC_UNUSED) cleanup: for (i =3D 0; i < nDev; i++) virPCIDeviceFree(dev[i]); - virObjectUnref(activeDevs); - virObjectUnref(inactiveDevs); return ret; } =20 @@ -137,8 +135,8 @@ testVirPCIDeviceReset(const void *opaque G_GNUC_UNUSED) int ret =3D -1; virPCIDevice *dev[] =3D {NULL, NULL, NULL}; size_t i, nDev =3D G_N_ELEMENTS(dev); - virPCIDeviceList *activeDevs =3D NULL; - virPCIDeviceList *inactiveDevs =3D NULL; + g_autoptr(virPCIDeviceList) activeDevs =3D NULL; + g_autoptr(virPCIDeviceList) inactiveDevs =3D NULL; int count; =20 if (!(activeDevs =3D virPCIDeviceListNew()) || @@ -164,8 +162,6 @@ testVirPCIDeviceReset(const void *opaque G_GNUC_UNUSED) cleanup: for (i =3D 0; i < nDev; i++) virPCIDeviceFree(dev[i]); - virObjectUnref(activeDevs); - virObjectUnref(inactiveDevs); return ret; } =20 @@ -175,8 +171,8 @@ testVirPCIDeviceReattach(const void *opaque G_GNUC_UNUS= ED) int ret =3D -1; virPCIDevice *dev[] =3D {NULL, NULL, NULL}; size_t i, nDev =3D G_N_ELEMENTS(dev); - virPCIDeviceList *activeDevs =3D NULL; - virPCIDeviceList *inactiveDevs =3D NULL; + g_autoptr(virPCIDeviceList) activeDevs =3D NULL; + g_autoptr(virPCIDeviceList) inactiveDevs =3D NULL; int count; =20 if (!(activeDevs =3D virPCIDeviceListNew()) || @@ -213,8 +209,6 @@ testVirPCIDeviceReattach(const void *opaque G_GNUC_UNUS= ED) =20 ret =3D 0; cleanup: - virObjectUnref(activeDevs); - virObjectUnref(inactiveDevs); return ret; } =20 diff --git a/tests/virresctrltest.c b/tests/virresctrltest.c index 26fbde3668..b1dbf66d41 100644 --- a/tests/virresctrltest.c +++ b/tests/virresctrltest.c @@ -21,10 +21,10 @@ test_virResctrlGetUnused(const void *opaque) char *system_dir =3D NULL; char *resctrl_dir =3D NULL; int ret =3D -1; - virResctrlAlloc *alloc =3D NULL; + g_autoptr(virResctrlAlloc) alloc =3D NULL; char *schemata_str =3D NULL; char *schemata_file; - virCaps *caps =3D NULL; + g_autoptr(virCaps) caps =3D NULL; =20 system_dir =3D g_strdup_printf("%s/vircaps2xmldata/linux-%s/system", a= bs_srcdir, data->filename); @@ -65,8 +65,6 @@ test_virResctrlGetUnused(const void *opaque) =20 ret =3D 0; cleanup: - virObjectUnref(caps); - virObjectUnref(alloc); VIR_FREE(system_dir); VIR_FREE(resctrl_dir); VIR_FREE(schemata_str); diff --git a/tests/virscsitest.c b/tests/virscsitest.c index 0d7c35a261..1b6a7b9ae9 100644 --- a/tests/virscsitest.c +++ b/tests/virscsitest.c @@ -60,7 +60,7 @@ test1(const void *data G_GNUC_UNUSED) static int test2(const void *data G_GNUC_UNUSED) { - virSCSIDeviceList *list =3D NULL; + g_autoptr(virSCSIDeviceList) list =3D NULL; virSCSIDevice *dev =3D NULL; virSCSIDevice *dev1 =3D NULL; bool free_dev =3D true; @@ -157,7 +157,6 @@ test2(const void *data G_GNUC_UNUSED) virSCSIDeviceFree(dev); if (free_dev1) virSCSIDeviceFree(dev1); - virObjectUnref(list); return ret; } =20 diff --git a/tests/virusbtest.c b/tests/virusbtest.c index baad7dd821..39a8f1a18e 100644 --- a/tests/virusbtest.c +++ b/tests/virusbtest.c @@ -70,7 +70,7 @@ static int testDeviceFind(const void *opaque) const struct findTestInfo *info =3D opaque; int ret =3D -1; virUSBDevice *dev =3D NULL; - virUSBDeviceList *devs =3D NULL; + g_autoptr(virUSBDeviceList) devs =3D NULL; int rv =3D 0; size_t i, ndevs =3D 0; =20 @@ -123,7 +123,6 @@ static int testDeviceFind(const void *opaque) ret =3D 0; =20 cleanup: - virObjectUnref(devs); virUSBDeviceFree(dev); return ret; } diff --git a/tests/xlconfigtest.c b/tests/xlconfigtest.c index e5c4a053bc..0a2997b8b6 100644 --- a/tests/xlconfigtest.c +++ b/tests/xlconfigtest.c @@ -67,7 +67,7 @@ testCompareParseXML(const char *xlcfg, const char *xml, b= ool replaceVars) { char *gotxlcfgData =3D NULL; g_autoptr(virConf) conf =3D NULL; - virConnectPtr conn =3D NULL; + g_autoptr(virConnect) conn =3D NULL; int wrote =3D 4096; int ret =3D -1; virDomainDef *def =3D NULL; @@ -111,7 +111,6 @@ testCompareParseXML(const char *xlcfg, const char *xml,= bool replaceVars) VIR_FREE(replacedXML); VIR_FREE(gotxlcfgData); virDomainDefFree(def); - virObjectUnref(conn); =20 return ret; } @@ -127,7 +126,7 @@ testCompareFormatXML(const char *xlcfg, const char *xml= , bool replaceVars) char *gotxml =3D NULL; g_autoptr(virConf) conf =3D NULL; int ret =3D -1; - virConnectPtr conn; + g_autoptr(virConnect) conn =3D NULL; virDomainDef *def =3D NULL; char *replacedXML =3D NULL; g_autoptr(libxlDriverConfig) cfg =3D libxlDriverConfigGet(driver); @@ -166,7 +165,6 @@ testCompareFormatXML(const char *xlcfg, const char *xml= , bool replaceVars) VIR_FREE(xlcfgData); VIR_FREE(gotxml); virDomainDefFree(def); - virObjectUnref(conn); =20 return ret; } diff --git a/tests/xmconfigtest.c b/tests/xmconfigtest.c index bf74e4a163..9d5eb85bf9 100644 --- a/tests/xmconfigtest.c +++ b/tests/xmconfigtest.c @@ -42,7 +42,7 @@ testCompareParseXML(const char *xmcfg, const char *xml) char *gotxmcfgData =3D NULL; g_autoptr(virConf) conf =3D NULL; int ret =3D -1; - virConnectPtr conn =3D NULL; + g_autoptr(virConnect) conn =3D NULL; int wrote =3D 4096; virDomainDef *def =3D NULL; =20 @@ -75,7 +75,6 @@ testCompareParseXML(const char *xmcfg, const char *xml) fail: VIR_FREE(gotxmcfgData); virDomainDefFree(def); - virObjectUnref(conn); =20 return ret; } --=20 2.31.1 From nobody Fri May 3 12:48:53 2024 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 Reviewed-by: Laine Stump --- 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 From nobody Fri May 3 12:48:53 2024 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=1630788688; cv=none; d=zohomail.com; s=zohoarc; b=Oa4NCBSyzfaqD5qQS8Eo8IpUqNwfD0/l/lru+ZJ9p8ngBElQQEFsPFzX1Cz7K6IriVu9rc5P0IYxsr8yLGhClCYF4Cm6W2fRNF4Geu7jzBhOxxW+p70ohhu2nK8gu8ISrQuTOhKxZHBYfveKPNbuI08sEJOKOeWdOxb5PJKRcG4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630788688; 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=pHOPvJXm+pre440yZq03ilTLkm7LXzfbVy9aAOexNxs=; b=hkopXZ8O07JLVH+WJ0F9zub9191EK5mR3rCR7mfKizNUvk4keBnld7uGbx6inU5UjWikDgfHrtsfwxyCjPeWNBxlm54I6TfnzBpuTqgzavstBKJUqmqSs5b62x9pC+Tk4a7rdCjft23l8VR6KM2DAerATU63dBu/UB6vhpc4bsY= 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 1630788688754248.92805406207947; Sat, 4 Sep 2021 13:51:28 -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-265-iukCmubWMniYYqd5dbW_PA-1; Sat, 04 Sep 2021 16:51:25 -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 14BDE51E0; Sat, 4 Sep 2021 20:51: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 EF3403AB2; Sat, 4 Sep 2021 20:51: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 B74F244A5B; Sat, 4 Sep 2021 20:51:20 +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 184KiWoS008759 for ; Sat, 4 Sep 2021 16:44:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9E8DD2619D; Sat, 4 Sep 2021 20:44:32 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2775A1F4 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=1630788687; 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=pHOPvJXm+pre440yZq03ilTLkm7LXzfbVy9aAOexNxs=; b=XwYoc4Q6y0/jOeikIeVYfBK2/qYKxIda8EB+5N3Od7tvXvHEVL8yHdmx61Di5o+jjNWmYX uFAYLHLo3xmVhfGG3h9sqM30Joi6dnvAN5zZHYrmtWyiB/fbHzJSzVcVgvSufIK46BJN+k 0DIUrR6WqOjOhIIIk/KqNhowZlreaVU= X-MC-Unique: iukCmubWMniYYqd5dbW_PA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 06/24] tests: network: use g_autofree Date: Sat, 4 Sep 2021 22:44:04 +0200 Message-Id: <75ba62743765afb2166afac0d352cbea26aabad6.1630788206.git.jtomko@redhat.com> 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: 1630788689011100003 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Laine Stump --- tests/networkxml2conftest.c | 16 +++++----------- tests/networkxml2firewalltest.c | 9 +++------ tests/networkxml2xmltest.c | 10 +++------- tests/networkxml2xmlupdatetest.c | 16 +++++----------- 4 files changed, 16 insertions(+), 35 deletions(-) diff --git a/tests/networkxml2conftest.c b/tests/networkxml2conftest.c index a2ecc6e80a..b76d72793a 100644 --- a/tests/networkxml2conftest.c +++ b/tests/networkxml2conftest.c @@ -20,12 +20,12 @@ testCompareXMLToConfFiles(const char *inxml, const char= *outconf, char *outhostsfile, dnsmasqCaps *caps) { char *confactual =3D NULL; - char *hostsfileactual =3D NULL; + g_autofree char *hostsfileactual =3D NULL; int ret =3D -1; virNetworkDef *def =3D NULL; virNetworkObj *obj =3D NULL; virCommand *cmd =3D NULL; - char *pidfile =3D NULL; + g_autofree char *pidfile =3D NULL; dnsmasqContext *dctx =3D NULL; g_autoptr(virNetworkXMLOption) xmlopt =3D NULL; =20 @@ -82,8 +82,6 @@ testCompareXMLToConfFiles(const char *inxml, const char *= outconf, =20 fail: VIR_FREE(confactual); - VIR_FREE(hostsfileactual); - VIR_FREE(pidfile); virCommandFree(cmd); virNetworkObjEndAPI(&obj); dnsmasqContextFree(dctx); @@ -100,9 +98,9 @@ testCompareXMLToConfHelper(const void *data) { int result =3D -1; const testInfo *info =3D data; - char *inxml =3D NULL; - char *outconf =3D NULL; - char *outhostsfile =3D NULL; + g_autofree char *inxml =3D NULL; + g_autofree char *outconf =3D NULL; + g_autofree char *outhostsfile =3D NULL; =20 inxml =3D g_strdup_printf("%s/networkxml2confdata/%s.xml", abs_srcdir,= info->name); outconf =3D g_strdup_printf("%s/networkxml2confdata/%s.conf", abs_srcd= ir, info->name); @@ -110,10 +108,6 @@ testCompareXMLToConfHelper(const void *data) =20 result =3D testCompareXMLToConfFiles(inxml, outconf, outhostsfile, inf= o->caps); =20 - VIR_FREE(inxml); - VIR_FREE(outconf); - VIR_FREE(outhostsfile); - return result; } =20 diff --git a/tests/networkxml2firewalltest.c b/tests/networkxml2firewalltes= t.c index 91336a0c55..e4f86bc3fc 100644 --- a/tests/networkxml2firewalltest.c +++ b/tests/networkxml2firewalltest.c @@ -91,7 +91,7 @@ static int testCompareXMLToArgvFiles(const char *xml, const char *cmdline, const char *baseargs) { - char *actualargv =3D NULL; + g_autofree char *actualargv =3D NULL; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; virNetworkDef *def =3D NULL; int ret =3D -1; @@ -121,7 +121,6 @@ static int testCompareXMLToArgvFiles(const char *xml, ret =3D 0; =20 cleanup: - VIR_FREE(actualargv); virNetworkDefFree(def); return ret; } @@ -137,8 +136,8 @@ testCompareXMLToIPTablesHelper(const void *data) { int result =3D -1; const struct testInfo *info =3D data; - char *xml =3D NULL; - char *args =3D NULL; + g_autofree char *xml =3D NULL; + g_autofree char *args =3D NULL; =20 xml =3D g_strdup_printf("%s/networkxml2firewalldata/%s.xml", abs_srcdir, info->name); @@ -147,8 +146,6 @@ testCompareXMLToIPTablesHelper(const void *data) =20 result =3D testCompareXMLToArgvFiles(xml, args, info->baseargs); =20 - VIR_FREE(xml); - VIR_FREE(args); return result; } =20 diff --git a/tests/networkxml2xmltest.c b/tests/networkxml2xmltest.c index e1b5cdc748..ca24305ace 100644 --- a/tests/networkxml2xmltest.c +++ b/tests/networkxml2xmltest.c @@ -26,7 +26,7 @@ testCompareXMLToXMLFiles(const char *inxml, const char *o= utxml, unsigned int flags, testCompareNetXML2XMLResult expectResult) { - char *actual =3D NULL; + g_autofree char *actual =3D NULL; int ret; testCompareNetXML2XMLResult result =3D TEST_COMPARE_NET_XML2XML_RESULT= _SUCCESS; virNetworkDef *dev =3D NULL; @@ -70,7 +70,6 @@ testCompareXMLToXMLFiles(const char *inxml, const char *o= utxml, } virResetLastError(); =20 - VIR_FREE(actual); virNetworkDefFree(dev); return ret; } @@ -86,8 +85,8 @@ testCompareXMLToXMLHelper(const void *data) { const struct testInfo *info =3D data; int result =3D -1; - char *inxml =3D NULL; - char *outxml =3D NULL; + g_autofree char *inxml =3D NULL; + g_autofree char *outxml =3D NULL; =20 inxml =3D g_strdup_printf("%s/networkxml2xmlin/%s.xml", abs_srcdir, in= fo->name); outxml =3D g_strdup_printf("%s/networkxml2xmlout/%s.xml", abs_srcdir, = info->name); @@ -95,9 +94,6 @@ testCompareXMLToXMLHelper(const void *data) result =3D testCompareXMLToXMLFiles(inxml, outxml, info->flags, info->expectResult); =20 - VIR_FREE(inxml); - VIR_FREE(outxml); - return result; } =20 diff --git a/tests/networkxml2xmlupdatetest.c b/tests/networkxml2xmlupdatet= est.c index 11cfdfc25e..4471b4dd9e 100644 --- a/tests/networkxml2xmlupdatetest.c +++ b/tests/networkxml2xmlupdatetest.c @@ -19,8 +19,8 @@ testCompareXMLToXMLFiles(const char *netxml, const char *= updatexml, unsigned int command, unsigned int section, int parentIndex, bool expectFailure) { - char *updateXmlData =3D NULL; - char *actual =3D NULL; + g_autofree char *updateXmlData =3D NULL; + g_autofree char *actual =3D NULL; int ret =3D -1; virNetworkDef *def =3D NULL; =20 @@ -55,8 +55,6 @@ testCompareXMLToXMLFiles(const char *netxml, const char *= updatexml, } } error: - VIR_FREE(updateXmlData); - VIR_FREE(actual); virNetworkDefFree(def); return ret; } @@ -78,9 +76,9 @@ testCompareXMLToXMLHelper(const void *data) { const struct testInfo *info =3D data; int result =3D -1; - char *netxml =3D NULL; - char *updatexml =3D NULL; - char *outxml =3D NULL; + g_autofree char *netxml =3D NULL; + g_autofree char *updatexml =3D NULL; + g_autofree char *outxml =3D NULL; =20 netxml =3D g_strdup_printf("%s/networkxml2xmlin/%s.xml", abs_srcdir, info->netxml); @@ -93,10 +91,6 @@ testCompareXMLToXMLHelper(const void *data) info->command, info->section, info->parentIndex, info->expectFailu= re); =20 - VIR_FREE(netxml); - VIR_FREE(updatexml); - VIR_FREE(outxml); - return result; } =20 --=20 2.31.1 From nobody Fri May 3 12:48:53 2024 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=1630789645; cv=none; d=zohomail.com; s=zohoarc; b=PHqbbo2D3d+t/HrAEI9fsBwJC9RMfD0NoB+h4EBwU2+HZt0giUmRTXIsvVbGkTXQRKJKaAp/kRoE4eXLJ2oycAysyTRKjJY8CvF7RjuFncDNrHT6NfcuPrOfqBTVBwD7MGgDUD8GEC0IQ3tMiCtjtgpoxeHfad4j6XUbTmSTigw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630789645; 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=P+91bzSZDIXNug1GRWS6EG/K2bTDx3RhAlDNkRgs9mM=; b=JNN1YmbpBCF4rWKxPV2IPJGnnXP8AbopNJFs838WpwnkVf1kPk3Ho/2OZ8Q5KJQgnZFqJF0K2FEgGQdSkOB0bmxvFT3uOHMfrllp/9iPLagfZxpQtNEw1OFJhQ9ujhdFfySgQS1FF6WmTbnmM3yGHzWdJxyBcpFRwCEXZbExBe4= 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 1630789645276408.86994563303097; Sat, 4 Sep 2021 14:07:25 -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-119-DZVeg7XbPAiGExjOuESgsQ-1; Sat, 04 Sep 2021 17:07:22 -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 5E7AD10060F8; Sat, 4 Sep 2021 21:07:17 +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 389AC1F4; Sat, 4 Sep 2021 21:07:17 +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 E989244A5C; Sat, 4 Sep 2021 21:07:16 +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 184KiXAm008767 for ; Sat, 4 Sep 2021 16:44:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6D56D2619D; Sat, 4 Sep 2021 20:44:33 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id EB79B1F4 for ; Sat, 4 Sep 2021 20:44:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630789644; 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=P+91bzSZDIXNug1GRWS6EG/K2bTDx3RhAlDNkRgs9mM=; b=DZ2btrvSmq4YAyRmIpXFyhkNm7PMPGuAn3qTA0kslZOxUo2T65MjoHNfIcXIH4M3T2VH+Z 1FWN0sOf99uupG8VB/b5uC/WqcfAJ8swmxzSW2et1f91aGkTEajQWaThOEGsSPWSWUltxY +gOVcSnKdX2JyjZC6sDaIDpflaOCSPc= X-MC-Unique: DZVeg7XbPAiGExjOuESgsQ-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 07/24] tests: libxl: use g_autofree Date: Sat, 4 Sep 2021 22:44:05 +0200 Message-Id: <9e806c377da7aab0d42b967842390f3ab0db7bfd.1630788206.git.jtomko@redhat.com> 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.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: 1630789645890100001 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Laine Stump --- tests/libxlxml2domconfigtest.c | 15 +++++---------- tests/xlconfigtest.c | 25 ++++++++----------------- tests/xmconfigtest.c | 16 +++++----------- 3 files changed, 18 insertions(+), 38 deletions(-) diff --git a/tests/libxlxml2domconfigtest.c b/tests/libxlxml2domconfigtest.c index 19385c6fb5..2bc5c26223 100644 --- a/tests/libxlxml2domconfigtest.c +++ b/tests/libxlxml2domconfigtest.c @@ -53,9 +53,9 @@ testCompareXMLToDomConfig(const char *xmlfile, xentoollog_logger *log =3D NULL; virPortAllocatorRange *gports =3D NULL; virDomainDef *vmdef =3D NULL; - char *actualjson =3D NULL; - char *tempjson =3D NULL; - char *expectjson =3D NULL; + g_autofree char *actualjson =3D NULL; + g_autofree char *tempjson =3D NULL; + g_autofree char *expectjson =3D NULL; g_autoptr(libxlDriverConfig) cfg =3D libxlDriverConfigGet(driver); =20 libxl_domain_config_init(&actualconfig); @@ -128,9 +128,6 @@ testCompareXMLToDomConfig(const char *xmlfile, vmdef->graphics[0]->type =3D=3D VIR_DOMAIN_GRAPHICS_TYPE_VNC) virPortAllocatorRelease(vmdef->graphics[0]->data.vnc.port); =20 - VIR_FREE(expectjson); - VIR_FREE(actualjson); - VIR_FREE(tempjson); virDomainDefFree(vmdef); virPortAllocatorRangeFree(gports); libxl_domain_config_dispose(&actualconfig); @@ -150,16 +147,14 @@ testCompareXMLToDomConfigHelper(const void *data) { int ret =3D -1; const struct testInfo *info =3D data; - char *xmlfile =3D NULL; - char *jsonfile =3D NULL; + g_autofree char *xmlfile =3D NULL; + g_autofree char *jsonfile =3D NULL; =20 xmlfile =3D g_strdup_printf("%s/libxlxml2domconfigdata/%s.xml", abs_sr= cdir, info->name); jsonfile =3D g_strdup_printf("%s/libxlxml2domconfigdata/%s.json", abs_= srcdir, info->name); =20 ret =3D testCompareXMLToDomConfig(xmlfile, jsonfile); =20 - VIR_FREE(xmlfile); - VIR_FREE(jsonfile); return ret; } =20 diff --git a/tests/xlconfigtest.c b/tests/xlconfigtest.c index 0a2997b8b6..95ee670b00 100644 --- a/tests/xlconfigtest.c +++ b/tests/xlconfigtest.c @@ -45,7 +45,7 @@ static libxlDriverPrivate *driver; static char * testReplaceVarsXML(const char *xml) { - char *xmlcfgData; + g_autofree char *xmlcfgData =3D NULL; char *replacedXML; =20 if (virTestLoadFile(xml, &xmlcfgData) < 0) @@ -54,7 +54,6 @@ testReplaceVarsXML(const char *xml) replacedXML =3D virStringReplace(xmlcfgData, "/LIBXL_FIRMWARE_DIR", LIBXL_FIRMWARE_DIR); =20 - VIR_FREE(xmlcfgData); return replacedXML; } =20 @@ -65,13 +64,13 @@ testReplaceVarsXML(const char *xml) static int testCompareParseXML(const char *xlcfg, const char *xml, bool replaceVars) { - char *gotxlcfgData =3D NULL; + g_autofree char *gotxlcfgData =3D NULL; g_autoptr(virConf) conf =3D NULL; g_autoptr(virConnect) conn =3D NULL; int wrote =3D 4096; int ret =3D -1; virDomainDef *def =3D NULL; - char *replacedXML =3D NULL; + g_autofree char *replacedXML =3D NULL; =20 gotxlcfgData =3D g_new0(char, wrote); =20 @@ -108,8 +107,6 @@ testCompareParseXML(const char *xlcfg, const char *xml,= bool replaceVars) ret =3D 0; =20 fail: - VIR_FREE(replacedXML); - VIR_FREE(gotxlcfgData); virDomainDefFree(def); =20 return ret; @@ -122,13 +119,13 @@ testCompareParseXML(const char *xlcfg, const char *xm= l, bool replaceVars) static int testCompareFormatXML(const char *xlcfg, const char *xml, bool replaceVars) { - char *xlcfgData =3D NULL; - char *gotxml =3D NULL; + g_autofree char *xlcfgData =3D NULL; + g_autofree char *gotxml =3D NULL; g_autoptr(virConf) conf =3D NULL; int ret =3D -1; g_autoptr(virConnect) conn =3D NULL; virDomainDef *def =3D NULL; - char *replacedXML =3D NULL; + g_autofree char *replacedXML =3D NULL; g_autoptr(libxlDriverConfig) cfg =3D libxlDriverConfigGet(driver); =20 conn =3D virGetConnect(); @@ -161,9 +158,6 @@ testCompareFormatXML(const char *xlcfg, const char *xml= , bool replaceVars) ret =3D 0; =20 fail: - VIR_FREE(replacedXML); - VIR_FREE(xlcfgData); - VIR_FREE(gotxml); virDomainDefFree(def); =20 return ret; @@ -181,8 +175,8 @@ testCompareHelper(const void *data) { int result =3D -1; const struct testInfo *info =3D data; - char *xml =3D NULL; - char *cfg =3D NULL; + g_autofree char *xml =3D NULL; + g_autofree char *cfg =3D NULL; =20 xml =3D g_strdup_printf("%s/xlconfigdata/test-%s.xml", abs_srcdir, inf= o->name); cfg =3D g_strdup_printf("%s/xlconfigdata/test-%s.cfg", abs_srcdir, inf= o->name); @@ -192,9 +186,6 @@ testCompareHelper(const void *data) else result =3D testCompareFormatXML(cfg, xml, info->replaceVars); =20 - VIR_FREE(xml); - VIR_FREE(cfg); - return result; } =20 diff --git a/tests/xmconfigtest.c b/tests/xmconfigtest.c index 9d5eb85bf9..a756f752f8 100644 --- a/tests/xmconfigtest.c +++ b/tests/xmconfigtest.c @@ -39,7 +39,7 @@ static libxlDriverPrivate *driver; static int testCompareParseXML(const char *xmcfg, const char *xml) { - char *gotxmcfgData =3D NULL; + g_autofree char *gotxmcfgData =3D NULL; g_autoptr(virConf) conf =3D NULL; int ret =3D -1; g_autoptr(virConnect) conn =3D NULL; @@ -73,7 +73,6 @@ testCompareParseXML(const char *xmcfg, const char *xml) ret =3D 0; =20 fail: - VIR_FREE(gotxmcfgData); virDomainDefFree(def); =20 return ret; @@ -82,8 +81,8 @@ testCompareParseXML(const char *xmcfg, const char *xml) static int testCompareFormatXML(const char *xmcfg, const char *xml) { - char *xmcfgData =3D NULL; - char *gotxml =3D NULL; + g_autofree char *xmcfgData =3D NULL; + g_autofree char *gotxml =3D NULL; g_autoptr(virConf) conf =3D NULL; int ret =3D -1; virDomainDef *def =3D NULL; @@ -107,8 +106,6 @@ testCompareFormatXML(const char *xmcfg, const char *xml) ret =3D 0; =20 fail: - VIR_FREE(xmcfgData); - VIR_FREE(gotxml); virDomainDefFree(def); =20 return ret; @@ -125,8 +122,8 @@ testCompareHelper(const void *data) { int result =3D -1; const struct testInfo *info =3D data; - char *xml =3D NULL; - char *cfg =3D NULL; + g_autofree char *xml =3D NULL; + g_autofree char *cfg =3D NULL; =20 xml =3D g_strdup_printf("%s/xmconfigdata/test-%s.xml", abs_srcdir, inf= o->name); cfg =3D g_strdup_printf("%s/xmconfigdata/test-%s.cfg", abs_srcdir, inf= o->name); @@ -136,9 +133,6 @@ testCompareHelper(const void *data) else result =3D testCompareFormatXML(cfg, xml); =20 - VIR_FREE(xml); - VIR_FREE(cfg); - return result; } =20 --=20 2.31.1 From nobody Fri May 3 12:48:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1630788723; cv=none; d=zohomail.com; s=zohoarc; b=kvYKfzH73NwJ87rHvywXpwkV+SBDLaRdjIQOHwV2jAJeAKO2sQ9znwyDnLISzSoWscU8HbSWaaNpN/8lKry+BWGZhbVXsOSz47Fnb6QVNmDFpOg4UAx5cQ//gaBw0OmIUxf+BUXzQx9HJjq5o1oerWqWh/8Ye5k0QqbJftdhki4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630788723; 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=HwBLco/FqTtKxe/IZrT4zEGdpV4GhptNgO5tK4O6FRY=; b=jflC7XhRppdOrG/xSOPCQbePsE3pugILuLS82/UhP7ltMzaqKnZSDjCPaFgOpBdVvwFqQmZEZTps8zObYPlhX891kyigZ6HBkvp5je4qMQQKkykhZ8dpGPb5LzhupZq5ENDLnylAJ2pC1JwfmRx/o5xcRS4bO4KER+c7bSrghfg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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 [170.10.133.124]) by mx.zohomail.com with SMTPS id 1630788723480975.3876346895081; Sat, 4 Sep 2021 13:52:03 -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-164-xO8y1ug5MnqK6ywI7E2f_A-1; Sat, 04 Sep 2021 16:51:28 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A141A824FA6; Sat, 4 Sep 2021 20:51:23 +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 85B0A77BF1; Sat, 4 Sep 2021 20:51:23 +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 392DC1800B9C; Sat, 4 Sep 2021 20:51:23 +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 184KiYAF008780 for ; Sat, 4 Sep 2021 16:44:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3D6DB2619D; Sat, 4 Sep 2021 20:44:34 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id BAABE1F4 for ; Sat, 4 Sep 2021 20:44:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630788722; 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=HwBLco/FqTtKxe/IZrT4zEGdpV4GhptNgO5tK4O6FRY=; b=KjGRI4A5ryOBulS/VHCuUGzZklMNcmdyVm4Hi/AVLsartQmlpK7SfGJdYxkQEXMDZtyohV 5Nna/XBFQt1znNjPYK2Bj5CPk6+7bhSkLEnHLN+HLbKY7SOjLjXuBPp2jR0skcvfV3+OcZ PPgMGXWp6CB5kSQzDCZIARsk5Nwgwq4= X-MC-Unique: xO8y1ug5MnqK6ywI7E2f_A-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 08/24] tests: nwfilter: use g_autofree Date: Sat, 4 Sep 2021 22:44:06 +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.13 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: 1630788723901100001 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Laine Stump --- tests/nwfilterebiptablestest.c | 21 +++++++-------------- tests/nwfilterxml2firewalltest.c | 12 ++++-------- tests/nwfilterxml2xmltest.c | 10 +++------- 3 files changed, 14 insertions(+), 29 deletions(-) diff --git a/tests/nwfilterebiptablestest.c b/tests/nwfilterebiptablestest.c index 65b63959fb..7b32e90d19 100644 --- a/tests/nwfilterebiptablestest.c +++ b/tests/nwfilterebiptablestest.c @@ -101,7 +101,7 @@ testNWFilterEBIPTablesAllTeardown(const void *opaque G_= GNUC_UNUSED) "ebtables --concurrent -t nat -X libvirt-I-vnet0\n" "ebtables --concurrent -t nat -F libvirt-O-vnet0\n" "ebtables --concurrent -t nat -X libvirt-O-vnet0\n"; - char *actual =3D NULL; + g_autofree char *actual =3D NULL; int ret =3D -1; g_autoptr(virCommandDryRunToken) dryRunToken =3D virCommandDryRunToken= New(); =20 @@ -119,7 +119,6 @@ testNWFilterEBIPTablesAllTeardown(const void *opaque G_= GNUC_UNUSED) =20 ret =3D 0; cleanup: - VIR_FREE(actual); return ret; } =20 @@ -167,7 +166,7 @@ testNWFilterEBIPTablesTearOldRules(const void *opaque G= _GNUC_UNUSED) "ebtables --concurrent -t nat -L libvirt-P-vnet0\n" "ebtables --concurrent -t nat -E libvirt-J-vnet0 libvirt-I-vnet0\n" "ebtables --concurrent -t nat -E libvirt-P-vnet0 libvirt-O-vnet0\n= "; - char *actual =3D NULL; + g_autofree char *actual =3D NULL; int ret =3D -1; g_autoptr(virCommandDryRunToken) dryRunToken =3D virCommandDryRunToken= New(); =20 @@ -185,7 +184,6 @@ testNWFilterEBIPTablesTearOldRules(const void *opaque G= _GNUC_UNUSED) =20 ret =3D 0; cleanup: - VIR_FREE(actual); return ret; } =20 @@ -211,7 +209,7 @@ testNWFilterEBIPTablesRemoveBasicRules(const void *opaq= ue G_GNUC_UNUSED) "ebtables --concurrent -t nat -X libvirt-J-vnet0\n" "ebtables --concurrent -t nat -F libvirt-P-vnet0\n" "ebtables --concurrent -t nat -X libvirt-P-vnet0\n"; - char *actual =3D NULL; + g_autofree char *actual =3D NULL; int ret =3D -1; g_autoptr(virCommandDryRunToken) dryRunToken =3D virCommandDryRunToken= New(); =20 @@ -229,7 +227,6 @@ testNWFilterEBIPTablesRemoveBasicRules(const void *opaq= ue G_GNUC_UNUSED) =20 ret =3D 0; cleanup: - VIR_FREE(actual); return ret; } =20 @@ -240,7 +237,7 @@ testNWFilterEBIPTablesTearNewRules(const void *opaque G= _GNUC_UNUSED) g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; const char *expected =3D VIR_NWFILTER_NEW_RULES_TEARDOWN; - char *actual =3D NULL; + g_autofree char *actual =3D NULL; int ret =3D -1; g_autoptr(virCommandDryRunToken) dryRunToken =3D virCommandDryRunToken= New(); =20 @@ -258,7 +255,6 @@ testNWFilterEBIPTablesTearNewRules(const void *opaque G= _GNUC_UNUSED) =20 ret =3D 0; cleanup: - VIR_FREE(actual); return ret; } =20 @@ -306,7 +302,7 @@ testNWFilterEBIPTablesApplyBasicRules(const void *opaqu= e G_GNUC_UNUSED) "ebtables --concurrent -t nat -A libvirt-J-vnet0 -j DROP\n" "ebtables --concurrent -t nat -A PREROUTING -i vnet0 -j libvirt-J-= vnet0\n" "ebtables --concurrent -t nat -E libvirt-J-vnet0 libvirt-I-vnet0\n= "; - char *actual =3D NULL; + g_autofree char *actual =3D NULL; int ret =3D -1; virMacAddr mac =3D { .addr =3D { 0x10, 0x20, 0x30, 0x40, 0x50, 0x60 } = }; g_autoptr(virCommandDryRunToken) dryRunToken =3D virCommandDryRunToken= New(); @@ -325,7 +321,6 @@ testNWFilterEBIPTablesApplyBasicRules(const void *opaqu= e G_GNUC_UNUSED) =20 ret =3D 0; cleanup: - VIR_FREE(actual); return ret; } =20 @@ -381,7 +376,7 @@ testNWFilterEBIPTablesApplyDHCPOnlyRules(const void *op= aque G_GNUC_UNUSED) "ebtables --concurrent -t nat -A POSTROUTING -o vnet0 -j libvirt-P= -vnet0\n" "ebtables --concurrent -t nat -E libvirt-J-vnet0 libvirt-I-vnet0\n" "ebtables --concurrent -t nat -E libvirt-P-vnet0 libvirt-O-vnet0\n= "; - char *actual =3D NULL; + g_autofree char *actual =3D NULL; int ret =3D -1; virMacAddr mac =3D { .addr =3D { 0x10, 0x20, 0x30, 0x40, 0x50, 0x60 } = }; const char *servers[] =3D { "192.168.122.1", "10.0.0.1", "10.0.0.2" }; @@ -410,7 +405,6 @@ testNWFilterEBIPTablesApplyDHCPOnlyRules(const void *op= aque G_GNUC_UNUSED) =20 ret =3D 0; cleanup: - VIR_FREE(actual); return ret; } =20 @@ -460,7 +454,7 @@ testNWFilterEBIPTablesApplyDropAllRules(const void *opa= que G_GNUC_UNUSED) "ebtables --concurrent -t nat -A POSTROUTING -o vnet0 -j libvirt-P= -vnet0\n" "ebtables --concurrent -t nat -E libvirt-J-vnet0 libvirt-I-vnet0\n" "ebtables --concurrent -t nat -E libvirt-P-vnet0 libvirt-O-vnet0\n= "; - char *actual =3D NULL; + g_autofree char *actual =3D NULL; int ret =3D -1; g_autoptr(virCommandDryRunToken) dryRunToken =3D virCommandDryRunToken= New(); =20 @@ -478,7 +472,6 @@ testNWFilterEBIPTablesApplyDropAllRules(const void *opa= que G_GNUC_UNUSED) =20 ret =3D 0; cleanup: - VIR_FREE(actual); return ret; } =20 diff --git a/tests/nwfilterxml2firewalltest.c b/tests/nwfilterxml2firewallt= est.c index 7fefd3ce75..3e8436a98c 100644 --- a/tests/nwfilterxml2firewalltest.c +++ b/tests/nwfilterxml2firewalltest.c @@ -229,7 +229,7 @@ virNWFilterIncludeDefToRuleInst(virNWFilterIncludeDef *= inc, { GHashTable *tmpvars =3D NULL; int ret =3D -1; - char *xml; + g_autofree char *xml =3D NULL; =20 xml =3D g_strdup_printf("%s/nwfilterxml2firewalldata/%s.xml", abs_srcd= ir, inc->filterref); @@ -249,7 +249,6 @@ virNWFilterIncludeDefToRuleInst(virNWFilterIncludeDef *= inc, if (ret < 0) virNWFilterInstReset(inst); virHashFree(tmpvars); - VIR_FREE(xml); return ret; } =20 @@ -350,7 +349,7 @@ static int testSetDefaultParameters(GHashTable *vars) static int testCompareXMLToArgvFiles(const char *xml, const char *cmdline) { - char *actualargv =3D NULL; + g_autofree char *actualargv =3D NULL; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; GHashTable *vars =3D virHashNew(virNWFilterVarValueHashFree); virNWFilterInst inst; @@ -382,7 +381,6 @@ static int testCompareXMLToArgvFiles(const char *xml, ret =3D 0; =20 cleanup: - VIR_FREE(actualargv); virNWFilterInstReset(&inst); virHashFree(vars); return ret; @@ -398,8 +396,8 @@ testCompareXMLToIPTablesHelper(const void *data) { int result =3D -1; const struct testInfo *info =3D data; - char *xml =3D NULL; - char *args =3D NULL; + g_autofree char *xml =3D NULL; + g_autofree char *args =3D NULL; =20 xml =3D g_strdup_printf("%s/nwfilterxml2firewalldata/%s.xml", abs_srcdir, info->name); @@ -408,8 +406,6 @@ testCompareXMLToIPTablesHelper(const void *data) =20 result =3D testCompareXMLToArgvFiles(xml, args); =20 - VIR_FREE(xml); - VIR_FREE(args); return result; } =20 diff --git a/tests/nwfilterxml2xmltest.c b/tests/nwfilterxml2xmltest.c index 82ce042e01..7a7e05965b 100644 --- a/tests/nwfilterxml2xmltest.c +++ b/tests/nwfilterxml2xmltest.c @@ -20,7 +20,7 @@ static int testCompareXMLToXMLFiles(const char *inxml, const char *outxml, bool expect_error) { - char *actual =3D NULL; + g_autofree char *actual =3D NULL; int ret =3D -1; virNWFilterDef *dev =3D NULL; =20 @@ -44,7 +44,6 @@ testCompareXMLToXMLFiles(const char *inxml, const char *o= utxml, ret =3D 0; =20 fail: - VIR_FREE(actual); virNWFilterDefFree(dev); return ret; } @@ -59,17 +58,14 @@ testCompareXMLToXMLHelper(const void *data) { int result =3D -1; const test_parms *tp =3D data; - char *inxml =3D NULL; - char *outxml =3D NULL; + g_autofree char *inxml =3D NULL; + g_autofree char *outxml =3D NULL; =20 inxml =3D g_strdup_printf("%s/nwfilterxml2xmlin/%s.xml", abs_srcdir, t= p->name); outxml =3D g_strdup_printf("%s/nwfilterxml2xmlout/%s.xml", abs_srcdir,= tp->name); =20 result =3D testCompareXMLToXMLFiles(inxml, outxml, tp->expect_warning); =20 - VIR_FREE(inxml); - VIR_FREE(outxml); - return result; } =20 --=20 2.31.1 From nobody Fri May 3 12:48:53 2024 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=1630788695; cv=none; d=zohomail.com; s=zohoarc; b=SPl7CqkpWQYI6ofU6O7LovkW2sIen0gz2cIbODSZar3RkWcKryuxqRjJvG46xEwgf1ujy0rIIvxNtNx7AFStbMzX+Fr79U3amtzpsTvBeVPpiwpwT5E3Kdi4F2+zU5kWXvoR5CjvkatgMsCLXIvpFA2K+9scMJMafIoctiif7EA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630788695; 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=clwg+O5YjhTR4j+9vjp/59wCOEitNC2+JSzjCG6QkyY=; b=IQlCSH94i15qGWTEDe2ee0KNsDDCGMCfT1OJU7ZTvSU7bZ0lh9zo6BEwz3V5J7PBT0wBIRGyhUwLGUPUnkdBqvzg8NW9cn6pDOEL4CGiCB8p52ipELvbyttfPGSk3rQFQrdeu2uvG8rfnOUcQV+bXuha3Rdu2yWpE1dsBQrPVhY= 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 1630788695012442.45759408818935; Sat, 4 Sep 2021 13:51:35 -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-381-bg9VBrIGM-qxonmCuSQbXg-1; Sat, 04 Sep 2021 16:51:32 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B6DBE1006CA2; Sat, 4 Sep 2021 20:51:26 +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 87EBD5D9FC; Sat, 4 Sep 2021 20:51:26 +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 0EB14180BAA1; Sat, 4 Sep 2021 20:51:26 +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 184KiZMO008785 for ; Sat, 4 Sep 2021 16:44:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0E4551F4; Sat, 4 Sep 2021 20:44:35 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8B6A726367 for ; Sat, 4 Sep 2021 20:44:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630788694; 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=clwg+O5YjhTR4j+9vjp/59wCOEitNC2+JSzjCG6QkyY=; b=Z38GBuqgct5NlVFpX+4Qp0AIk93U9LaTXgX4D9SL0WSjG+jmw0MOyYTbgtRryPqrQnOBFr A2iSvV+j8zKNluJ2YRKHE2D4rM9+bwCftPRfBng+4scdbnvwcYVNnwt8uPNp6uSn08jGm+ BfK2oPul6HpR3WptnYNlErFRerfvDgI= X-MC-Unique: bg9VBrIGM-qxonmCuSQbXg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 09/24] tests: vmx: use g_autofree Date: Sat, 4 Sep 2021 22:44:07 +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.14 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: 1630788697138100001 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Laine Stump --- tests/vmx2xmltest.c | 13 ++++--------- tests/xml2vmxtest.c | 14 ++++---------- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c index 33bf243717..cd44a84a07 100644 --- a/tests/vmx2xmltest.c +++ b/tests/vmx2xmltest.c @@ -69,8 +69,8 @@ static int testCompareFiles(const char *vmx, const char *xml, bool should_fail_parse) { int ret =3D -1; - char *vmxData =3D NULL; - char *formatted =3D NULL; + g_autofree char *vmxData =3D NULL; + g_autofree char *formatted =3D NULL; virDomainDef *def =3D NULL; =20 if (virTestLoadFile(vmx, &vmxData) < 0) @@ -102,8 +102,6 @@ testCompareFiles(const char *vmx, const char *xml, bool= should_fail_parse) ret =3D 0; =20 cleanup: - VIR_FREE(vmxData); - VIR_FREE(formatted); virDomainDefFree(def); =20 return ret; @@ -119,8 +117,8 @@ testCompareHelper(const void *data) { int ret =3D -1; const struct testInfo *info =3D data; - char *vmx =3D NULL; - char *xml =3D NULL; + g_autofree char *vmx =3D NULL; + g_autofree char *xml =3D NULL; =20 vmx =3D g_strdup_printf("%s/vmx2xmldata/%s.vmx", abs_srcdir, info->file); @@ -129,9 +127,6 @@ testCompareHelper(const void *data) =20 ret =3D testCompareFiles(vmx, xml, info->should_fail); =20 - VIR_FREE(vmx); - VIR_FREE(xml); - return ret; } =20 diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c index fb87000529..cb70f70f4f 100644 --- a/tests/xml2vmxtest.c +++ b/tests/xml2vmxtest.c @@ -71,7 +71,7 @@ static int testCompareFiles(const char *xml, const char *vmx, int virtualHW_version) { int result =3D -1; - char *formatted =3D NULL; + g_autofree char *formatted =3D NULL; virDomainDef *def =3D NULL; =20 def =3D virDomainDefParseFile(xml, xmlopt, NULL, @@ -95,7 +95,6 @@ testCompareFiles(const char *xml, const char *vmx, int vi= rtualHW_version) result =3D 0; =20 failure: - VIR_FREE(formatted); virDomainDefFree(def); =20 return result; @@ -112,8 +111,8 @@ testCompareHelper(const void *data) { int result =3D -1; const struct testInfo *info =3D data; - char *xml =3D NULL; - char *vmx =3D NULL; + g_autofree char *xml =3D NULL; + g_autofree char *vmx =3D NULL; =20 xml =3D g_strdup_printf("%s/xml2vmxdata/xml2vmx-%s.xml", abs_srcdir, info->input); @@ -122,9 +121,6 @@ testCompareHelper(const void *data) =20 result =3D testCompareFiles(xml, vmx, info->virtualHW_version); =20 - VIR_FREE(xml); - VIR_FREE(vmx); - return result; } =20 @@ -141,7 +137,7 @@ static char * testFormatVMXFileName(const char *src, void *opaque G_GNUC_UNUSED) { bool success =3D false; - char *copyOfDatastorePath =3D NULL; + g_autofree char *copyOfDatastorePath =3D NULL; char *tmp =3D NULL; char *saveptr =3D NULL; char *datastoreName =3D NULL; @@ -182,8 +178,6 @@ testFormatVMXFileName(const char *src, void *opaque G_G= NUC_UNUSED) if (! success) VIR_FREE(absolutePath); =20 - VIR_FREE(copyOfDatastorePath); - return absolutePath; } =20 --=20 2.31.1 From nobody Fri May 3 12:48:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1630788415; cv=none; d=zohomail.com; s=zohoarc; b=bXAKxyZSLHFPlTNyPZ+TD+h7/y5cBZ7nnbRQTbvw4/Ge6LMI+80YMY2TBiWLY09W59im3niZIj4TJTv9e0g6X0XjPcNanMh3PKcMgkB6K/VtS8yXDU5NrsKsCMIaFk5ge5jHvKorwDr7EPqstfvLO1n1KN/AlBYRhTq944mmi0A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630788415; 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=6Au7ZapnY4cI6ZEzODEtc86diDiaHbSisBfMY3NKJhc=; b=c9iQoBEwlKa+JKgp3gJs6SDXu3gU98yqh4idl9/CNfScExkYgouYY5/gSV7CBS5m4Q4F1ITXqT8PiIiESKfXrYahdFzTKuYRQ6xsVS1qW55JkrTQSwxOUEKrY2Lc/+lc9E2laLzU1NPb56+nE2p2RnZ58Ofc6+I6vraq6Y8BLF8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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 [170.10.133.124]) by mx.zohomail.com with SMTPS id 1630788415881123.73309610488195; Sat, 4 Sep 2021 13:46:55 -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-412-OFgfTe7dPN6PJ_kDvu8Llw-1; Sat, 04 Sep 2021 16:46:52 -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 9AF791006711; Sat, 4 Sep 2021 20:46:47 +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 CCAEC6A910; Sat, 4 Sep 2021 20:46:46 +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 9E8E744A5D; Sat, 4 Sep 2021 20:46:46 +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 184KiaKc008795 for ; Sat, 4 Sep 2021 16:44:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id 04CFA2635E; Sat, 4 Sep 2021 20:44:36 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5D0151F4 for ; Sat, 4 Sep 2021 20:44:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630788414; 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=6Au7ZapnY4cI6ZEzODEtc86diDiaHbSisBfMY3NKJhc=; b=eMGVst1EbU45SE/grL01LPihGoLdWDro6LaXWNk97vyr9jqG5TSWidVfAX3hFNx58Ke254 87M3zjMdhwQ3qeHWqM06Z42rltS+h4Ry/Bu3rh7SQxMBFSu4pFu4fLIbvaGK2XzTOPj0QV k2YyJmY3aRkWwcbK0PPgEXB08onU3g0= X-MC-Unique: OFgfTe7dPN6PJ_kDvu8Llw-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 10/24] tests: vir: use g_autofree Date: Sat, 4 Sep 2021 22:44:08 +0200 Message-Id: <27693afdd2c7ec6a8bea994247aa606a61eca334.1630788206.git.jtomko@redhat.com> 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: 1630788416632100001 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Laine Stump --- tests/vircgrouptest.c | 3 +-- tests/virconftest.c | 6 ++---- tests/vircryptotest.c | 12 ++++-------- tests/virfilecachetest.c | 3 +-- tests/virfilemock.c | 3 +-- tests/virfiletest.c | 6 ++---- tests/virhostcputest.c | 23 +++++++---------------- tests/viriscsitest.c | 3 +-- tests/virkmodtest.c | 9 +++------ tests/virmacmaptest.c | 12 ++++-------- tests/virnetdaemontest.c | 12 ++++-------- tests/virnetsockettest.c | 6 ++---- tests/virnetworkportxml2xmltest.c | 8 ++------ tests/virnumamock.c | 7 ++----- tests/virnwfilterbindingxml2xmltest.c | 7 ++----- tests/virpcitest.c | 16 +++++----------- tests/virresctrltest.c | 12 ++++-------- tests/virscsitest.c | 13 ++++--------- tests/virstringtest.c | 12 ++++-------- tests/virsystemdtest.c | 9 +++------ tests/virtestmock.c | 10 +++------- tests/viruritest.c | 3 +-- tests/virusbmock.c | 7 ++----- tests/virusbtest.c | 3 +-- 24 files changed, 65 insertions(+), 140 deletions(-) diff --git a/tests/vircgrouptest.c b/tests/vircgrouptest.c index 1060f6073e..7d54df1a85 100644 --- a/tests/vircgrouptest.c +++ b/tests/vircgrouptest.c @@ -174,7 +174,7 @@ testCgroupDetectMounts(const void *args) { int result =3D -1; const struct _detectMountsData *data =3D args; - char *parsed =3D NULL; + g_autofree char *parsed =3D NULL; const char *actual; g_autoptr(virCgroup) group =3D NULL; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; @@ -209,7 +209,6 @@ testCgroupDetectMounts(const void *args) =20 cleanup: g_unsetenv("VIR_CGROUP_MOCK_FILENAME"); - VIR_FREE(parsed); return result; } =20 diff --git a/tests/virconftest.c b/tests/virconftest.c index f1a58b01cf..a7189579d3 100644 --- a/tests/virconftest.c +++ b/tests/virconftest.c @@ -70,7 +70,7 @@ static int testConfMemoryNoNewline(const void *opaque G_G= NUC_UNUSED) int ret =3D -1; virConfValue *val; unsigned long long llvalue; - char *str =3D NULL; + g_autofree char *str =3D NULL; int uintvalue; =20 if (!conf) @@ -119,7 +119,6 @@ static int testConfMemoryNoNewline(const void *opaque G= _GNUC_UNUSED) =20 ret =3D 0; cleanup: - VIR_FREE(str); return ret; } =20 @@ -341,7 +340,7 @@ static int testConfParseString(const void *opaque G_GNU= C_UNUSED) =20 int ret =3D -1; g_autoptr(virConf) conf =3D virConfReadString(srcdata, 0); - char *str =3D NULL; + g_autofree char *str =3D NULL; =20 if (!conf) return -1; @@ -367,7 +366,6 @@ static int testConfParseString(const void *opaque G_GNU= C_UNUSED) =20 ret =3D 0; cleanup: - VIR_FREE(str); return ret; } =20 diff --git a/tests/vircryptotest.c b/tests/vircryptotest.c index 2c3d4bfe75..2d503a439e 100644 --- a/tests/vircryptotest.c +++ b/tests/vircryptotest.c @@ -37,7 +37,7 @@ static int testCryptoHash(const void *opaque) { const struct testCryptoHashData *data =3D opaque; - char *actual =3D NULL; + g_autofree char *actual =3D NULL; int ret =3D -1; =20 if (virCryptoHashString(data->hash, data->input, &actual) < 0) { @@ -53,7 +53,6 @@ testCryptoHash(const void *opaque) =20 ret =3D 0; cleanup: - VIR_FREE(actual); return ret; } =20 @@ -70,11 +69,11 @@ static int testCryptoEncrypt(const void *opaque) { const struct testCryptoEncryptData *data =3D opaque; - uint8_t *enckey =3D NULL; + g_autofree uint8_t *enckey =3D NULL; size_t enckeylen =3D 32; - uint8_t *iv =3D NULL; + g_autofree uint8_t *iv =3D NULL; size_t ivlen =3D 16; - uint8_t *ciphertext =3D NULL; + g_autofree uint8_t *ciphertext =3D NULL; size_t ciphertextlen =3D 0; int ret =3D -1; =20 @@ -110,9 +109,6 @@ testCryptoEncrypt(const void *opaque) =20 ret =3D 0; cleanup: - VIR_FREE(enckey); - VIR_FREE(iv); - VIR_FREE(ciphertext); =20 return ret; } diff --git a/tests/virfilecachetest.c b/tests/virfilecachetest.c index 3083aee35d..5730e23b73 100644 --- a/tests/virfilecachetest.c +++ b/tests/virfilecachetest.c @@ -112,14 +112,13 @@ testFileCacheLoadFile(const char *filename, bool *outdated G_GNUC_UNUSED) { testFileCacheObj *obj; - char *data; + g_autofree char *data =3D NULL; =20 if (virFileReadAll(filename, 20, &data) < 0) return NULL; =20 obj =3D testFileCacheObjNew(data); =20 - VIR_FREE(data); return obj; } =20 diff --git a/tests/virfilemock.c b/tests/virfilemock.c index bf153ab769..d4863bd12c 100644 --- a/tests/virfilemock.c +++ b/tests/virfilemock.c @@ -105,7 +105,7 @@ statfs_mock(const char *mtab, FILE *f; struct mntent mb; char mntbuf[1024]; - char *canonPath =3D NULL; + g_autofree char *canonPath =3D NULL; int ret =3D -1; =20 if (!(f =3D real_setmntent(mtab, "r"))) { @@ -158,7 +158,6 @@ statfs_mock(const char *mtab, } =20 endmntent(f); - VIR_FREE(canonPath); return ret; } =20 diff --git a/tests/virfiletest.c b/tests/virfiletest.c index 3c1f2ce54e..019c230cea 100644 --- a/tests/virfiletest.c +++ b/tests/virfiletest.c @@ -104,7 +104,7 @@ testFileSanitizePath(const void *opaque) { const struct testFileSanitizePathData *data =3D opaque; int ret =3D -1; - char *actual; + g_autofree char *actual =3D NULL; =20 if (!(actual =3D virFileSanitizePath(data->path))) return -1; @@ -117,7 +117,6 @@ testFileSanitizePath(const void *opaque) ret =3D 0; =20 cleanup: - VIR_FREE(actual); return ret; } =20 @@ -322,7 +321,7 @@ testFileIsSharedFSType(const void *opaque G_GNUC_UNUSED) return EXIT_AM_SKIP; #else const struct testFileIsSharedFSType *data =3D opaque; - char *mtabFile =3D NULL; + g_autofree char *mtabFile =3D NULL; bool actual; int ret =3D -1; =20 @@ -343,7 +342,6 @@ testFileIsSharedFSType(const void *opaque G_GNUC_UNUSED) =20 ret =3D 0; cleanup: - VIR_FREE(mtabFile); g_unsetenv("LIBVIRT_MTAB"); return ret; #endif diff --git a/tests/virhostcputest.c b/tests/virhostcputest.c index 9e329b38b4..f935df0f63 100644 --- a/tests/virhostcputest.c +++ b/tests/virhostcputest.c @@ -31,7 +31,7 @@ linuxTestCompareFiles(const char *cpuinfofile, const char *outputfile) { int ret =3D -1; - char *actualData =3D NULL; + g_autofree char *actualData =3D NULL; virNodeInfo nodeinfo; FILE *cpuinfo; =20 @@ -68,7 +68,6 @@ linuxTestCompareFiles(const char *cpuinfofile, ret =3D 0; =20 fail: - VIR_FREE(actualData); return ret; } =20 @@ -109,7 +108,7 @@ linuxCPUStatsCompareFiles(const char *cpustatfile, const char *outfile) { int ret =3D -1; - char *actualData =3D NULL; + g_autofree char *actualData =3D NULL; FILE *cpustat =3D NULL; virNodeCPUStatsPtr params =3D NULL; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; @@ -150,7 +149,6 @@ linuxCPUStatsCompareFiles(const char *cpustatfile, =20 fail: VIR_FORCE_FCLOSE(cpustat); - VIR_FREE(actualData); VIR_FREE(params); return ret; } @@ -165,9 +163,9 @@ static int linuxTestHostCPU(const void *opaque) { int result =3D -1; - char *cpuinfo =3D NULL; - char *sysfs_prefix =3D NULL; - char *output =3D NULL; + g_autofree char *cpuinfo =3D NULL; + g_autofree char *sysfs_prefix =3D NULL; + g_autofree char *output =3D NULL; struct linuxTestHostCPUData *data =3D (struct linuxTestHostCPUData *) = opaque; const char *archStr =3D virArchToString(data->arch); =20 @@ -182,10 +180,6 @@ linuxTestHostCPU(const void *opaque) result =3D linuxTestCompareFiles(cpuinfo, data->arch, output); virFileWrapperRemovePrefix(SYSFS_SYSTEM_PATH); =20 - VIR_FREE(cpuinfo); - VIR_FREE(output); - VIR_FREE(sysfs_prefix); - return result; } =20 @@ -232,8 +226,8 @@ linuxTestNodeCPUStats(const void *data) { const struct nodeCPUStatsData *testData =3D data; int result =3D -1; - char *cpustatfile =3D NULL; - char *outfile =3D NULL; + g_autofree char *cpustatfile =3D NULL; + g_autofree g_autofree char *outfile =3D NULL; =20 cpustatfile =3D g_strdup_printf("%s/virhostcpudata/linux-cpustat-%s.st= at", abs_srcdir, testData->name); @@ -255,9 +249,6 @@ linuxTestNodeCPUStats(const void *data) } } =20 - - VIR_FREE(cpustatfile); - VIR_FREE(outfile); return result; } =20 diff --git a/tests/viriscsitest.c b/tests/viriscsitest.c index 37922ba552..7ea761fda6 100644 --- a/tests/viriscsitest.c +++ b/tests/viriscsitest.c @@ -210,7 +210,7 @@ testISCSIGetSession(const void *data) { const struct testSessionInfo *info =3D data; struct testIscsiadmCbData cbData =3D { 0 }; - char *actual_session =3D NULL; + g_autofree char *actual_session =3D NULL; int ret =3D -1; g_autoptr(virCommandDryRunToken) dryRunToken =3D virCommandDryRunToken= New(); =20 @@ -231,7 +231,6 @@ testISCSIGetSession(const void *data) ret =3D 0; =20 cleanup: - VIR_FREE(actual_session); return ret; } =20 diff --git a/tests/virkmodtest.c b/tests/virkmodtest.c index 2a85e0ae6d..2f07757c88 100644 --- a/tests/virkmodtest.c +++ b/tests/virkmodtest.c @@ -35,7 +35,7 @@ static int checkOutput(virBuffer *buf, const char *exp_cmd) { int ret =3D -1; - char *actual_cmd =3D NULL; + g_autofree char *actual_cmd =3D NULL; =20 if (!(actual_cmd =3D virBufferContentAndReset(buf))) { fprintf(stderr, "cannot compare buffer to exp: %s", exp_cmd); @@ -50,7 +50,6 @@ checkOutput(virBuffer *buf, const char *exp_cmd) ret =3D 0; =20 cleanup: - VIR_FREE(actual_cmd); return ret; } =20 @@ -59,7 +58,7 @@ static int testKModLoad(const void *args G_GNUC_UNUSED) { int ret =3D -1; - char *errbuf =3D NULL; + g_autofree char *errbuf =3D NULL; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; g_autoptr(virCommandDryRunToken) dryRunToken =3D virCommandDryRunToken= New(); =20 @@ -77,7 +76,6 @@ testKModLoad(const void *args G_GNUC_UNUSED) ret =3D 0; =20 cleanup: - VIR_FREE(errbuf); return ret; } =20 @@ -86,7 +84,7 @@ static int testKModUnload(const void *args G_GNUC_UNUSED) { int ret =3D -1; - char *errbuf =3D NULL; + g_autofree char *errbuf =3D NULL; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; g_autoptr(virCommandDryRunToken) dryRunToken =3D virCommandDryRunToken= New(); =20 @@ -104,7 +102,6 @@ testKModUnload(const void *args G_GNUC_UNUSED) ret =3D 0; =20 cleanup: - VIR_FREE(errbuf); return ret; } =20 diff --git a/tests/virmacmaptest.c b/tests/virmacmaptest.c index 4e78615029..01a3588ed9 100644 --- a/tests/virmacmaptest.c +++ b/tests/virmacmaptest.c @@ -39,7 +39,7 @@ testMACLookup(const void *opaque) GSList *macs; GSList *next; size_t i, j; - char *file =3D NULL; + g_autofree char *file =3D NULL; int ret =3D -1; =20 file =3D g_strdup_printf("%s/virmacmaptestdata/%s.json", abs_srcdir, d= ata->file); @@ -78,7 +78,6 @@ testMACLookup(const void *opaque) =20 ret =3D 0; cleanup: - VIR_FREE(file); return ret; } =20 @@ -90,7 +89,7 @@ testMACRemove(const void *opaque) g_autoptr(virMacMap) mgr =3D NULL; GSList *macs; size_t i; - char *file =3D NULL; + g_autofree char *file =3D NULL; int ret =3D -1; =20 file =3D g_strdup_printf("%s/virmacmaptestdata/%s.json", abs_srcdir, d= ata->file); @@ -115,7 +114,6 @@ testMACRemove(const void *opaque) =20 ret =3D 0; cleanup: - VIR_FREE(file); return ret; } =20 @@ -124,8 +122,8 @@ static int testMACFlush(const void *opaque) { const struct testData *data =3D opaque; - char *file =3D NULL; - char *str =3D NULL; + g_autofree char *file =3D NULL; + g_autofree char *str =3D NULL; int ret =3D -1; =20 file =3D g_strdup_printf("%s/virmacmaptestdata/%s.json", abs_srcdir, d= ata->file); @@ -138,8 +136,6 @@ testMACFlush(const void *opaque) =20 ret =3D 0; cleanup: - VIR_FREE(file); - VIR_FREE(str); return ret; } =20 diff --git a/tests/virnetdaemontest.c b/tests/virnetdaemontest.c index f764268c50..2522a4c8ea 100644 --- a/tests/virnetdaemontest.c +++ b/tests/virnetdaemontest.c @@ -270,10 +270,10 @@ static int testExecRestart(const void *opaque) int ret =3D -1; virNetDaemon *dmn =3D NULL; const struct testExecRestartData *data =3D opaque; - char *infile =3D NULL; - char *outfile =3D NULL; - char *injsonstr =3D NULL; - char *outjsonstr =3D NULL; + g_autofree char *infile =3D NULL; + g_autofree char *outfile =3D NULL; + g_autofree char *injsonstr =3D NULL; + g_autofree char *outjsonstr =3D NULL; virJSONValue *injson =3D NULL; virJSONValue *outjson =3D NULL; int fdclient[2] =3D { -1, -1 }, fdserver[2] =3D { -1, -1 }; @@ -352,10 +352,6 @@ static int testExecRestart(const void *opaque) VIR_TEST_DEBUG("Test should have failed"); ret =3D -1; } - VIR_FREE(infile); - VIR_FREE(outfile); - VIR_FREE(injsonstr); - VIR_FREE(outjsonstr); virJSONValueFree(injson); virJSONValueFree(outjson); virObjectUnref(dmn); diff --git a/tests/virnetsockettest.c b/tests/virnetsockettest.c index 8059c6cbb0..8fbbea5d30 100644 --- a/tests/virnetsockettest.c +++ b/tests/virnetsockettest.c @@ -186,7 +186,7 @@ testSocketAccept(const void *opaque) int ret =3D -1; char portstr[100]; char *tmpdir =3D NULL; - char *path =3D NULL; + g_autofree char *path =3D NULL; char template[] =3D "/tmp/libvirt_XXXXXX"; virThread th; struct testClientData cdata =3D { 0 }; @@ -296,7 +296,6 @@ testSocketAccept(const void *opaque) virObjectUnref(lsock[i]); } VIR_FREE(lsock); - VIR_FREE(path); if (tmpdir) rmdir(tmpdir); return ret; @@ -312,7 +311,7 @@ static int testSocketUNIXAddrs(const void *data G_GNUC_= UNUSED) virNetSocket *csock =3D NULL; /* Client socket */ int ret =3D -1; =20 - char *path =3D NULL; + g_autofree char *path =3D NULL; char *tmpdir; char template[] =3D "/tmp/libvirt_XXXXXX"; =20 @@ -383,7 +382,6 @@ static int testSocketUNIXAddrs(const void *data G_GNUC_= UNUSED) ret =3D 0; =20 cleanup: - VIR_FREE(path); virObjectUnref(lsock); virObjectUnref(ssock); virObjectUnref(csock); diff --git a/tests/virnetworkportxml2xmltest.c b/tests/virnetworkportxml2xm= ltest.c index 039da96490..8d29db724f 100644 --- a/tests/virnetworkportxml2xmltest.c +++ b/tests/virnetworkportxml2xmltest.c @@ -36,7 +36,7 @@ static int testCompareXMLToXMLFiles(const char *expected) { - char *actual =3D NULL; + g_autofree char *actual =3D NULL; int ret =3D -1; g_autoptr(virNetworkPortDef) dev =3D NULL; =20 @@ -51,7 +51,6 @@ testCompareXMLToXMLFiles(const char *expected) =20 ret =3D 0; cleanup: - VIR_FREE(actual); return ret; } =20 @@ -64,15 +63,12 @@ testCompareXMLToXMLHelper(const void *data) { const struct testInfo *info =3D data; int ret =3D -1; - char *xml =3D NULL; + g_autofree char *xml =3D NULL; =20 xml =3D g_strdup_printf("%s/virnetworkportxml2xmldata/%s.xml", abs_src= dir, info->name); =20 ret =3D testCompareXMLToXMLFiles(xml); - - VIR_FREE(xml); - return ret; } =20 diff --git a/tests/virnumamock.c b/tests/virnumamock.c index ff9c6e951d..6e0293a49e 100644 --- a/tests/virnumamock.c +++ b/tests/virnumamock.c @@ -41,13 +41,11 @@ bool virNumaIsAvailable(void) { if (numa_avail < 0) { - char *sysfs_node_path =3D NULL; + g_autofree char *sysfs_node_path =3D NULL; =20 sysfs_node_path =3D g_strdup_printf("%s/node", SYSFS_SYSTEM_PATH); =20 numa_avail =3D virFileExists(sysfs_node_path); - - VIR_FREE(sysfs_node_path); } =20 /* @@ -165,7 +163,7 @@ int virNumaGetNodeCPUs(int node, virBitmap **cpus) { int ret =3D -1; - char *cpulist =3D NULL; + g_autofree char *cpulist =3D NULL; =20 if (virFileReadValueString(&cpulist, "%s/node/node%u/cpulist", @@ -183,6 +181,5 @@ virNumaGetNodeCPUs(int node, virBitmap **cpus) =20 ret =3D virBitmapCountBits(*cpus); cleanup: - VIR_FREE(cpulist); return ret; } diff --git a/tests/virnwfilterbindingxml2xmltest.c b/tests/virnwfilterbindi= ngxml2xmltest.c index ba8edcfd05..ccdad3daa5 100644 --- a/tests/virnwfilterbindingxml2xmltest.c +++ b/tests/virnwfilterbindingxml2xmltest.c @@ -38,7 +38,7 @@ static int testCompareXMLToXMLFiles(const char *xml) { - char *actual =3D NULL; + g_autofree char *actual =3D NULL; int ret =3D -1; virNWFilterBindingDef *dev =3D NULL; =20 @@ -56,7 +56,6 @@ testCompareXMLToXMLFiles(const char *xml) ret =3D 0; =20 fail: - VIR_FREE(actual); virNWFilterBindingDefFree(dev); return ret; } @@ -70,15 +69,13 @@ testCompareXMLToXMLHelper(const void *data) { int result =3D -1; const test_parms *tp =3D data; - char *xml =3D NULL; + g_autofree char *xml =3D NULL; =20 xml =3D g_strdup_printf("%s/virnwfilterbindingxml2xmldata/%s.xml", abs= _srcdir, tp->name); =20 result =3D testCompareXMLToXMLFiles(xml); =20 - VIR_FREE(xml); - return result; } =20 diff --git a/tests/virpcitest.c b/tests/virpcitest.c index 1cffe6e279..1ff0330b22 100644 --- a/tests/virpcitest.c +++ b/tests/virpcitest.c @@ -32,8 +32,8 @@ static int testVirPCIDeviceCheckDriver(virPCIDevice *dev, const char *expected) { - char *path =3D NULL; - char *driver =3D NULL; + g_autofree char *path =3D NULL; + g_autofree char *driver =3D NULL; int ret =3D -1; =20 if (virPCIDeviceGetDriverPathAndName(dev, &path, &driver) < 0) @@ -49,8 +49,6 @@ testVirPCIDeviceCheckDriver(virPCIDevice *dev, const char= *expected) =20 ret =3D 0; cleanup: - VIR_FREE(path); - VIR_FREE(driver); return ret; } =20 @@ -339,7 +337,7 @@ static int mymain(void) { int ret =3D 0; - char *fakerootdir; + g_autofree char *fakerootdir =3D NULL; =20 fakerootdir =3D g_strdup(FAKEROOTDIRTEMPLATE); =20 @@ -361,12 +359,11 @@ mymain(void) struct testPCIDevData data =3D { \ domain, bus, slot, function, NULL \ }; \ - char *label =3D NULL; \ + g_autofree char *label =3D NULL; \ label =3D g_strdup_printf("%s(%04x:%02x:%02x.%x)", \ #fnc, domain, bus, slot, function); \ if (virTestRun(label, fnc, &data) < 0) \ ret =3D -1; \ - VIR_FREE(label); \ } while (0) =20 # define DO_TEST_PCI_DRIVER(domain, bus, slot, function, driver) \ @@ -374,14 +371,13 @@ mymain(void) struct testPCIDevData data =3D { \ domain, bus, slot, function, driver \ }; \ - char *label =3D NULL; \ + g_autofree char *label =3D NULL; \ label =3D g_strdup_printf("PCI driver %04x:%02x:%02x.%x is %s", \ domain, bus, slot, function, \ NULLSTR(driver)); \ if (virTestRun(label, testVirPCIDeviceCheckDriverTest, \ &data) < 0) \ ret =3D -1; \ - VIR_FREE(label); \ } while (0) =20 /* Changes made to individual devices are persistent and the @@ -419,8 +415,6 @@ mymain(void) if (getenv("LIBVIRT_SKIP_CLEANUP") =3D=3D NULL) virFileDeleteTree(fakerootdir); =20 - VIR_FREE(fakerootdir); - return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } =20 diff --git a/tests/virresctrltest.c b/tests/virresctrltest.c index b1dbf66d41..0beb9a4df4 100644 --- a/tests/virresctrltest.c +++ b/tests/virresctrltest.c @@ -18,12 +18,12 @@ static int test_virResctrlGetUnused(const void *opaque) { struct virResctrlData *data =3D (struct virResctrlData *) opaque; - char *system_dir =3D NULL; - char *resctrl_dir =3D NULL; + g_autofree char *system_dir =3D NULL; + g_autofree char *resctrl_dir =3D NULL; int ret =3D -1; g_autoptr(virResctrlAlloc) alloc =3D NULL; - char *schemata_str =3D NULL; - char *schemata_file; + g_autofree char *schemata_str =3D NULL; + g_autofree char *schemata_file =3D NULL; g_autoptr(virCaps) caps =3D NULL; =20 system_dir =3D g_strdup_printf("%s/vircaps2xmldata/linux-%s/system", a= bs_srcdir, @@ -65,10 +65,6 @@ test_virResctrlGetUnused(const void *opaque) =20 ret =3D 0; cleanup: - VIR_FREE(system_dir); - VIR_FREE(resctrl_dir); - VIR_FREE(schemata_str); - VIR_FREE(schemata_file); return ret; } =20 diff --git a/tests/virscsitest.c b/tests/virscsitest.c index 1b6a7b9ae9..d67cd23896 100644 --- a/tests/virscsitest.c +++ b/tests/virscsitest.c @@ -36,7 +36,7 @@ static char *virscsi_prefix; static int test1(const void *data G_GNUC_UNUSED) { - char *name =3D NULL; + g_autofree char *name =3D NULL; int ret =3D -1; =20 if (!(name =3D virSCSIDeviceGetDevName(virscsi_prefix, @@ -48,7 +48,6 @@ test1(const void *data G_GNUC_UNUSED) =20 ret =3D 0; cleanup: - VIR_FREE(name); return ret; } =20 @@ -66,7 +65,7 @@ test2(const void *data G_GNUC_UNUSED) bool free_dev =3D true; bool free_dev1 =3D true; virSCSIDevice *tmp =3D NULL; - char *sgname =3D NULL; + g_autofree char *sgname =3D NULL; int ret =3D -1; =20 sgname =3D virSCSIDeviceGetSgName(virscsi_prefix, @@ -152,7 +151,6 @@ test2(const void *data G_GNUC_UNUSED) =20 ret =3D 0; cleanup: - VIR_FREE(sgname); if (free_dev) virSCSIDeviceFree(dev); if (free_dev1) @@ -164,8 +162,8 @@ static int create_symlink(const char *tmpdir, const char *src_name, const char *dst_n= ame) { int ret =3D -1; - char *src_path =3D NULL; - char *dst_path =3D NULL; + g_autofree char *src_path =3D NULL; + g_autofree char *dst_path =3D NULL; =20 src_path =3D g_strdup_printf("%s/%s", virscsi_prefix, src_name); =20 @@ -179,9 +177,6 @@ create_symlink(const char *tmpdir, const char *src_name= , const char *dst_name) ret =3D 0; =20 cleanup: - VIR_FREE(src_path); - VIR_FREE(dst_path); - return ret; } =20 diff --git a/tests/virstringtest.c b/tests/virstringtest.c index 83b883524d..bbdd17da84 100644 --- a/tests/virstringtest.c +++ b/tests/virstringtest.c @@ -222,7 +222,7 @@ static int testStringReplace(const void *opaque G_GNUC_UNUSED) { const struct stringReplaceData *data =3D opaque; - char *result; + g_autofree char *result =3D NULL; int ret =3D -1; =20 result =3D virStringReplace(data->haystack, @@ -238,7 +238,6 @@ testStringReplace(const void *opaque G_GNUC_UNUSED) ret =3D 0; =20 cleanup: - VIR_FREE(result); return ret; } =20 @@ -402,7 +401,7 @@ static int testStripIPv6Brackets(const void *args) { const struct testStripData *data =3D args; int ret =3D -1; - char *res =3D NULL; + g_autofree char *res =3D NULL; =20 res =3D g_strdup(data->string); =20 @@ -417,7 +416,6 @@ static int testStripIPv6Brackets(const void *args) ret =3D 0; =20 cleanup: - VIR_FREE(res); return ret; } =20 @@ -425,7 +423,7 @@ static int testStripControlChars(const void *args) { const struct testStripData *data =3D args; int ret =3D -1; - char *res =3D NULL; + g_autofree char *res =3D NULL; =20 res =3D g_strdup(data->string); =20 @@ -440,7 +438,6 @@ static int testStripControlChars(const void *args) ret =3D 0; =20 cleanup: - VIR_FREE(res); return ret; } =20 @@ -454,7 +451,7 @@ static int testFilterChars(const void *args) { const struct testFilterData *data =3D args; int ret =3D -1; - char *res =3D NULL; + g_autofree char *res =3D NULL; =20 res =3D g_strdup(data->string); =20 @@ -469,7 +466,6 @@ static int testFilterChars(const void *args) ret =3D 0; =20 cleanup: - VIR_FREE(res); return ret; } =20 diff --git a/tests/virsystemdtest.c b/tests/virsystemdtest.c index a09b428a8a..9cf6bfec43 100644 --- a/tests/virsystemdtest.c +++ b/tests/virsystemdtest.c @@ -325,7 +325,7 @@ static int testCreateNetwork(const void *opaque G_GNUC_= UNUSED) static int testGetMachineName(const void *opaque G_GNUC_UNUSED) { - char *tmp =3D virSystemdGetMachineNameByPID(1234); + g_autofree char *tmp =3D virSystemdGetMachineNameByPID(1234); int ret =3D -1; =20 if (!tmp) { @@ -336,7 +336,6 @@ testGetMachineName(const void *opaque G_GNUC_UNUSED) if (STREQ(tmp, "qemu-demo")) ret =3D 0; =20 - VIR_FREE(tmp); return ret; } =20 @@ -371,7 +370,7 @@ testScopeName(const void *opaque) { const struct testNameData *data =3D opaque; int ret =3D -1; - char *actual =3D NULL; + g_autofree char *actual =3D NULL; =20 if (!(actual =3D virSystemdMakeScopeName(data->name, "lxc", data->lega= cy))) goto cleanup; @@ -385,7 +384,6 @@ testScopeName(const void *opaque) ret =3D 0; =20 cleanup: - VIR_FREE(actual); return ret; } =20 @@ -394,7 +392,7 @@ testMachineName(const void *opaque) { const struct testNameData *data =3D opaque; int ret =3D -1; - char *actual =3D NULL; + g_autofree char *actual =3D NULL; =20 if (!(actual =3D virDomainDriverGenerateMachineName("qemu", data->root, data->id, data->name= , true))) @@ -409,7 +407,6 @@ testMachineName(const void *opaque) ret =3D 0; =20 cleanup: - VIR_FREE(actual); return ret; } =20 diff --git a/tests/virtestmock.c b/tests/virtestmock.c index 0073677b4d..7951f3d00f 100644 --- a/tests/virtestmock.c +++ b/tests/virtestmock.c @@ -100,9 +100,9 @@ static void checkPath(const char *path, const char *func) { - char *fullPath =3D NULL; - char *relPath =3D NULL; - char *crippledPath =3D NULL; + g_autofree char *fullPath =3D NULL; + g_autofree char *relPath =3D NULL; + g_autofree char *crippledPath =3D NULL; =20 if (!g_path_is_absolute(path)) relPath =3D g_strdup_printf("./%s", path); @@ -130,10 +130,6 @@ checkPath(const char *path, printFile(path, func); } =20 - VIR_FREE(crippledPath); - VIR_FREE(relPath); - VIR_FREE(fullPath); - return; } =20 diff --git a/tests/viruritest.c b/tests/viruritest.c index 1962000bc8..96f29aafc0 100644 --- a/tests/viruritest.c +++ b/tests/viruritest.c @@ -49,7 +49,7 @@ static int testURIParse(const void *args) int ret =3D -1; virURI *uri =3D NULL; const struct URIParseData *data =3D args; - char *uristr =3D NULL; + g_autofree char *uristr =3D NULL; size_t i; bool fail =3D false; =20 @@ -134,7 +134,6 @@ static int testURIParse(const void *args) =20 ret =3D 0; cleanup: - VIR_FREE(uristr); virURIFree(uri); return ret; } diff --git a/tests/virusbmock.c b/tests/virusbmock.c index 57c9611e54..a1f539b8b1 100644 --- a/tests/virusbmock.c +++ b/tests/virusbmock.c @@ -63,7 +63,7 @@ static char *get_fake_path(const char *real_path) =20 DIR *opendir(const char *name) { - char *path; + g_autofree char *path =3D NULL; DIR* ret; =20 init_syms(); @@ -71,13 +71,12 @@ DIR *opendir(const char *name) path =3D get_fake_path(name); =20 ret =3D realopendir(path); - VIR_FREE(path); return ret; } =20 int open(const char *pathname, int flags, ...) { - char *path; + g_autofree char *path =3D NULL; int ret; va_list ap; mode_t mode =3D 0; @@ -98,7 +97,5 @@ int open(const char *pathname, int flags, ...) } =20 ret =3D realopen(path, flags, mode); - - VIR_FREE(path); return ret; } diff --git a/tests/virusbtest.c b/tests/virusbtest.c index 39a8f1a18e..74333f0105 100644 --- a/tests/virusbtest.c +++ b/tests/virusbtest.c @@ -49,7 +49,7 @@ static int testDeviceFileActor(virUSBDevice *dev, const char *path, void *opaque G_GNUC_UNUSED) { - char *str =3D NULL; + g_autofree char *str =3D NULL; int ret =3D 0; =20 str =3D g_strdup_printf(USB_DEVFS "%03d/%03d", virUSBDeviceGetBus(dev), @@ -61,7 +61,6 @@ static int testDeviceFileActor(virUSBDevice *dev, path, str); ret =3D -1; } - VIR_FREE(str); return ret; } =20 --=20 2.31.1 From nobody Fri May 3 12:48:53 2024 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=1630788418; cv=none; d=zohomail.com; s=zohoarc; b=VGjLpsV1kUkb/gDB2hqGnQHVz9MG9nUJOKwVZNYv9pR3BKdxGXsc7LE9TsYlPEm4tUSzDMt6fUXOifX8Zk+12qd9Wi3uZ+aFB5KySTA1VyKcqaFrztqsFbXqSpexKb3QbkuMBDpCyU3Yp3pSCujScyWLwAJepDLeLtHfnyUxx+g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630788418; 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=f9cnks8Qswdko9ym6PjIjtWnKYlAZvz/GyTfXkQ/oc4=; b=ZKZJzwwnCkQUglpG8qexHOFqKkdaOpY25nami2Rachwsi7zzqrIevaR7i7DgINOmJ6PKsaxBi7lPLCn5MWKnmnTb6OVkO8JVMugVyCOSgydUB09vIOiH7MujqAQMABwCaC0Jp1K6mb2ZuYUR4DtmDodJbluRLDt6w2bj2va80HM= 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 1630788418005854.134050643662; Sat, 4 Sep 2021 13:46:58 -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-589-4pZCMbtIMKe3MQqzRm0byA-1; Sat, 04 Sep 2021 16:46:55 -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 5CFE4512B; Sat, 4 Sep 2021 20:46:50 +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 C0101604CC; Sat, 4 Sep 2021 20:46:49 +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 718D21806D0F; Sat, 4 Sep 2021 20:46:49 +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 184Kiaal008815 for ; Sat, 4 Sep 2021 16:44:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id CC6642619D; Sat, 4 Sep 2021 20:44:36 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 53BB71F4 for ; Sat, 4 Sep 2021 20:44:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630788417; 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=f9cnks8Qswdko9ym6PjIjtWnKYlAZvz/GyTfXkQ/oc4=; b=BqQf8duF/jR+5qXA6n84HBRgUpYGeXrSJAxz3RYBObMXWguo6xxN/PmA8S6vx+o7xMI5TA 63duLRO4wWZ2hvepzyWvVcysldVokMFgf2tJFSjaI7Voiwydu2Okimmg1g4ZhfWucvohBR M60I6KVLNZ4ePzVM7W3k99mXbpkVJro= X-MC-Unique: 4pZCMbtIMKe3MQqzRm0byA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 11/24] tests: use g_autofree Date: Sat, 4 Sep 2021 22:44:09 +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.11 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: 1630788418754100001 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Laine Stump --- tests/domaincapstest.c | 15 +++++---------- tests/domainconftest.c | 3 +-- tests/eventtest.c | 3 +-- tests/fchosttest.c | 30 ++++++++++-------------------- tests/fdstreamtest.c | 18 ++++++------------ tests/genericxml2xmltest.c | 6 ++---- tests/interfacexml2xmltest.c | 9 +++------ tests/lxcconf2xmltest.c | 18 ++++++------------ tests/lxcxml2xmltest.c | 6 ++---- tests/metadatatest.c | 9 +++------ tests/nodedevxml2xmltest.c | 9 +++------ tests/nsstest.c | 4 +--- tests/openvzutilstest.c | 9 +++------ tests/scsihosttest.c | 12 ++++-------- tests/secretxml2xmltest.c | 7 ++----- tests/securityselinuxlabeltest.c | 9 +++------ tests/sockettest.c | 4 +--- tests/testutilslxc.c | 4 +--- tests/vboxsnapshotxmltest.c | 12 ++++-------- tests/vmwarevertest.c | 6 ++---- tests/vshtabletest.c | 24 ++++++++---------------- 21 files changed, 71 insertions(+), 146 deletions(-) diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c index 6ab14a0179..463ff83890 100644 --- a/tests/domaincapstest.c +++ b/tests/domaincapstest.c @@ -74,7 +74,7 @@ fillQemuCaps(virDomainCaps *domCaps, virQEMUDriverConfig *cfg) { int ret =3D -1; - char *path =3D NULL; + g_autofree char *path =3D NULL; g_autoptr(virQEMUCaps) qemuCaps =3D NULL; virDomainCapsLoader *loader =3D &domCaps->os.loader; virDomainVirtType virtType; @@ -127,7 +127,6 @@ fillQemuCaps(virDomainCaps *domCaps, =20 ret =3D 0; cleanup: - VIR_FREE(path); return ret; } #endif /* WITH_QEMU */ @@ -167,7 +166,7 @@ fillXenCaps(virDomainCaps *domCaps) static int fillBhyveCaps(virDomainCaps *domCaps, unsigned int *bhyve_caps) { - virDomainCapsStringValues *firmwares =3D NULL; + g_autofree virDomainCapsStringValues *firmwares =3D NULL; int ret =3D -1; =20 firmwares =3D g_new0(virDomainCapsStringValues, 1); @@ -180,7 +179,6 @@ fillBhyveCaps(virDomainCaps *domCaps, unsigned int *bhy= ve_caps) =20 ret =3D 0; cleanup: - VIR_FREE(firmwares); return ret; } #endif /* WITH_BHYVE */ @@ -208,8 +206,8 @@ test_virDomainCapsFormat(const void *opaque) { const struct testData *data =3D opaque; g_autoptr(virDomainCaps) domCaps =3D NULL; - char *path =3D NULL; - char *domCapsXML =3D NULL; + g_autofree char *path =3D NULL; + g_autofree char *domCapsXML =3D NULL; int ret =3D -1; =20 path =3D g_strdup_printf("%s/domaincapsdata/%s.xml", abs_srcdir, data-= >name); @@ -253,8 +251,6 @@ test_virDomainCapsFormat(const void *opaque) =20 ret =3D 0; cleanup: - VIR_FREE(domCapsXML); - VIR_FREE(path); return ret; } =20 @@ -400,7 +396,7 @@ mymain(void) =20 #define DO_TEST_BHYVE(Name, Emulator, BhyveCaps, Type) \ do { \ - char *name =3D NULL; \ + g_autofree char *name =3D NULL; \ name =3D g_strdup_printf("bhyve_%s.x86_64", Name); \ struct testData data =3D { \ .name =3D name, \ @@ -412,7 +408,6 @@ mymain(void) }; \ if (virTestRun(name, test_virDomainCapsFormat, &data) < 0) \ ret =3D -1; \ - VIR_FREE(name); \ } while (0) =20 DO_TEST("empty", "/bin/emulatorbin", "my-machine-type", diff --git a/tests/domainconftest.c b/tests/domainconftest.c index 66a133c13e..8b77952860 100644 --- a/tests/domainconftest.c +++ b/tests/domainconftest.c @@ -42,7 +42,7 @@ static int testGetFilesystem(const void *opaque) { int ret =3D -1; virDomainDef *def =3D NULL; - char *filename =3D NULL; + g_autofree char *filename =3D NULL; const struct testGetFilesystemData *data =3D opaque; virDomainFSDef *fsdef; =20 @@ -72,7 +72,6 @@ static int testGetFilesystem(const void *opaque) =20 cleanup: virDomainDefFree(def); - VIR_FREE(filename); return ret; } =20 diff --git a/tests/eventtest.c b/tests/eventtest.c index 7a9c87b8cf..1e93c70e74 100644 --- a/tests/eventtest.c +++ b/tests/eventtest.c @@ -89,7 +89,7 @@ G_GNUC_PRINTF(3, 4) testEventReport(const char *name, bool failed, const char *msg, ...) { va_list vargs; - char *str =3D NULL; + g_autofree char *str =3D NULL; struct testEventResultData data; =20 va_start(vargs, msg); @@ -102,7 +102,6 @@ testEventReport(const char *name, bool failed, const ch= ar *msg, ...) ignore_value(virTestRun(name, testEventResultCallback, &data)); =20 va_end(vargs); - VIR_FREE(str); } =20 static void diff --git a/tests/fchosttest.c b/tests/fchosttest.c index 53d02241ca..707dd7e410 100644 --- a/tests/fchosttest.c +++ b/tests/fchosttest.c @@ -118,11 +118,11 @@ test3(const void *data G_GNUC_UNUSED) const char *expect_fabric_wwn =3D "2001000dec9877c1"; const char *expect_max_vports =3D "127"; const char *expect_vports =3D "0"; - char *wwnn =3D NULL; - char *wwpn =3D NULL; - char *fabric_wwn =3D NULL; - char *max_vports =3D NULL; - char *vports =3D NULL; + g_autofree char *wwnn =3D NULL; + g_autofree char *wwpn =3D NULL; + g_autofree char *fabric_wwn =3D NULL; + g_autofree char *max_vports =3D NULL; + g_autofree char *vports =3D NULL; int ret =3D -1; =20 if (!(wwnn =3D virVHBAGetConfig(TEST_FC_HOST_PREFIX, TEST_FC_HOST_NUM, @@ -155,11 +155,6 @@ test3(const void *data G_GNUC_UNUSED) =20 ret =3D 0; cleanup: - VIR_FREE(wwnn); - VIR_FREE(wwpn); - VIR_FREE(fabric_wwn); - VIR_FREE(max_vports); - VIR_FREE(vports); return ret; } =20 @@ -168,7 +163,7 @@ static int test4(const void *data G_GNUC_UNUSED) { const char *expect_hostname =3D "host5"; - char *hostname =3D NULL; + g_autofree char *hostname =3D NULL; int ret =3D -1; =20 if (!(hostname =3D virVHBAGetHostByWWN(TEST_FC_HOST_PREFIX, @@ -181,7 +176,6 @@ test4(const void *data G_GNUC_UNUSED) =20 ret =3D 0; cleanup: - VIR_FREE(hostname); return ret; } =20 @@ -193,7 +187,7 @@ static int test5(const void *data G_GNUC_UNUSED) { const char *expect_hostname =3D "host5"; - char *hostname =3D NULL; + g_autofree char *hostname =3D NULL; int ret =3D -1; =20 if (!(hostname =3D virVHBAFindVportHost(TEST_FC_HOST_PREFIX))) @@ -204,7 +198,6 @@ test5(const void *data G_GNUC_UNUSED) =20 ret =3D 0; cleanup: - VIR_FREE(hostname); return ret; } =20 @@ -214,9 +207,9 @@ test6(const void *data G_GNUC_UNUSED) { const char *expect_wwnn =3D "2002001b32a9da4e"; const char *expect_wwpn =3D "2102001b32a9da4e"; - char *wwnn =3D NULL; - char *wwpn =3D NULL; - char *fabric_wwn =3D NULL; + g_autofree char *wwnn =3D NULL; + g_autofree char *wwpn =3D NULL; + g_autofree char *fabric_wwn =3D NULL; int ret =3D -1; =20 if (!(wwnn =3D virVHBAGetConfig(TEST_FC_HOST_PREFIX, TEST_FC_HOST_NUM_= NO_FAB, @@ -238,9 +231,6 @@ test6(const void *data G_GNUC_UNUSED) =20 ret =3D 0; cleanup: - VIR_FREE(wwnn); - VIR_FREE(wwpn); - VIR_FREE(fabric_wwn); return ret; } =20 diff --git a/tests/fdstreamtest.c b/tests/fdstreamtest.c index 7a2fe27477..182c853b33 100644 --- a/tests/fdstreamtest.c +++ b/tests/fdstreamtest.c @@ -39,10 +39,10 @@ VIR_LOG_INIT("tests.fdstreamtest"); static int testFDStreamReadCommon(const char *scratchdir, bool blocking) { int fd =3D -1; - char *file =3D NULL; + g_autofree char *file =3D NULL; int ret =3D -1; - char *pattern =3D NULL; - char *buf =3D NULL; + g_autofree char *pattern =3D NULL; + g_autofree char *buf =3D NULL; virStreamPtr st =3D NULL; size_t i; virConnectPtr conn =3D NULL; @@ -149,9 +149,6 @@ static int testFDStreamReadCommon(const char *scratchdi= r, bool blocking) unlink(file); if (conn) virConnectClose(conn); - VIR_FREE(file); - VIR_FREE(pattern); - VIR_FREE(buf); return ret; } =20 @@ -169,10 +166,10 @@ static int testFDStreamReadNonblock(const void *data) static int testFDStreamWriteCommon(const char *scratchdir, bool blocking) { int fd =3D -1; - char *file =3D NULL; + g_autofree char *file =3D NULL; int ret =3D -1; - char *pattern =3D NULL; - char *buf =3D NULL; + g_autofree char *pattern =3D NULL; + g_autofree char *buf =3D NULL; virStreamPtr st =3D NULL; size_t i; virConnectPtr conn =3D NULL; @@ -292,9 +289,6 @@ static int testFDStreamWriteCommon(const char *scratchd= ir, bool blocking) unlink(file); if (conn) virConnectClose(conn); - VIR_FREE(file); - VIR_FREE(pattern); - VIR_FREE(buf); return ret; } =20 diff --git a/tests/genericxml2xmltest.c b/tests/genericxml2xmltest.c index 39fd6d403a..a6f974e758 100644 --- a/tests/genericxml2xmltest.c +++ b/tests/genericxml2xmltest.c @@ -26,8 +26,8 @@ static int testCompareXMLToXMLHelper(const void *data) { const struct testInfo *info =3D data; - char *xml_in =3D NULL; - char *xml_out =3D NULL; + g_autofree char *xml_in =3D NULL; + g_autofree char *xml_out =3D NULL; int ret =3D -1; =20 xml_in =3D g_strdup_printf("%s/genericxml2xmlindata/%s.xml", @@ -39,8 +39,6 @@ testCompareXMLToXMLHelper(const void *data) info->different ? xml_out : xml_in, info->active_only, 0, info->expectResult); - VIR_FREE(xml_in); - VIR_FREE(xml_out); return ret; } =20 diff --git a/tests/interfacexml2xmltest.c b/tests/interfacexml2xmltest.c index 3785467f84..8235e701a9 100644 --- a/tests/interfacexml2xmltest.c +++ b/tests/interfacexml2xmltest.c @@ -16,8 +16,8 @@ static int testCompareXMLToXMLFiles(const char *xml) { - char *xmlData =3D NULL; - char *actual =3D NULL; + g_autofree char *xmlData =3D NULL; + g_autofree char *actual =3D NULL; int ret =3D -1; virInterfaceDef *dev =3D NULL; =20 @@ -38,8 +38,6 @@ testCompareXMLToXMLFiles(const char *xml) ret =3D 0; =20 fail: - VIR_FREE(xmlData); - VIR_FREE(actual); virInterfaceDefFree(dev); return ret; } @@ -48,14 +46,13 @@ static int testCompareXMLToXMLHelper(const void *data) { int result =3D -1; - char *xml =3D NULL; + g_autofree char *xml =3D NULL; =20 xml =3D g_strdup_printf("%s/interfaceschemadata/%s.xml", abs_srcdir, (const char *)data); =20 result =3D testCompareXMLToXMLFiles(xml); =20 - VIR_FREE(xml); return result; } =20 diff --git a/tests/lxcconf2xmltest.c b/tests/lxcconf2xmltest.c index df7756c931..99473a0b89 100644 --- a/tests/lxcconf2xmltest.c +++ b/tests/lxcconf2xmltest.c @@ -26,8 +26,8 @@ testCompareXMLToConfigFiles(const char *xmlfile, bool expectError) { int ret =3D -1; - char *config =3D NULL; - char *actualxml =3D NULL; + g_autofree char *config =3D NULL; + g_autofree char *actualxml =3D NULL; virDomainDef *vmdef =3D NULL; =20 if (virTestLoadFile(configfile, &config) < 0) @@ -51,8 +51,6 @@ testCompareXMLToConfigFiles(const char *xmlfile, ret =3D 0; =20 fail: - VIR_FREE(actualxml); - VIR_FREE(config); virDomainDefFree(vmdef); return ret; } @@ -67,8 +65,8 @@ testCompareXMLToConfigHelperLegacy(const void *data) { int result =3D -1; const struct testInfo *info =3D data; - char *xml =3D NULL; - char *config =3D NULL; + g_autofree char *xml =3D NULL; + g_autofree char *config =3D NULL; =20 xml =3D g_strdup_printf("%s/lxcconf2xmldata/lxcconf2xml-%s.xml", abs_srcdir, info->name); @@ -77,8 +75,6 @@ testCompareXMLToConfigHelperLegacy(const void *data) =20 result =3D testCompareXMLToConfigFiles(xml, config, info->expectError); =20 - VIR_FREE(xml); - VIR_FREE(config); return result; } =20 @@ -87,8 +83,8 @@ testCompareXMLToConfigHelperV3(const void *data) { int result =3D -1; const struct testInfo *info =3D data; - char *xml =3D NULL; - char *config =3D NULL; + g_autofree char *xml =3D NULL; + g_autofree char *config =3D NULL; =20 xml =3D g_strdup_printf("%s/lxcconf2xmldata/lxcconf2xml-%s.xml", abs_srcdir, info->name); @@ -97,8 +93,6 @@ testCompareXMLToConfigHelperV3(const void *data) =20 result =3D testCompareXMLToConfigFiles(xml, config, info->expectError); =20 - VIR_FREE(xml); - VIR_FREE(config); return result; } =20 diff --git a/tests/lxcxml2xmltest.c b/tests/lxcxml2xmltest.c index 69c333b9b5..8ab32acf42 100644 --- a/tests/lxcxml2xmltest.c +++ b/tests/lxcxml2xmltest.c @@ -29,8 +29,8 @@ static int testCompareXMLToXMLHelper(const void *data) { const struct testInfo *info =3D data; - char *xml_in =3D NULL; - char *xml_out =3D NULL; + g_autofree char *xml_in =3D NULL; + g_autofree char *xml_out =3D NULL; int ret =3D -1; =20 xml_in =3D g_strdup_printf("%s/lxcxml2xmldata/lxc-%s.xml", @@ -43,8 +43,6 @@ testCompareXMLToXMLHelper(const void *data) info->active_only, info->parse_flags, TEST_COMPARE_DOM_XML2XML_RESULT_SUCCE= SS); - VIR_FREE(xml_in); - VIR_FREE(xml_out); return ret; } =20 diff --git a/tests/metadatatest.c b/tests/metadatatest.c index e565383ce2..5112912161 100644 --- a/tests/metadatatest.c +++ b/tests/metadatatest.c @@ -92,8 +92,8 @@ verifyMetadata(virDomainPtr dom, const char *uri) { bool ret =3D false; - char *metadataXML =3D NULL; - char *metadataAPI =3D NULL; + g_autofree char *metadataXML =3D NULL; + g_autofree char *metadataAPI =3D NULL; =20 if (!expectAPI) { if ((metadataAPI =3D virDomainGetMetadata(dom, @@ -147,8 +147,6 @@ verifyMetadata(virDomainPtr dom, ret =3D true; =20 cleanup: - VIR_FREE(metadataXML); - VIR_FREE(metadataAPI); =20 return ret; } @@ -214,7 +212,7 @@ static int testTextMetadata(const void *data) { const struct metadataTest *test =3D data; - char *actual =3D NULL; + g_autofree char *actual =3D NULL; int ret =3D -1; =20 if (virDomainSetMetadata(test->dom, test->type, test->data, NULL, NULL= , 0) < 0) { @@ -236,7 +234,6 @@ testTextMetadata(const void *data) ret =3D 0; =20 cleanup: - VIR_FREE(actual); =20 return ret; } diff --git a/tests/nodedevxml2xmltest.c b/tests/nodedevxml2xmltest.c index d8f81456ee..9e32e7d553 100644 --- a/tests/nodedevxml2xmltest.c +++ b/tests/nodedevxml2xmltest.c @@ -16,8 +16,8 @@ static int testCompareXMLToXMLFiles(const char *xml, const char *outfile) { - char *xmlData =3D NULL; - char *actual =3D NULL; + g_autofree char *xmlData =3D NULL; + g_autofree char *actual =3D NULL; int ret =3D -1; virNodeDeviceDef *dev =3D NULL; virNodeDevCapsDef *caps; @@ -59,8 +59,6 @@ testCompareXMLToXMLFiles(const char *xml, const char *out= file) ret =3D 0; =20 fail: - VIR_FREE(xmlData); - VIR_FREE(actual); virNodeDeviceDefFree(dev); return ret; } @@ -69,7 +67,7 @@ static int testCompareXMLToXMLHelper(const void *data) { int result =3D -1; - char *xml =3D NULL; + g_autofree char *xml =3D NULL; g_autofree char *outfile =3D NULL; =20 xml =3D g_strdup_printf("%s/nodedevschemadata/%s.xml", abs_srcdir, @@ -80,7 +78,6 @@ testCompareXMLToXMLHelper(const void *data) =20 result =3D testCompareXMLToXMLFiles(xml, outfile); =20 - VIR_FREE(xml); return result; } =20 diff --git a/tests/nsstest.c b/tests/nsstest.c index a4e8a4a37f..2c2e57769b 100644 --- a/tests/nsstest.c +++ b/tests/nsstest.c @@ -118,7 +118,7 @@ testGetHostByName(const void *opaque) i =3D 0; while (*addrList) { virSocketAddr sa; - char *ipAddr; + g_autofree char *ipAddr =3D NULL; void *address =3D *addrList; =20 memset(&sa, 0, sizeof(sa)); @@ -138,10 +138,8 @@ testGetHostByName(const void *opaque) virReportError(VIR_ERR_INTERNAL_ERROR, "Unexpected address %s, expecting %s", ipAddr, NULLSTR(data->ipAddr[i])); - VIR_FREE(ipAddr); return -1; } - VIR_FREE(ipAddr); =20 addrList++; i++; diff --git a/tests/openvzutilstest.c b/tests/openvzutilstest.c index ddb2fcbe6c..10cf307d61 100644 --- a/tests/openvzutilstest.c +++ b/tests/openvzutilstest.c @@ -38,8 +38,8 @@ testReadConfigParam(const void *data G_GNUC_UNUSED) { int result =3D -1; size_t i; - char *conf =3D NULL; - char *value =3D NULL; + g_autofree char *conf =3D NULL; + g_autofree char *value =3D NULL; =20 conf =3D g_strdup_printf("%s/openvzutilstest.conf", abs_srcdir); =20 @@ -61,8 +61,6 @@ testReadConfigParam(const void *data G_GNUC_UNUSED) result =3D 0; =20 cleanup: - VIR_FREE(conf); - VIR_FREE(value); =20 return result; } @@ -72,7 +70,7 @@ testReadNetworkConf(const void *data G_GNUC_UNUSED) { int result =3D -1; virDomainDef *def =3D NULL; - char *actual =3D NULL; + g_autofree char *actual =3D NULL; const char *expected =3D "\n" " 00000000-0000-0000-0000-000000000000\n" @@ -133,7 +131,6 @@ testReadNetworkConf(const void *data G_GNUC_UNUSED) cleanup: virObjectUnref(driver.xmlopt); virObjectUnref(driver.caps); - VIR_FREE(actual); virDomainDefFree(def); =20 return result; diff --git a/tests/scsihosttest.c b/tests/scsihosttest.c index 7508ac37a3..336b3cc496 100644 --- a/tests/scsihosttest.c +++ b/tests/scsihosttest.c @@ -67,8 +67,8 @@ static int create_scsihost(const char *fakesysfsdir, const char *devicepath, const char *unique_id, const char *hostname) { - char *unique_id_path =3D NULL; - char *link_path =3D NULL; + g_autofree char *unique_id_path =3D NULL; + g_autofree char *link_path =3D NULL; char *spot; int ret =3D -1; int fd =3D -1; @@ -137,8 +137,6 @@ create_scsihost(const char *fakesysfsdir, const char *d= evicepath, =20 cleanup: VIR_FORCE_CLOSE(fd); - VIR_FREE(unique_id_path); - VIR_FREE(link_path); return ret; } =20 @@ -242,8 +240,8 @@ static int mymain(void) { int ret =3D -1; - char *fakerootdir =3D NULL; - char *fakesysfsdir =3D NULL; + g_autofree char *fakerootdir =3D NULL; + g_autofree char *fakesysfsdir =3D NULL; =20 fakerootdir =3D g_strdup(FAKEROOTDIRTEMPLATE); =20 @@ -279,8 +277,6 @@ mymain(void) cleanup: if (getenv("LIBVIRT_SKIP_CLEANUP") =3D=3D NULL) virFileDeleteTree(fakerootdir); - VIR_FREE(fakerootdir); - VIR_FREE(fakesysfsdir); VIR_FREE(scsihost_class_path); return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/tests/secretxml2xmltest.c b/tests/secretxml2xmltest.c index 48f48416b5..62b82b4a24 100644 --- a/tests/secretxml2xmltest.c +++ b/tests/secretxml2xmltest.c @@ -40,8 +40,8 @@ static int testCompareXMLToXMLHelper(const void *data) { int result =3D -1; - char *inxml =3D NULL; - char *outxml =3D NULL; + g_autofree char *inxml =3D NULL; + g_autofree char *outxml =3D NULL; const struct testInfo *info =3D data; =20 inxml =3D g_strdup_printf("%s/secretxml2xmlin/%s.xml", abs_srcdir, inf= o->name); @@ -52,9 +52,6 @@ testCompareXMLToXMLHelper(const void *data) =20 result =3D testCompareXMLToXMLFiles(inxml, outxml); =20 - VIR_FREE(inxml); - VIR_FREE(outxml); - return result; } =20 diff --git a/tests/securityselinuxlabeltest.c b/tests/securityselinuxlabelt= est.c index f7dd3c866a..cd604eda31 100644 --- a/tests/securityselinuxlabeltest.c +++ b/tests/securityselinuxlabeltest.c @@ -59,7 +59,7 @@ testUserXattrEnabled(void) int ret =3D -1; ssize_t len; const char *con_value =3D "system_u:object_r:svirt_image_t:s0:c41,c264= "; - char *path =3D NULL; + g_autofree char *path =3D NULL; path =3D g_strdup_printf("%s/securityselinuxlabeldata/testxattr", abs_= builddir); =20 if (g_mkdir_with_parents(abs_builddir "/securityselinuxlabeldata", 077= 7) < 0 || @@ -79,7 +79,6 @@ testUserXattrEnabled(void) cleanup: unlink(path); rmdir(abs_builddir "/securityselinuxlabeldata"); - VIR_FREE(path); return ret; } =20 @@ -101,9 +100,9 @@ testSELinuxLoadFileList(const char *testname, size_t *nfiles) { int ret =3D -1; - char *path =3D NULL; + g_autofree char *path =3D NULL; FILE *fp =3D NULL; - char *line =3D NULL; + g_autofree char *line =3D NULL; =20 *files =3D NULL; *nfiles =3D 0; @@ -153,8 +152,6 @@ testSELinuxLoadFileList(const char *testname, =20 cleanup: VIR_FORCE_FCLOSE(fp); - VIR_FREE(path); - VIR_FREE(line); return ret; } =20 diff --git a/tests/sockettest.c b/tests/sockettest.c index e9654fcebb..332def2c93 100644 --- a/tests/sockettest.c +++ b/tests/sockettest.c @@ -43,7 +43,7 @@ static int testParse(virSocketAddr *addr, const char *add= rstr, int family, bool =20 static int testFormat(virSocketAddr *addr, const char *addrstr, bool pass) { - char *newaddrstr; + g_autofree char *newaddrstr =3D NULL; =20 newaddrstr =3D virSocketAddrFormat(addr); if (!newaddrstr) @@ -51,10 +51,8 @@ static int testFormat(virSocketAddr *addr, const char *a= ddrstr, bool pass) =20 if (STRNEQ(newaddrstr, addrstr)) { virTestDifference(stderr, addrstr, newaddrstr); - VIR_FREE(newaddrstr); return pass ? -1 : 0; } else { - VIR_FREE(newaddrstr); return pass ? 0 : -1; } } diff --git a/tests/testutilslxc.c b/tests/testutilslxc.c index 9ab57f7ccb..0139de7437 100644 --- a/tests/testutilslxc.c +++ b/tests/testutilslxc.c @@ -39,15 +39,13 @@ testLXCCapsInit(void) =20 =20 if (virTestGetDebug()) { - char *caps_str; + g_autofree char *caps_str =3D NULL; =20 caps_str =3D virCapabilitiesFormatXML(caps); if (!caps_str) goto error; =20 VIR_TEST_DEBUG("LXC driver capabilities:\n%s", caps_str); - - VIR_FREE(caps_str); } =20 return caps; diff --git a/tests/vboxsnapshotxmltest.c b/tests/vboxsnapshotxmltest.c index f5f8fe36b9..da39561456 100644 --- a/tests/vboxsnapshotxmltest.c +++ b/tests/vboxsnapshotxmltest.c @@ -46,9 +46,9 @@ testFilterXML(char *xml) static int testCompareXMLtoXMLFiles(const char *xml) { - char *xmlData =3D NULL; - char *actual =3D NULL; - char *pathResult =3D NULL; + g_autofree char *xmlData =3D NULL; + g_autofree char *actual =3D NULL; + g_autofree char *pathResult =3D NULL; int ret =3D -1; virVBoxSnapshotConfMachine *machine =3D NULL; =20 @@ -84,10 +84,7 @@ testCompareXMLtoXMLFiles(const char *xml) cleanup: unlink(pathResult); rmdir(abs_builddir "/vboxsnapshotxmldata"); - VIR_FREE(xmlData); - VIR_FREE(actual); virVBoxSnapshotConfMachineFree(machine); - VIR_FREE(pathResult); =20 return ret; } @@ -96,14 +93,13 @@ static int testCompareXMLToXMLHelper(const void *data) { int result =3D -1; - char *xml =3D NULL; + g_autofree char *xml =3D NULL; =20 xml =3D g_strdup_printf("%s/vboxsnapshotxmldata/%s.vbox", abs_srcdir, (const char *)data); =20 result =3D testCompareXMLtoXMLFiles(xml); =20 - VIR_FREE(xml); return result; } =20 diff --git a/tests/vmwarevertest.c b/tests/vmwarevertest.c index fa909ad022..7cb358795f 100644 --- a/tests/vmwarevertest.c +++ b/tests/vmwarevertest.c @@ -38,8 +38,8 @@ testVerStrParse(const void *data) { const struct testInfo *info =3D data; int ret =3D -1; - char *path =3D NULL; - char *databuf =3D NULL; + g_autofree char *path =3D NULL; + g_autofree char *databuf =3D NULL; unsigned long version; int vmware_type; =20 @@ -63,8 +63,6 @@ testVerStrParse(const void *data) ret =3D 0; =20 cleanup: - VIR_FREE(path); - VIR_FREE(databuf); return ret; } =20 diff --git a/tests/vshtabletest.c b/tests/vshtabletest.c index 41c33b1701..804aaf4d9c 100644 --- a/tests/vshtabletest.c +++ b/tests/vshtabletest.c @@ -119,7 +119,7 @@ static int testUnicode(const void *opaque G_GNUC_UNUSED) { int ret =3D 0; - char *act =3D NULL; + g_autofree char *act =3D NULL; =20 const char *exp =3D " Id =E5=90=8D=E7=A8=B1 =D0=B3=D0=BE=D1=81=D1= =83=D0=B4=D0=B0=D1=80=D1=81=D1=82=D0=B2=D0=BE\n" @@ -141,7 +141,6 @@ testUnicode(const void *opaque G_GNUC_UNUSED) ret =3D -1; =20 cleanup: - VIR_FREE(act); vshTableFree(table); return ret; } @@ -151,7 +150,7 @@ static int testUnicodeArabic(const void *opaque G_GNUC_UNUSED) { int ret =3D 0; - char *act =3D NULL; + g_autofree char *act =3D NULL; =20 const char *exp =3D " =EF=BB=A1=EF=BA=8D =EF=BB=A2=EF=BB=A3=EF=BA=8D =EF=BB=95=EF=BA= =8E=EF=BA=8C=EF=BB=A3=EF=BA=93 =EF=BA=93 =EF=BA=8E=EF=BB=A0=EF=BA=BC=EF= =BB=8B =EF=BA=8D=EF=BB=B8= =EF=BA=9C=EF=BB=A7=EF=BA=8E=EF=BB=A7\n" @@ -184,7 +183,6 @@ testUnicodeArabic(const void *opaque G_GNUC_UNUSED) ret =3D -1; =20 cleanup: - VIR_FREE(act); vshTableFree(table); return ret; } @@ -200,7 +198,7 @@ testUnicodeZeroWidthChar(const void *opaque G_GNUC_UNUS= ED) "--------------------------\n" " 1\u200B fedora28 run\u200Bning\n" " 2 rhel7.5 running\n"; - char *act =3D NULL; + g_autofree char *act =3D NULL; wchar_t wc; =20 /* If this char is not classed as printable, the actual @@ -222,7 +220,6 @@ testUnicodeZeroWidthChar(const void *opaque G_GNUC_UNUS= ED) ret =3D -1; =20 cleanup: - VIR_FREE(act); vshTableFree(table); return ret; } @@ -237,7 +234,7 @@ testUnicodeCombiningChar(const void *opaque G_GNUC_UNUS= ED) "--------------------------\n" " 1 f=C4=9Bdora28 running\n" " 2 rhel running\n"; - char *act =3D NULL; + g_autofree char *act =3D NULL; =20 table =3D vshTableNew("Id", "N=C3=A1me", "=E2=93=88tatus", NULL); if (!table) @@ -250,7 +247,6 @@ testUnicodeCombiningChar(const void *opaque G_GNUC_UNUS= ED) ret =3D -1; =20 cleanup: - VIR_FREE(act); vshTableFree(table); return ret; } @@ -266,7 +262,7 @@ testUnicodeNonPrintableChar(const void *opaque G_GNUC_U= NUSED) "----------------------------------\n" " 1 f\\x07edora28 running\n" " 2 rhel7.5 running\n"; - char *act =3D NULL; + g_autofree char *act =3D NULL; =20 table =3D vshTableNew("I\td", "Name", "Status", NULL); if (!table) @@ -279,7 +275,6 @@ testUnicodeNonPrintableChar(const void *opaque G_GNUC_U= NUSED) ret =3D -1; =20 cleanup: - VIR_FREE(act); vshTableFree(table); return ret; } @@ -307,9 +302,9 @@ testNTables(const void *opaque G_GNUC_UNUSED) " 2\n" " 3\n" " 4\n"; - char *act1 =3D NULL; - char *act2 =3D NULL; - char *act3 =3D NULL; + g_autofree char *act1 =3D NULL; + g_autofree char *act2 =3D NULL; + g_autofree char *act3 =3D NULL; =20 table1 =3D vshTableNew("Id", "Name", "Status", NULL); if (!table1) @@ -341,9 +336,6 @@ testNTables(const void *opaque G_GNUC_UNUSED) ret =3D -1; =20 cleanup: - VIR_FREE(act1); - VIR_FREE(act2); - VIR_FREE(act3); vshTableFree(table1); vshTableFree(table2); vshTableFree(table3); --=20 2.31.1 From nobody Fri May 3 12:48:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1630788420; cv=none; d=zohomail.com; s=zohoarc; b=NkKG/MUgoQUZaV19yWoDlDNNROv3zsvEtM+QCNd9s5cp1cndcyqmR6LRr9I/N2yr+uxDq7Aggq7ZzhUPIWI/5D5rITsWLpvJ90XMHRKxaSUoxoSazBMX1EiYoT+HxSoKpggu0Dtom7A3A9DYcpwxca9uXLWnfNpzimgg2lSBV4A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630788420; 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=/6GCfwG4IqdMn7D+xX4mQ+oCv7PZcnyyY9iB+neaT0M=; b=FKu17QhSMvWGfgWyOjayBDGSJnNSznm8MANkj46vzCgF5SdBKSOHb4IFTYCwCnR3QmdZuRPMB2rDYuDzFG1KxGvaEsf/QHqHiFNUdm7GRNQ3CCeHBOd3IBxqlaAlaPyPkeKmPK2DWXrprYvS0AMB11gKnf+c07GAaCk7/nfI5mQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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 [170.10.133.124]) by mx.zohomail.com with SMTPS id 1630788420605355.95856849405527; Sat, 4 Sep 2021 13:47:00 -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-170-aQmiNE-pMgSgZLkDKdvP9w-1; Sat, 04 Sep 2021 16:46:57 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2DFEF18460E3; Sat, 4 Sep 2021 20:46:53 +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 10AF95C1CF; Sat, 4 Sep 2021 20:46:53 +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 D73D244A5F; Sat, 4 Sep 2021 20:46:52 +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 184KibJZ008828 for ; Sat, 4 Sep 2021 16:44:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9C0372619D; Sat, 4 Sep 2021 20:44:37 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 25D3B1F4 for ; Sat, 4 Sep 2021 20:44:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630788419; 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=/6GCfwG4IqdMn7D+xX4mQ+oCv7PZcnyyY9iB+neaT0M=; b=ZwzKHBUviVlhl0sSWjGhQKX+Ato8zm20HO/o2nQ1H5XeSjMgDLjubcaxB2sQRh13g1wQBz wx2f/GpHgRvu8Kh8gOpmo6qtPnCKbRdcA6QeTAEb5gLO82rT+U1rwX4MMuG64wvfJip+tY EBXs4jDpY6ErACJ/B9bopHmUFOIu2Q0= X-MC-Unique: aQmiNE-pMgSgZLkDKdvP9w-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 12/24] tests: use g_autoptr instead of virJSONValueFree Date: Sat, 4 Sep 2021 22:44:10 +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.16 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: 1630788422749100005 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Laine Stump --- tests/qemucapsprobemock.c | 3 +-- tests/qemucommandutiltest.c | 3 +-- tests/qemumonitorjsontest.c | 12 ++++-------- tests/virnetdaemontest.c | 3 +-- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/tests/qemucapsprobemock.c b/tests/qemucapsprobemock.c index 00670101ce..27539d04a1 100644 --- a/tests/qemucapsprobemock.c +++ b/tests/qemucapsprobemock.c @@ -87,7 +87,7 @@ qemuMonitorJSONIOProcessLine(qemuMonitor *mon, const char *line, qemuMonitorMessage *msg) { - virJSONValue *value =3D NULL; + g_autoptr(virJSONValue) value =3D NULL; g_autofree char *json =3D NULL; int ret; =20 @@ -115,6 +115,5 @@ qemuMonitorJSONIOProcessLine(qemuMonitor *mon, } =20 cleanup: - virJSONValueFree(value); return ret; } diff --git a/tests/qemucommandutiltest.c b/tests/qemucommandutiltest.c index 6b5e477849..e1cab0be90 100644 --- a/tests/qemucommandutiltest.c +++ b/tests/qemucommandutiltest.c @@ -37,7 +37,7 @@ static int testQemuCommandBuildFromJSON(const void *opaque) { const testQemuCommandBuildObjectFromJSONData *data =3D opaque; - virJSONValue *val =3D NULL; + g_autoptr(virJSONValue) val =3D NULL; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; g_autofree char *result =3D NULL; int ret =3D -1; @@ -65,7 +65,6 @@ testQemuCommandBuildFromJSON(const void *opaque) =20 ret =3D 0; cleanup: - virJSONValueFree(val); return ret; } =20 diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index c64c5c6b6f..542b35850e 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -2507,8 +2507,8 @@ testBlockNodeNameDetect(const void *opaque) const char *pathprefix =3D "qemumonitorjsondata/qemumonitorjson-nodena= me-"; g_autofree char *resultFile =3D NULL; g_autofree char *actual =3D NULL; - virJSONValue *namedNodesJson =3D NULL; - virJSONValue *blockstatsJson =3D NULL; + g_autoptr(virJSONValue) namedNodesJson =3D NULL; + g_autoptr(virJSONValue) blockstatsJson =3D NULL; GHashTable *nodedata =3D NULL; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; int ret =3D -1; @@ -2541,8 +2541,6 @@ testBlockNodeNameDetect(const void *opaque) =20 cleanup: virHashFree(nodedata); - virJSONValueFree(namedNodesJson); - virJSONValueFree(blockstatsJson); =20 return ret; } @@ -2584,7 +2582,7 @@ testQAPISchemaValidate(const void *opaque) const struct testQAPISchemaData *data =3D opaque; g_auto(virBuffer) debug =3D VIR_BUFFER_INITIALIZER; virJSONValue *schemaroot; - virJSONValue *json =3D NULL; + g_autoptr(virJSONValue) json =3D NULL; int ret =3D -1; =20 if (virQEMUQAPISchemaPathGet(data->query, data->schema, &schemaroot) <= 0) @@ -2610,7 +2608,6 @@ testQAPISchemaValidate(const void *opaque) =20 =20 cleanup: - virJSONValueFree(json); return ret; } =20 @@ -2927,7 +2924,7 @@ mymain(void) virQEMUDriver driver; testQemuMonitorJSONSimpleFuncData simpleFunc; struct testQAPISchemaData qapiData; - virJSONValue *metaschema =3D NULL; + g_autoptr(virJSONValue) metaschema =3D NULL; g_autofree char *metaschemastr =3D NULL; =20 if (qemuTestDriverInit(&driver) < 0) @@ -3220,7 +3217,6 @@ mymain(void) DO_TEST(qemuMonitorJSONGetCPUModelBaseline); =20 cleanup: - virJSONValueFree(metaschema); virHashFree(qapiData.schema); qemuTestDriverFree(&driver); return (ret =3D=3D 0) ? EXIT_SUCCESS : EXIT_FAILURE; diff --git a/tests/virnetdaemontest.c b/tests/virnetdaemontest.c index 2522a4c8ea..70af1480df 100644 --- a/tests/virnetdaemontest.c +++ b/tests/virnetdaemontest.c @@ -188,7 +188,7 @@ static char *testGenerateJSON(const char *server_name) { virNetDaemon *dmn =3D NULL; virNetServer *srv =3D NULL; - virJSONValue *json =3D NULL; + g_autoptr(virJSONValue) json =3D NULL; char *jsonstr =3D NULL; bool has_ipv4, has_ipv6; =20 @@ -226,7 +226,6 @@ static char *testGenerateJSON(const char *server_name) virNetServerClose(srv); virObjectUnref(srv); virObjectUnref(dmn); - virJSONValueFree(json); if (!jsonstr) virDispatchError(NULL); return jsonstr; --=20 2.31.1 From nobody Fri May 3 12:48:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1630789649; cv=none; d=zohomail.com; s=zohoarc; b=DTBfTNrForQAY+1QAD7XJRf49lDc324sDkzQDZYX20jr4Yif/8sl0pnEapaQFBtpxbmQDfx5QOeENo7uaGb5X8hKC9uPia4wvHA5NCpEfpV3w2p5AwU1/pN5MTrQs8PSzXO1Peo8sy1fS0IQvrO8QN8YsEmXrsLiKQUKp95eXM8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630789649; 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=b02apZKTW2VNR4Qmp3YsE8qnFgJH/BaEU1QkWSV6sZk=; b=XhUrd75kdFk0iYC6z6b4qXzW3PdK9OSlnbpEdOmCY1ViAdJO82PtNCaNvC380qq3cy/GHGEwWEuAgmbt7LGFFyr9JO2bG+Nmc9a3VpNLblrejkx3fkOjmyV9cdNNoBjBUTKdCaR+0eflghFhar0tnwRTFelk196a9xhmd4Jjl5k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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 [170.10.133.124]) by mx.zohomail.com with SMTPS id 1630789649358411.70009442871446; Sat, 4 Sep 2021 14:07:29 -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-422-1Z9RMJWMP82ZQrOyfFhjVQ-1; Sat, 04 Sep 2021 17:07:26 -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 8C383800FEF; Sat, 4 Sep 2021 21:07: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 7284C6E6E7; Sat, 4 Sep 2021 21:07: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 43BA018087F1; Sat, 4 Sep 2021 21:07:21 +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 184Kicf1008834 for ; Sat, 4 Sep 2021 16:44:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6CC321F4; Sat, 4 Sep 2021 20:44:38 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id E9D5926367 for ; Sat, 4 Sep 2021 20:44:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630789648; 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=b02apZKTW2VNR4Qmp3YsE8qnFgJH/BaEU1QkWSV6sZk=; b=dpVPE84hUkzHtXYX2BwZOtVlGNAst6z5XpQ6QQ6o+ovbtAe8/nDSsCJ1GF6b45pQ8HfKA6 ptP/DsDgi1seN0ddqThLYJO0quC9A0Ig/UAyp+CKnDtSLaj9FwOYxxkFJrF6jX8F1peJSC tbvenlzMVX/IdnjmL1Bvnt+caJV07rM= X-MC-Unique: 1Z9RMJWMP82ZQrOyfFhjVQ-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 13/24] tests: use g_auto for virCPUDataFree Date: Sat, 4 Sep 2021 22:44:11 +0200 Message-Id: <28371660a65f93bd5136097a0c30d7df0f22aea8.1630788206.git.jtomko@redhat.com> 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.11 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: 1630789650262100001 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Laine Stump --- tests/qemumonitorjsontest.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index 542b35850e..b68351d9d8 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -2158,7 +2158,7 @@ static int testQemuMonitorJSONGetCPUData(const void *opaque) { const struct testCPUData *data =3D opaque; - virCPUData *cpuData =3D NULL; + g_autoptr(virCPUData) cpuData =3D NULL; g_autofree char *jsonFile =3D NULL; g_autofree char *dataFile =3D NULL; g_autofree char *jsonStr =3D NULL; @@ -2208,7 +2208,6 @@ testQemuMonitorJSONGetCPUData(const void *opaque) =20 ret =3D 0; cleanup: - virCPUDataFree(cpuData); return ret; } =20 @@ -2217,7 +2216,7 @@ testQemuMonitorJSONGetNonExistingCPUData(const void *= opaque) { const testGenericData *data =3D opaque; virDomainXMLOption *xmlopt =3D data->xmlopt; - virCPUData *cpuData =3D NULL; + g_autoptr(virCPUData) cpuData =3D NULL; int rv, ret =3D -1; g_autoptr(qemuMonitorTest) test =3D NULL; =20 @@ -2251,7 +2250,6 @@ testQemuMonitorJSONGetNonExistingCPUData(const void *= opaque) =20 ret =3D 0; cleanup: - virCPUDataFree(cpuData); return ret; } =20 --=20 2.31.1 From nobody Fri May 3 12:48:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1630789652; cv=none; d=zohomail.com; s=zohoarc; b=jyT3EphIP/uMFp7wEHKk8BdEwdNgcAa4ye8UkrEJ4clWH+plip9mM+kWhNsZZATznkerWhtmcL7llmHUjDIANDKnKs5A/U/ojzG+pDCghv3QQndeO+1EFmw72dce8hnMeji0Rvz0WOpwtgS59tjKFBdRhuz/cBTHXM4Qrm42sjk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630789652; 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=WBDmFjOeoklujKRVE/UGraMG+bLobF5/5dBDLJwCbFY=; b=ZHPPJGzJ8KNUgn9UQeiJloUtWJs7pW0p+5/m+VmkQdfVnJ0vKmvLsQbabFm2sB9BBiVwY+wr4tZBrtkrQWVNRaIYrrL9DKvXZb/zC1QiLK5dlmrahcHGQDdCgBR3OGd+bc2it+1knJes8ASw9hZcm/JN9xNqlNDcHFhfehB1DZw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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 [170.10.133.124]) by mx.zohomail.com with SMTPS id 1630789652158499.8147233013567; Sat, 4 Sep 2021 14:07:32 -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-548-QuobScPyNiWBidkIvqVMyA-1; Sat, 04 Sep 2021 17:07:29 -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 377B51854E2B; Sat, 4 Sep 2021 21:07: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 1AFBD6A259; Sat, 4 Sep 2021 21:07:24 +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 DB9BC44A5E; Sat, 4 Sep 2021 21:07:23 +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 184KideA008848 for ; Sat, 4 Sep 2021 16:44:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3D1922619D; Sat, 4 Sep 2021 20:44:39 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id BA4B21F4 for ; Sat, 4 Sep 2021 20:44:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630789651; 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=WBDmFjOeoklujKRVE/UGraMG+bLobF5/5dBDLJwCbFY=; b=hEiSQeQ/Bf9b5HZUcNFOnJBnJuFvjt7eBQCWjPHE381aPK2WgY4tb2wyJCJMqnXAYIvrfZ dDaCDZzMx/okAwsuz4L4zEaY/4/qu9f617xqxTvaykMiC9xFhVhbGYj4jOoDqgp0mMU2br rcNUqix6THe+ls0yM2cN54U7eYn5PNA= X-MC-Unique: QuobScPyNiWBidkIvqVMyA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 14/24] tests: use g_auto instead of VIR_FORCE_FCLOSE Date: Sat, 4 Sep 2021 22:44:12 +0200 Message-Id: <0f05199c34201d6edbd95de537788d7be82d3086.1630788206.git.jtomko@redhat.com> 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.11 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: 1630789654380100001 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Laine Stump --- tests/securityselinuxlabeltest.c | 3 +-- tests/testutils.c | 5 +---- tests/virhostcputest.c | 7 ++----- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/tests/securityselinuxlabeltest.c b/tests/securityselinuxlabelt= est.c index cd604eda31..2fb6e0c6b7 100644 --- a/tests/securityselinuxlabeltest.c +++ b/tests/securityselinuxlabeltest.c @@ -101,7 +101,7 @@ testSELinuxLoadFileList(const char *testname, { int ret =3D -1; g_autofree char *path =3D NULL; - FILE *fp =3D NULL; + g_autoptr(FILE) fp =3D NULL; g_autofree char *line =3D NULL; =20 *files =3D NULL; @@ -151,7 +151,6 @@ testSELinuxLoadFileList(const char *testname, ret =3D 0; =20 cleanup: - VIR_FORCE_FCLOSE(fp); return ret; } =20 diff --git a/tests/testutils.c b/tests/testutils.c index 5e9835ee89..d98246ec75 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -223,7 +223,7 @@ virTestRunLog(int *ret, int virTestLoadFile(const char *file, char **buf) { - FILE *fp =3D fopen(file, "r"); + g_autoptr(FILE) fp =3D fopen(file, "r"); struct stat st; char *tmp; int len, tmplen, buflen; @@ -235,7 +235,6 @@ virTestLoadFile(const char *file, char **buf) =20 if (fstat(fileno(fp), &st) < 0) { fprintf(stderr, "%s: failed to fstat: %s\n", file, g_strerror(errn= o)); - VIR_FORCE_FCLOSE(fp); return -1; } =20 @@ -263,13 +262,11 @@ virTestLoadFile(const char *file, char **buf) } if (ferror(fp)) { fprintf(stderr, "%s: read failed: %s\n", file, g_strerror(errn= o)); - VIR_FORCE_FCLOSE(fp); VIR_FREE(*buf); return -1; } } =20 - VIR_FORCE_FCLOSE(fp); return 0; } =20 diff --git a/tests/virhostcputest.c b/tests/virhostcputest.c index f935df0f63..c80cd1581c 100644 --- a/tests/virhostcputest.c +++ b/tests/virhostcputest.c @@ -33,7 +33,7 @@ linuxTestCompareFiles(const char *cpuinfofile, int ret =3D -1; g_autofree char *actualData =3D NULL; virNodeInfo nodeinfo; - FILE *cpuinfo; + g_autoptr(FILE) cpuinfo =3D NULL; =20 cpuinfo =3D fopen(cpuinfofile, "r"); if (!cpuinfo) { @@ -51,10 +51,8 @@ linuxTestCompareFiles(const char *cpuinfofile, if (virGetLastErrorCode()) VIR_TEST_DEBUG("\n%s", virGetLastErrorMessage()); } - VIR_FORCE_FCLOSE(cpuinfo); goto fail; } - VIR_FORCE_FCLOSE(cpuinfo); =20 actualData =3D g_strdup_printf("CPUs: %u/%u, MHz: %u, Nodes: %u, Socke= ts: %u, " "Cores: %u, Threads: %u\n", @@ -109,7 +107,7 @@ linuxCPUStatsCompareFiles(const char *cpustatfile, { int ret =3D -1; g_autofree char *actualData =3D NULL; - FILE *cpustat =3D NULL; + g_autoptr(FILE) cpustat =3D NULL; virNodeCPUStatsPtr params =3D NULL; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; size_t i; @@ -148,7 +146,6 @@ linuxCPUStatsCompareFiles(const char *cpustatfile, ret =3D 0; =20 fail: - VIR_FORCE_FCLOSE(cpustat); VIR_FREE(params); return ret; } --=20 2.31.1 From nobody Fri May 3 12:48:53 2024 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=1630789654; cv=none; d=zohomail.com; s=zohoarc; b=kFDmiv200PEth88mjBb7qBbaJsS4aNjFpm+VoymOmALr4OIHEZfRi1LQO4tb8dsXZT9xs776RzOuVs4ijeWgxdswzuqn0sND9QAb2tdJy8USPV3QXT1VpQW3Lc1zJ+89c41kqVPsuQbpXBN5+gRWSJjZZkP/tvUD92Z8YUUlrSA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630789654; 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=+EQVj9DoKONU2cRCJslhLhAgti86J5cnx1OFetgXCx4=; b=JZJyOKVTZhMzQQWhv9wcUcRjpsbEnnGvQ2QFEC6OstbwbomQKES60Jp5W68KYz6Y5+iv+XbfRaXOtIBjdygtG9meZABk9tdeYN72TOq1gjKT6Mip5r1wgaecBBRUNTJGsgpJZ/UPqUf0spX26LGdFhgc1MpfivJgMIQVbRKdfbc= 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 1630789654545473.46062395903584; Sat, 4 Sep 2021 14:07:34 -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-329-gsLoQnAINyueY43lUVkrjg-1; Sat, 04 Sep 2021 17:07:32 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1EBD9FC80; Sat, 4 Sep 2021 21:07:27 +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 026A677BE7; Sat, 4 Sep 2021 21:07:27 +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 C8D9144A63; Sat, 4 Sep 2021 21:07:26 +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 184KiefR008863 for ; Sat, 4 Sep 2021 16:44:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0D6862619D; Sat, 4 Sep 2021 20:44:40 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8AB251F4 for ; Sat, 4 Sep 2021 20:44:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630789653; 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=+EQVj9DoKONU2cRCJslhLhAgti86J5cnx1OFetgXCx4=; b=BgY+jxy5zVcaAnYXzfjqEUo0Dqp0wrX7MNIabK9VJ3MbN1Uofkf9046P8lV4iGePO7/rJp W2knHLCGKxvd4jdRqxa1mOfEJoqbdCcOjc7w5lL/oYn/JzmiPIP7zE/4/SKiLEDz5zpSbV OJHK0w2M8kOHgG8Q7R1k3VjeBeLg8ak= X-MC-Unique: gsLoQnAINyueY43lUVkrjg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 15/24] tests: use VIR_AUTOCLOSE Date: Sat, 4 Sep 2021 22:44:13 +0200 Message-Id: <9f3f7b3750b913e6f74999272a2ca0e8d8f493b4.1630788206.git.jtomko@redhat.com> 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.13 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: 1630789656251100003 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Laine Stump --- tests/fdstreamtest.c | 6 ++---- tests/scsihosttest.c | 3 +-- tests/virfiletest.c | 6 ++---- tests/virnettlshelpers.c | 4 +--- tests/virpcimock.c | 4 +--- tests/virrotatingfiletest.c | 4 +--- 6 files changed, 8 insertions(+), 19 deletions(-) diff --git a/tests/fdstreamtest.c b/tests/fdstreamtest.c index 182c853b33..96519e91c2 100644 --- a/tests/fdstreamtest.c +++ b/tests/fdstreamtest.c @@ -38,7 +38,7 @@ VIR_LOG_INIT("tests.fdstreamtest"); =20 static int testFDStreamReadCommon(const char *scratchdir, bool blocking) { - int fd =3D -1; + VIR_AUTOCLOSE fd =3D -1; g_autofree char *file =3D NULL; int ret =3D -1; g_autofree char *pattern =3D NULL; @@ -144,7 +144,6 @@ static int testFDStreamReadCommon(const char *scratchdi= r, bool blocking) cleanup: if (st) virStreamFree(st); - VIR_FORCE_CLOSE(fd); if (file !=3D NULL) unlink(file); if (conn) @@ -165,7 +164,7 @@ static int testFDStreamReadNonblock(const void *data) =20 static int testFDStreamWriteCommon(const char *scratchdir, bool blocking) { - int fd =3D -1; + VIR_AUTOCLOSE fd =3D -1; g_autofree char *file =3D NULL; int ret =3D -1; g_autofree char *pattern =3D NULL; @@ -284,7 +283,6 @@ static int testFDStreamWriteCommon(const char *scratchd= ir, bool blocking) cleanup: if (st) virStreamFree(st); - VIR_FORCE_CLOSE(fd); if (file !=3D NULL) unlink(file); if (conn) diff --git a/tests/scsihosttest.c b/tests/scsihosttest.c index 336b3cc496..aeb91da691 100644 --- a/tests/scsihosttest.c +++ b/tests/scsihosttest.c @@ -71,7 +71,7 @@ create_scsihost(const char *fakesysfsdir, const char *dev= icepath, g_autofree char *link_path =3D NULL; char *spot; int ret =3D -1; - int fd =3D -1; + VIR_AUTOCLOSE fd =3D -1; =20 unique_id_path =3D g_strdup_printf("%s/devices/pci0000:00/%s/unique_id= ", fakesysfsdir, devicepath); @@ -136,7 +136,6 @@ create_scsihost(const char *fakesysfsdir, const char *d= evicepath, ret =3D 0; =20 cleanup: - VIR_FORCE_CLOSE(fd); return ret; } =20 diff --git a/tests/virfiletest.c b/tests/virfiletest.c index 019c230cea..a6e722b4d2 100644 --- a/tests/virfiletest.c +++ b/tests/virfiletest.c @@ -194,7 +194,7 @@ holesSupported(void) { off_t offsets[] =3D {EXTENT, EXTENT, EXTENT, -1}; off_t tmp; - int fd; + VIR_AUTOCLOSE fd =3D -1; bool ret =3D false; =20 if ((fd =3D makeSparseFile(offsets, true)) < 0) @@ -229,7 +229,6 @@ holesSupported(void) =20 ret =3D true; cleanup: - VIR_FORCE_CLOSE(fd); return ret; } =20 @@ -261,7 +260,7 @@ static int testFileInData(const void *opaque) { const struct testFileInData *data =3D opaque; - int fd =3D -1; + VIR_AUTOCLOSE fd =3D -1; int ret =3D -1; size_t i; =20 @@ -303,7 +302,6 @@ testFileInData(const void *opaque) ret =3D 0; =20 cleanup: - VIR_FORCE_CLOSE(fd); return ret; } =20 diff --git a/tests/virnettlshelpers.c b/tests/virnettlshelpers.c index 905e633e60..c9e2b372bb 100644 --- a/tests/virnettlshelpers.c +++ b/tests/virnettlshelpers.c @@ -396,7 +396,7 @@ void testTLSWriteCertChain(const char *filename, size_t ncerts) { size_t i; - int fd; + VIR_AUTOCLOSE fd =3D -1; int err; static char buffer[1024*1024]; size_t size; @@ -420,8 +420,6 @@ void testTLSWriteCertChain(const char *filename, abort(); } } - - VIR_FORCE_CLOSE(fd); } =20 =20 diff --git a/tests/virpcimock.c b/tests/virpcimock.c index ead810d412..d4d43aac51 100644 --- a/tests/virpcimock.c +++ b/tests/virpcimock.c @@ -177,7 +177,7 @@ make_file(const char *path, const char *value, ssize_t len) { - int fd =3D -1; + VIR_AUTOCLOSE fd =3D -1; g_autofree char *filepath =3D NULL; if (value && len =3D=3D -1) len =3D strlen(value); @@ -189,8 +189,6 @@ make_file(const char *path, =20 if (value && safewrite(fd, value, len) !=3D len) ABORT("Unable to write: %s", filepath); - - VIR_FORCE_CLOSE(fd); } =20 static void diff --git a/tests/virrotatingfiletest.c b/tests/virrotatingfiletest.c index 87699936cb..ede65848ea 100644 --- a/tests/virrotatingfiletest.c +++ b/tests/virrotatingfiletest.c @@ -125,7 +125,7 @@ static int testRotatingFileInitOne(const char *filename, unlink(filename); } else { char buf[1024]; - int fd; + VIR_AUTOCLOSE fd =3D -1; =20 VIR_DEBUG("Creating %s size %zu", filename, (size_t)size); =20 @@ -142,12 +142,10 @@ static int testRotatingFileInitOne(const char *filena= me, =20 if (safewrite(fd, buf, towrite) !=3D towrite) { fprintf(stderr, "Cannot write to %s\n", filename); - VIR_FORCE_CLOSE(fd); return -1; } size -=3D towrite; } - VIR_FORCE_CLOSE(fd); } return 0; } --=20 2.31.1 From nobody Fri May 3 12:48:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1630788698; cv=none; d=zohomail.com; s=zohoarc; b=OGu7upHPDL9NyevFNJgGN7xSI5X3cGZ8n+6RyWTKDI2h//MuX4uNQxy1x5DK2Cy2PVNgEBD0RQv3xr388k4j96ZHDH3EBOANOVKo2on6QxbOead0HQPEK03zwXiJVl/GpjqThl5haNwtYse/NQu+n9Wpr1HXqTH/F3echYlqDac= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630788698; 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=Um61ulYlUTHhmkIffNCSj3EwBc3CYF/CvicnvwLn6RQ=; b=KoJisl8vNh8HYF3azYNpoIuP9qlj5EmLTUaDT2AYEVBdTqo0B0hna8HmRQcn8vvnVJr9Z1exZ6KfnsyBz1W9KAYQy3xtg8kQsOBiLJk1VG7muMKcPIHPenjYD6BJ1zeSTDM67XVsY4vziVxjOkXtJpBQ5FzviQuHyKNw+5opL84= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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 [170.10.133.124]) by mx.zohomail.com with SMTPS id 1630788698736781.4576955565113; Sat, 4 Sep 2021 13:51:38 -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-564-Sj2J3UmwNQK7cWBFnvXUTA-1; Sat, 04 Sep 2021 16:51:35 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 20A5E1854E21; Sat, 4 Sep 2021 20:51:31 +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 061CB6091B; Sat, 4 Sep 2021 20:51:31 +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 A5729180BAB3; Sat, 4 Sep 2021 20:51:30 +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 184KieN1008868 for ; Sat, 4 Sep 2021 16:44:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id D256C2619D; Sat, 4 Sep 2021 20:44:40 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5C47E1F4 for ; Sat, 4 Sep 2021 20:44:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630788697; 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=Um61ulYlUTHhmkIffNCSj3EwBc3CYF/CvicnvwLn6RQ=; b=INq5RCdYbe4+bdV9qwGWW7qgfYxKkSjNzi5xNUdNGmvBrVzK2hrl9Pg/A7OkHmtDsCzavb IHfwlp4p7wEFCyOU12qLR68mM/d/aTdIdlxo+iJxRzsLPby1f8j5p8C2eFq3NyQoiizNT2 rK5vIGNDkWbLIEuaKVnymt59woOuS2o= X-MC-Unique: Sj2J3UmwNQK7cWBFnvXUTA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 16/24] tests: use g_auto instead of vshTableFree Date: Sat, 4 Sep 2021 22:44:14 +0200 Message-Id: <42e98a7b6d43df688546b92b2a92e5b2154fd86d.1630788206.git.jtomko@redhat.com> 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.13 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: 1630788699324100001 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Laine Stump --- tests/vshtabletest.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/tests/vshtabletest.c b/tests/vshtabletest.c index 804aaf4d9c..569d7a852f 100644 --- a/tests/vshtabletest.c +++ b/tests/vshtabletest.c @@ -55,7 +55,7 @@ testVshTableHeader(const void *opaque G_GNUC_UNUSED) " 1 fedora28 running\n" " 2 rhel7.5 running\n"; =20 - vshTable *table =3D vshTableNew("Id", "Name", "State", + g_autoptr(vshTable) table =3D vshTableNew("Id", "Name", "State", NULL); //to ask about return if (!table) goto cleanup; @@ -75,7 +75,6 @@ testVshTableHeader(const void *opaque G_GNUC_UNUSED) =20 cleanup: VIR_FREE(act); - vshTableFree(table); return ret; } =20 @@ -84,7 +83,7 @@ testVshTableRowAppend(const void *opaque G_GNUC_UNUSED) { int ret =3D 0; =20 - vshTable *table =3D vshTableNew("Id", "Name", NULL); + g_autoptr(vshTable) table =3D vshTableNew("Id", "Name", NULL); if (!table) goto cleanup; =20 @@ -111,7 +110,6 @@ testVshTableRowAppend(const void *opaque G_GNUC_UNUSED) } =20 cleanup: - vshTableFree(table); return ret; } =20 @@ -126,7 +124,7 @@ testUnicode(const void *opaque G_GNUC_UNUSED) "-----------------------------------------\n" " 1 fedora28 running\n" " 2 =E3=81=A4=E3=81=B8=E3=82=BDrhel7.5=E3=81=A4=E3=81=B8=E3=82= =BD running\n"; - vshTable *table; + g_autoptr(vshTable) table =3D NULL; =20 table =3D vshTableNew("Id", "=E5=90=8D=E7=A8=B1", "=D0=B3=D0=BE=D1=81= =D1=83=D0=B4=D0=B0=D1=80=D1=81=D1=82=D0=B2=D0=BE", NULL); if (!table) @@ -141,7 +139,6 @@ testUnicode(const void *opaque G_GNUC_UNUSED) ret =3D -1; =20 cleanup: - vshTableFree(table); return ret; } =20 @@ -157,7 +154,7 @@ testUnicodeArabic(const void *opaque G_GNUC_UNUSED) "-----------------------------------------------------------------= --------------------------\n" " 1 =EF=BB=89=EF=BA=AA=EF=BB=B4=EF=BB=9F =EF=BA=8E=EF= =BB=A0=EF=BA=9C=EF=BB=98=EF=BB=B4=EF=BB=9F =EF=BB=95=EF=BA=8E=EF=BB=A3 =EF= =BB=8A=EF=BB=A7, =D9=A3=D9=A0 =EF=BB=8E=EF=BB=B4=EF=BB=A8=EF=BB=B3=EF=BA=8D= =EF=BB=AE=EF=BA=98=EF=BB=A7=EF=BA=8E=EF=BB=A4=EF=BA=97 =EF=BA=8E=EF=BB=A0= =EF=BA=9B=EF=BA=8E=EF=BB=A0=EF=BA=9B=D8=8C =EF=BA=84=EF=BA=B3=EF=BA=AD, =EF= =BA=A9=EF=BB=AE=EF=BB=9F =EF=BA=A9=EF=BB=AE=EF=BB=9F. =EF=BA=84=EF=BB=A3= =EF=BA=8E=EF=BB=A3 =EF=BA=8D =EF=BA=8E=EF=BB=A7 =EF=BB=B2=EF=BB=9C=EF=BB=A7= \n" " =EF=BA=BA=EF=BB=94=EF=BA=A3=EF=BA=93 =EF=BA=96=EF=BB= =9C=EF=BA=98=EF=BB=B4=EF=BB=9B=EF=BA=8D=D9=8B =EF=BB=8A=EF=BB=9F, =EF=BA=8E= =EF=BB=A0=EF=BA=A0=EF=BB=A7=EF=BB=AD=EF=BA=A9 =EF=BB=AD=EF=BA=8E=EF=BB=A0= =EF=BB=8C=EF=BA=97=EF=BA=8D=EF=BA=A9 =EF=BA=B5= =EF=BA=AD\n"; - vshTable *table; + g_autoptr(vshTable) table =3D NULL; wchar_t wc; =20 /* If this char is not classed as printable, the actual @@ -183,7 +180,6 @@ testUnicodeArabic(const void *opaque G_GNUC_UNUSED) ret =3D -1; =20 cleanup: - vshTableFree(table); return ret; } =20 @@ -192,7 +188,7 @@ static int testUnicodeZeroWidthChar(const void *opaque G_GNUC_UNUSED) { int ret =3D 0; - vshTable *table =3D NULL; + g_autoptr(vshTable) table =3D NULL; const char *exp =3D " I\u200Bd Name \u200BStatus\n" "--------------------------\n" @@ -220,7 +216,6 @@ testUnicodeZeroWidthChar(const void *opaque G_GNUC_UNUS= ED) ret =3D -1; =20 cleanup: - vshTableFree(table); return ret; } =20 @@ -228,7 +223,7 @@ static int testUnicodeCombiningChar(const void *opaque G_GNUC_UNUSED) { int ret =3D 0; - vshTable *table =3D NULL; + g_autoptr(vshTable) table =3D NULL; const char *exp =3D " Id N=C3=A1me =E2=93=88tatus\n" "--------------------------\n" @@ -247,7 +242,6 @@ testUnicodeCombiningChar(const void *opaque G_GNUC_UNUS= ED) ret =3D -1; =20 cleanup: - vshTableFree(table); return ret; } =20 @@ -256,7 +250,7 @@ static int testUnicodeNonPrintableChar(const void *opaque G_GNUC_UNUSED) { int ret =3D 0; - vshTable *table =3D NULL; + g_autoptr(vshTable) table =3D NULL; const char *exp =3D " I\\x09d Name Status\n" "----------------------------------\n" @@ -275,7 +269,6 @@ testUnicodeNonPrintableChar(const void *opaque G_GNUC_U= NUSED) ret =3D -1; =20 cleanup: - vshTableFree(table); return ret; } =20 @@ -283,9 +276,9 @@ static int testNTables(const void *opaque G_GNUC_UNUSED) { int ret =3D 0; - vshTable *table1 =3D NULL; - vshTable *table2 =3D NULL; - vshTable *table3 =3D NULL; + g_autoptr(vshTable) table1 =3D NULL; + g_autoptr(vshTable) table2 =3D NULL; + g_autoptr(vshTable) table3 =3D NULL; const char *exp1 =3D " Id Name Status\n" "--------------------------\n" @@ -336,9 +329,6 @@ testNTables(const void *opaque G_GNUC_UNUSED) ret =3D -1; =20 cleanup: - vshTableFree(table1); - vshTableFree(table2); - vshTableFree(table3); return ret; } =20 --=20 2.31.1 From nobody Fri May 3 12:48:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1630788726; cv=none; d=zohomail.com; s=zohoarc; b=Eb3FcCOuu2W+7kKUuertVpWt2dQPAQyIi7TYWyf844mPG2/tP0ZI8Zf64344IOtiqAgDkUsjzqZ/RdiTWmUN+jLYcyrDU87uuoV8Hv3ysXsKGwZ9esuHO2Y7WXitdTuix3KGZWL0DGrqeEUS1WifHe86fYjKmVS7jMMxesm9nLg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630788726; 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=4Q3iw6mCUCK2zgQ5eWK8foN+dY4k9eIlZA92MvH8jdc=; b=XRMlLos6J4Eos8T/r41Ijd8UhexgiENuWK39/WLT3H8Pr/8iWojHlLgFXjJiDgFv3WicWPLGG2UytoVzYwdXGGLKPPIkhhmFejt41QzwPV9yCvN9QSb46iqiHFnCdpx96OJaRPcu/Ly7HMY8Q2dzgrkxBPWeVYVIIeZ3fU4i67M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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 [170.10.133.124]) by mx.zohomail.com with SMTPS id 1630788726767623.8148823299164; Sat, 4 Sep 2021 13:52:06 -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-470-fUp7y7hPOVmJlmP47pgzjw-1; Sat, 04 Sep 2021 16:51:38 -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 8F5EE1854E2D; Sat, 4 Sep 2021 20:51:33 +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 5317E6B54B; Sat, 4 Sep 2021 20:51:33 +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 28B13180BAC0; Sat, 4 Sep 2021 20:51:33 +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 184KiftI008873 for ; Sat, 4 Sep 2021 16:44:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id A206B2619D; Sat, 4 Sep 2021 20:44:41 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2C15A1F4 for ; Sat, 4 Sep 2021 20:44:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630788725; 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=4Q3iw6mCUCK2zgQ5eWK8foN+dY4k9eIlZA92MvH8jdc=; b=XSd3aC13ZDgqvq6hOcdT4xzCsBF4/8Hpb6CeAI1gd721Wb7D9WhZ4eE6KqBEhNYy67mMR7 sF/FV6iFa2y+/22rkHjSmpQIMK740PT2BvLKH45c+csI4zihwTbX1bQIZF55v40MnClBJC yaw/gIngp1clsya7LHXGYVHJ65pxCNI= X-MC-Unique: fUp7y7hPOVmJlmP47pgzjw-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 17/24] tests: use g_auto instead of virDomainFree Date: Sat, 4 Sep 2021 22:44:15 +0200 Message-Id: <3d34d2e10ed134ecd8f43f708b277353e4256971.1630788206.git.jtomko@redhat.com> 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: 1630788728086100001 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Laine Stump --- tests/domainconftest.c | 3 +-- tests/libxlxml2domconfigtest.c | 3 +-- tests/lxcconf2xmltest.c | 3 +-- tests/openvzutilstest.c | 3 +-- tests/qemuagenttest.c | 3 +-- tests/securityselinuxlabeltest.c | 3 +-- tests/testutils.c | 3 +-- tests/vmx2xmltest.c | 3 +-- tests/xlconfigtest.c | 6 ++---- tests/xmconfigtest.c | 6 ++---- tests/xml2vmxtest.c | 3 +-- 11 files changed, 13 insertions(+), 26 deletions(-) diff --git a/tests/domainconftest.c b/tests/domainconftest.c index 8b77952860..aaf58bcf93 100644 --- a/tests/domainconftest.c +++ b/tests/domainconftest.c @@ -41,7 +41,7 @@ struct testGetFilesystemData { static int testGetFilesystem(const void *opaque) { int ret =3D -1; - virDomainDef *def =3D NULL; + g_autoptr(virDomainDef) def =3D NULL; g_autofree char *filename =3D NULL; const struct testGetFilesystemData *data =3D opaque; virDomainFSDef *fsdef; @@ -71,7 +71,6 @@ static int testGetFilesystem(const void *opaque) ret =3D 0; =20 cleanup: - virDomainDefFree(def); return ret; } =20 diff --git a/tests/libxlxml2domconfigtest.c b/tests/libxlxml2domconfigtest.c index 2bc5c26223..015597eb44 100644 --- a/tests/libxlxml2domconfigtest.c +++ b/tests/libxlxml2domconfigtest.c @@ -52,7 +52,7 @@ testCompareXMLToDomConfig(const char *xmlfile, libxl_domain_config expectconfig; xentoollog_logger *log =3D NULL; virPortAllocatorRange *gports =3D NULL; - virDomainDef *vmdef =3D NULL; + g_autoptr(virDomainDef) vmdef =3D NULL; g_autofree char *actualjson =3D NULL; g_autofree char *tempjson =3D NULL; g_autofree char *expectjson =3D NULL; @@ -128,7 +128,6 @@ testCompareXMLToDomConfig(const char *xmlfile, vmdef->graphics[0]->type =3D=3D VIR_DOMAIN_GRAPHICS_TYPE_VNC) virPortAllocatorRelease(vmdef->graphics[0]->data.vnc.port); =20 - virDomainDefFree(vmdef); virPortAllocatorRangeFree(gports); libxl_domain_config_dispose(&actualconfig); libxl_domain_config_dispose(&expectconfig); diff --git a/tests/lxcconf2xmltest.c b/tests/lxcconf2xmltest.c index 99473a0b89..be70671d68 100644 --- a/tests/lxcconf2xmltest.c +++ b/tests/lxcconf2xmltest.c @@ -28,7 +28,7 @@ testCompareXMLToConfigFiles(const char *xmlfile, int ret =3D -1; g_autofree char *config =3D NULL; g_autofree char *actualxml =3D NULL; - virDomainDef *vmdef =3D NULL; + g_autoptr(virDomainDef) vmdef =3D NULL; =20 if (virTestLoadFile(configfile, &config) < 0) goto fail; @@ -51,7 +51,6 @@ testCompareXMLToConfigFiles(const char *xmlfile, ret =3D 0; =20 fail: - virDomainDefFree(vmdef); return ret; } =20 diff --git a/tests/openvzutilstest.c b/tests/openvzutilstest.c index 10cf307d61..3ebf38f104 100644 --- a/tests/openvzutilstest.c +++ b/tests/openvzutilstest.c @@ -69,7 +69,7 @@ static int testReadNetworkConf(const void *data G_GNUC_UNUSED) { int result =3D -1; - virDomainDef *def =3D NULL; + g_autoptr(virDomainDef) def =3D NULL; g_autofree char *actual =3D NULL; const char *expected =3D "\n" @@ -131,7 +131,6 @@ testReadNetworkConf(const void *data G_GNUC_UNUSED) cleanup: virObjectUnref(driver.xmlopt); virObjectUnref(driver.caps); - virDomainDefFree(def); =20 return result; } diff --git a/tests/qemuagenttest.c b/tests/qemuagenttest.c index a447c93494..10d02bd1b4 100644 --- a/tests/qemuagenttest.c +++ b/tests/qemuagenttest.c @@ -313,7 +313,7 @@ testQemuAgentGetFSInfo(const void *data) { virDomainXMLOption *xmlopt =3D (virDomainXMLOption *)data; qemuMonitorTest *test =3D NULL; - virDomainDef *def =3D NULL; + g_autoptr(virDomainDef) def =3D NULL; qemuAgentFSInfo **info =3D NULL; int ret =3D -1, ninfo =3D 0, i; =20 @@ -405,7 +405,6 @@ testQemuAgentGetFSInfo(const void *data) for (i =3D 0; i < ninfo; i++) qemuAgentFSInfoFree(info[i]); VIR_FREE(info); - virDomainDefFree(def); qemuMonitorTestFree(test); return ret; } diff --git a/tests/securityselinuxlabeltest.c b/tests/securityselinuxlabelt= est.c index 2fb6e0c6b7..2e5941d7ef 100644 --- a/tests/securityselinuxlabeltest.c +++ b/tests/securityselinuxlabeltest.c @@ -278,7 +278,7 @@ testSELinuxLabeling(const void *opaque) testSELinuxFile *files =3D NULL; size_t nfiles =3D 0; size_t i; - virDomainDef *def =3D NULL; + g_autoptr(virDomainDef) def =3D NULL; =20 if (testSELinuxLoadFileList(testname, &files, &nfiles) < 0) goto cleanup; @@ -301,7 +301,6 @@ testSELinuxLabeling(const void *opaque) if (testSELinuxDeleteDisks(files, nfiles) < 0) VIR_WARN("unable to fully clean up"); =20 - virDomainDefFree(def); for (i =3D 0; i < nfiles; i++) { VIR_FREE(files[i].file); VIR_FREE(files[i].context); diff --git a/tests/testutils.c b/tests/testutils.c index d98246ec75..7e0d273ed4 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -1009,7 +1009,7 @@ testCompareDomXML2XMLFiles(virCaps *caps G_GNUC_UNUSE= D, g_autofree char *actual =3D NULL; int ret =3D -1; testCompareDomXML2XMLResult result; - virDomainDef *def =3D NULL; + g_autoptr(virDomainDef) def =3D NULL; unsigned int parse_flags =3D live ? 0 : VIR_DOMAIN_DEF_PARSE_INACTIVE; unsigned int format_flags =3D VIR_DOMAIN_DEF_FORMAT_SECURE; =20 @@ -1059,7 +1059,6 @@ testCompareDomXML2XMLFiles(virCaps *caps G_GNUC_UNUSE= D, expectResult, result); } =20 - virDomainDefFree(def); return ret; } =20 diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c index cd44a84a07..b7f232eb77 100644 --- a/tests/vmx2xmltest.c +++ b/tests/vmx2xmltest.c @@ -71,7 +71,7 @@ testCompareFiles(const char *vmx, const char *xml, bool s= hould_fail_parse) int ret =3D -1; g_autofree char *vmxData =3D NULL; g_autofree char *formatted =3D NULL; - virDomainDef *def =3D NULL; + g_autoptr(virDomainDef) def =3D NULL; =20 if (virTestLoadFile(vmx, &vmxData) < 0) return -1; @@ -102,7 +102,6 @@ testCompareFiles(const char *vmx, const char *xml, bool= should_fail_parse) ret =3D 0; =20 cleanup: - virDomainDefFree(def); =20 return ret; } diff --git a/tests/xlconfigtest.c b/tests/xlconfigtest.c index 95ee670b00..6717377982 100644 --- a/tests/xlconfigtest.c +++ b/tests/xlconfigtest.c @@ -69,7 +69,7 @@ testCompareParseXML(const char *xlcfg, const char *xml, b= ool replaceVars) g_autoptr(virConnect) conn =3D NULL; int wrote =3D 4096; int ret =3D -1; - virDomainDef *def =3D NULL; + g_autoptr(virDomainDef) def =3D NULL; g_autofree char *replacedXML =3D NULL; =20 gotxlcfgData =3D g_new0(char, wrote); @@ -107,7 +107,6 @@ testCompareParseXML(const char *xlcfg, const char *xml,= bool replaceVars) ret =3D 0; =20 fail: - virDomainDefFree(def); =20 return ret; } @@ -124,7 +123,7 @@ testCompareFormatXML(const char *xlcfg, const char *xml= , bool replaceVars) g_autoptr(virConf) conf =3D NULL; int ret =3D -1; g_autoptr(virConnect) conn =3D NULL; - virDomainDef *def =3D NULL; + g_autoptr(virDomainDef) def =3D NULL; g_autofree char *replacedXML =3D NULL; g_autoptr(libxlDriverConfig) cfg =3D libxlDriverConfigGet(driver); =20 @@ -158,7 +157,6 @@ testCompareFormatXML(const char *xlcfg, const char *xml= , bool replaceVars) ret =3D 0; =20 fail: - virDomainDefFree(def); =20 return ret; } diff --git a/tests/xmconfigtest.c b/tests/xmconfigtest.c index a756f752f8..bd23e5fd5d 100644 --- a/tests/xmconfigtest.c +++ b/tests/xmconfigtest.c @@ -44,7 +44,7 @@ testCompareParseXML(const char *xmcfg, const char *xml) int ret =3D -1; g_autoptr(virConnect) conn =3D NULL; int wrote =3D 4096; - virDomainDef *def =3D NULL; + g_autoptr(virDomainDef) def =3D NULL; =20 gotxmcfgData =3D g_new0(char, wrote); =20 @@ -73,7 +73,6 @@ testCompareParseXML(const char *xmcfg, const char *xml) ret =3D 0; =20 fail: - virDomainDefFree(def); =20 return ret; } @@ -85,7 +84,7 @@ testCompareFormatXML(const char *xmcfg, const char *xml) g_autofree char *gotxml =3D NULL; g_autoptr(virConf) conf =3D NULL; int ret =3D -1; - virDomainDef *def =3D NULL; + g_autoptr(virDomainDef) def =3D NULL; g_autoptr(libxlDriverConfig) cfg =3D libxlDriverConfigGet(driver); =20 if (virTestLoadFile(xmcfg, &xmcfgData) < 0) @@ -106,7 +105,6 @@ testCompareFormatXML(const char *xmcfg, const char *xml) ret =3D 0; =20 fail: - virDomainDefFree(def); =20 return ret; } diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c index cb70f70f4f..8a03237b16 100644 --- a/tests/xml2vmxtest.c +++ b/tests/xml2vmxtest.c @@ -72,7 +72,7 @@ testCompareFiles(const char *xml, const char *vmx, int vi= rtualHW_version) { int result =3D -1; g_autofree char *formatted =3D NULL; - virDomainDef *def =3D NULL; + g_autoptr(virDomainDef) def =3D NULL; =20 def =3D virDomainDefParseFile(xml, xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE); @@ -95,7 +95,6 @@ testCompareFiles(const char *xml, const char *vmx, int vi= rtualHW_version) result =3D 0; =20 failure: - virDomainDefFree(def); =20 return result; } --=20 2.31.1 From nobody Fri May 3 12:48:53 2024 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=1630788747; cv=none; d=zohomail.com; s=zohoarc; b=nQcSr1V/It0e84FeFBhXHPLLcq8eC312ean+LPa4wUljh2YLrw2+cQT/aKSQzunaSKrBH9aUcqHfOQBzIC9pJOomjUejSi+91OvX6zBXDXxL2IL4/B81yjsOuKiN7xwN+x8S6YJ/lSdgm7PSezrdlcdyl3194gHHlKmajAs1mjE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630788747; 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=n/qZbfWEWr4XOAee/3eEnQeWr3hfaQLkIDqYh69vlv0=; b=Owh04SIODr1c/R6C6qv8wn9ZtpgyHp+sTPRpely1zSuxm5ikfcPalkVf/247YPjLApm5eFCN1ps1Yti5M9Prv4UPzNasUvFkScctEiEP/q+OrI1z5sUwJcYDc5XANyw/1WUmmwb7iqvkYkfalgQLltgBKZbpisfw95Y4j19J8KI= 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 1630788747124580.9931086740801; Sat, 4 Sep 2021 13:52:27 -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-10-eJAAUFeLNEC5h8deF1p1Uw-1; Sat, 04 Sep 2021 16:51:40 -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 3FE725200; Sat, 4 Sep 2021 20:51: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 25E9369FC9; Sat, 4 Sep 2021 20:51: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 EE1FB180101F; Sat, 4 Sep 2021 20:51:35 +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 184KigkN008891 for ; Sat, 4 Sep 2021 16:44:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7286C1F4; Sat, 4 Sep 2021 20:44:42 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id F093F26367 for ; Sat, 4 Sep 2021 20:44:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630788746; 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=n/qZbfWEWr4XOAee/3eEnQeWr3hfaQLkIDqYh69vlv0=; b=ecPRSQMb8JnDtocPH6lWqGEtgT+YRLKoWSTouh0aTsodUYCfudsLdf9tzHtUYH2rD+/kNs PIDGpJ2Jdd5HemA6Sop04jDi/ZAiMGlSLgEADWh4I60NCtpicHA2NVk7Ba3aROC6mtPYBz 7L0gAdzZUien4kP6VOfYSaqFF8Wjf/A= X-MC-Unique: eJAAUFeLNEC5h8deF1p1Uw-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 18/24] tests: qemu: remove pointless labels Date: Sat, 4 Sep 2021 22:44:16 +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.11 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: 1630788748610100001 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Laine Stump --- tests/qemuagenttest.c | 28 ++++++-------------- tests/qemucapsprobemock.c | 3 +-- tests/qemucommandutiltest.c | 9 +++---- tests/qemumonitorjsontest.c | 50 +++++++++++++++--------------------- tests/qemumonitortestutils.c | 45 ++++++++++---------------------- tests/qemuxml2argvtest.c | 21 ++++----------- 6 files changed, 51 insertions(+), 105 deletions(-) diff --git a/tests/qemuagenttest.c b/tests/qemuagenttest.c index 10d02bd1b4..bef6dfd152 100644 --- a/tests/qemuagenttest.c +++ b/tests/qemuagenttest.c @@ -471,51 +471,39 @@ qemuAgentShutdownTestMonitorHandler(qemuMonitorTest *= test, virJSONValue *args; const char *cmdname; const char *mode; - int ret =3D -1; =20 data =3D qemuMonitorTestItemGetPrivateData(item); =20 if (!(val =3D virJSONValueFromString(cmdstr))) return -1; =20 - if (!(cmdname =3D virJSONValueObjectGetString(val, "execute"))) { - ret =3D qemuMonitorTestAddErrorResponse(test, "Missing command nam= e in %s", cmdstr); - goto cleanup; - } + if (!(cmdname =3D virJSONValueObjectGetString(val, "execute"))) + return qemuMonitorTestAddErrorResponse(test, "Missing command name= in %s", cmdstr); =20 if (STRNEQ(cmdname, "guest-shutdown")) { - ret =3D qemuMonitorTestAddInvalidCommandResponse(test, "guest-shut= down", + return qemuMonitorTestAddInvalidCommandResponse(test, "guest-shutd= own", cmdname); - goto cleanup; } =20 if (!(args =3D virJSONValueObjectGet(val, "arguments"))) { - ret =3D qemuMonitorTestAddErrorResponse(test, + return qemuMonitorTestAddErrorResponse(test, "Missing arguments section"); - goto cleanup; } =20 - if (!(mode =3D virJSONValueObjectGetString(args, "mode"))) { - ret =3D qemuMonitorTestAddErrorResponse(test, "Missing shutdown mo= de"); - goto cleanup; - } + if (!(mode =3D virJSONValueObjectGetString(args, "mode"))) + return qemuMonitorTestAddErrorResponse(test, "Missing shutdown mod= e"); =20 if (STRNEQ(mode, data->mode)) { - ret =3D qemuMonitorTestAddErrorResponse(test, + return qemuMonitorTestAddErrorResponse(test, "expected shutdown mode '%s'= got '%s'", data->mode, mode); - goto cleanup; } =20 /* now don't reply but return a qemu agent event */ qemuAgentNotifyEvent(qemuMonitorTestGetAgent(test), data->event); =20 - ret =3D 0; - - cleanup: - return ret; - + return 0; } =20 =20 diff --git a/tests/qemucapsprobemock.c b/tests/qemucapsprobemock.c index 27539d04a1..915036d178 100644 --- a/tests/qemucapsprobemock.c +++ b/tests/qemucapsprobemock.c @@ -104,7 +104,7 @@ qemuMonitorJSONIOProcessLine(qemuMonitor *mon, =20 /* Ignore QMP greeting */ if (virJSONValueObjectHasKey(value, "QMP")) - goto cleanup; + return 0; =20 if (first) first =3D false; @@ -114,6 +114,5 @@ qemuMonitorJSONIOProcessLine(qemuMonitor *mon, printLineSkipEmpty(json, stdout); } =20 - cleanup: return ret; } diff --git a/tests/qemucommandutiltest.c b/tests/qemucommandutiltest.c index e1cab0be90..ae86ef9ea0 100644 --- a/tests/qemucommandutiltest.c +++ b/tests/qemucommandutiltest.c @@ -40,7 +40,6 @@ testQemuCommandBuildFromJSON(const void *opaque) g_autoptr(virJSONValue) val =3D NULL; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; g_autofree char *result =3D NULL; - int ret =3D -1; =20 if (!(val =3D virJSONValueFromString(data->props))) { fprintf(stderr, "Failed to parse JSON string '%s'", data->props); @@ -51,7 +50,7 @@ testQemuCommandBuildFromJSON(const void *opaque) fprintf(stderr, "\nvirQEMUBuildCommandlineJSON failed process JSON:\n%s\n", data->props); - goto cleanup; + return -1; } =20 result =3D virBufferContentAndReset(&buf); @@ -60,12 +59,10 @@ testQemuCommandBuildFromJSON(const void *opaque) fprintf(stderr, "\nFailed to create object string. " "\nExpected:\n'%s'\nGot:\n'%s'", NULLSTR(data->expectprops), NULLSTR(result)); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 static int diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index b68351d9d8..1e4c2fd14e 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -1719,7 +1719,6 @@ testQemuMonitorJSONqemuMonitorJSONGetMigrationStats(c= onst void *opaque) { const testGenericData *data =3D opaque; virDomainXMLOption *xmlopt =3D data->xmlopt; - int ret =3D -1; qemuMonitorMigrationStats stats, expectedStats; g_autofree char *error =3D NULL; g_autoptr(qemuMonitorTest) test =3D NULL; @@ -1756,33 +1755,31 @@ testQemuMonitorJSONqemuMonitorJSONGetMigrationStats= (const void *opaque) " }," " \"id\": \"libvirt-14\"" "}") < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONGetMigrationStats(qemuMonitorTestGetMonitor(test), &stats, &error) < 0) - goto cleanup; + return -1; =20 if (memcmp(&stats, &expectedStats, sizeof(stats)) !=3D 0 || error) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", "Invalid migration statistics"); - goto cleanup; + return -1; } =20 memset(&stats, 0, sizeof(stats)); if (qemuMonitorJSONGetMigrationStats(qemuMonitorTestGetMonitor(test), &stats, &error) < 0) - goto cleanup; + return -1; =20 if (stats.status !=3D QEMU_MONITOR_MIGRATION_STATUS_ERROR || STRNEQ_NULLABLE(error, "It's broken")) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", "Invalid failed migration status"); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 static int @@ -2163,7 +2160,6 @@ testQemuMonitorJSONGetCPUData(const void *opaque) 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 if (!(test =3D qemuMonitorTestNewSchema(data->xmlopt, data->schema))) @@ -2175,7 +2171,7 @@ testQemuMonitorJSONGetCPUData(const void *opaque) abs_srcdir, data->name); =20 if (virTestLoadFile(jsonFile, &jsonStr) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorTestAddItem(test, "qom-list", "{" @@ -2191,24 +2187,22 @@ testQemuMonitorJSONGetCPUData(const void *opaque) " ]," " \"id\": \"libvirt-19\"" "}") < 0) - goto cleanup; + return -1; =20 if (qemuMonitorTestAddItem(test, "qom-get", jsonStr) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONGetGuestCPUx86(qemuMonitorTestGetMonitor(test), &cpuData, NULL) < 0) - goto cleanup; + return -1; =20 if (!(actual =3D virCPUDataFormat(cpuData))) - goto cleanup; + return -1; =20 if (virTestCompareToFile(actual, dataFile) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 static int @@ -2217,7 +2211,7 @@ testQemuMonitorJSONGetNonExistingCPUData(const void *= opaque) const testGenericData *data =3D opaque; virDomainXMLOption *xmlopt =3D data->xmlopt; g_autoptr(virCPUData) cpuData =3D NULL; - int rv, ret =3D -1; + int rv; g_autoptr(qemuMonitorTest) test =3D NULL; =20 if (!(test =3D qemuMonitorTestNewSchema(xmlopt, data->schema))) @@ -2231,26 +2225,24 @@ testQemuMonitorJSONGetNonExistingCPUData(const void= *opaque) " \"desc\": \"The command qom-list h= as not been found\"" " }" "}") < 0) - goto cleanup; + return -1; =20 rv =3D qemuMonitorJSONGetGuestCPUx86(qemuMonitorTestGetMonitor(test), &cpuData, NULL); if (rv !=3D -2) { virReportError(VIR_ERR_INTERNAL_ERROR, "Unexpected return value %d, expecting -2", rv); - goto cleanup; + return -1; } =20 if (cpuData) { virReportError(VIR_ERR_INTERNAL_ERROR, "Unexpected allocation of data =3D %p, expecting NU= LL", cpuData); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 static int @@ -2584,10 +2576,10 @@ testQAPISchemaValidate(const void *opaque) int ret =3D -1; =20 if (virQEMUQAPISchemaPathGet(data->query, data->schema, &schemaroot) <= 0) - goto cleanup; + return -1; =20 if (!(json =3D virJSONValueFromString(data->json))) - goto cleanup; + return -1; =20 if ((testQEMUSchemaValidate(json, schemaroot, data->schema, false, &debug) =3D=3D 0) !=3D data->success) { @@ -2604,8 +2596,6 @@ testQAPISchemaValidate(const void *opaque) VIR_FREE(debugstr); } =20 - - cleanup: return ret; } =20 diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c index 8618e6bbef..71b26c326e 100644 --- a/tests/qemumonitortestutils.c +++ b/tests/qemumonitortestutils.c @@ -708,38 +708,25 @@ qemuMonitorTestProcessGuestAgentSync(qemuMonitorTest = *test, unsigned long long id; const char *cmdname; g_autofree char *retmsg =3D NULL; - int ret =3D -1; =20 if (!(val =3D virJSONValueFromString(cmdstr))) return -1; =20 - if (!(cmdname =3D virJSONValueObjectGetString(val, "execute"))) { - ret =3D qemuMonitorTestAddErrorResponse(test, "Missing guest-sync = command name"); - goto cleanup; - } + if (!(cmdname =3D virJSONValueObjectGetString(val, "execute"))) + return qemuMonitorTestAddErrorResponse(test, "Missing guest-sync c= ommand name"); =20 - if (STRNEQ(cmdname, "guest-sync")) { - ret =3D qemuMonitorTestAddInvalidCommandResponse(test, "guest-sync= ", cmdname); - goto cleanup; - } + if (STRNEQ(cmdname, "guest-sync")) + return qemuMonitorTestAddInvalidCommandResponse(test, "guest-sync"= , cmdname); =20 - if (!(args =3D virJSONValueObjectGet(val, "arguments"))) { - ret =3D qemuMonitorTestAddErrorResponse(test, "Missing arguments f= or guest-sync"); - goto cleanup; - } + if (!(args =3D virJSONValueObjectGet(val, "arguments"))) + return qemuMonitorTestAddErrorResponse(test, "Missing arguments fo= r guest-sync"); =20 - if (virJSONValueObjectGetNumberUlong(args, "id", &id)) { - ret =3D qemuMonitorTestAddErrorResponse(test, "Missing id for gues= t sync"); - goto cleanup; - } + if (virJSONValueObjectGetNumberUlong(args, "id", &id)) + return qemuMonitorTestAddErrorResponse(test, "Missing id for guest= sync"); =20 retmsg =3D g_strdup_printf("{\"return\":%llu}", id); =20 - - ret =3D qemuMonitorTestAddResponse(test, retmsg); - - cleanup: - return ret; + return qemuMonitorTestAddResponse(test, retmsg); } =20 =20 @@ -1194,10 +1181,10 @@ qemuMonitorTestNewFromFile(const char *fileName, char *singleReply; =20 if (virTestLoadFile(fileName, &json) < 0) - goto cleanup; + return NULL; =20 if (simple && !(test =3D qemuMonitorTestNewSimple(xmlopt))) - goto cleanup; + return NULL; =20 /* Our JSON parser expects replies to be separated by a newline charac= ter. * Hence we must preprocess the file a bit. */ @@ -1237,13 +1224,11 @@ qemuMonitorTestNewFromFile(const char *fileName, if (test && qemuMonitorTestAddItem(test, NULL, singleReply) < 0) goto error; =20 - cleanup: return test; =20 error: qemuMonitorTestFree(test); - test =3D NULL; - goto cleanup; + return NULL; } =20 =20 @@ -1341,7 +1326,7 @@ qemuMonitorTestNewFromFileFull(const char *fileName, =20 if (!(ret =3D qemuMonitorTestNew(driver->xmlopt, vm, driver, NULL, qmpschema))) - goto cleanup; + return NULL; =20 tmp =3D jsonstr; command =3D tmp; @@ -1393,13 +1378,11 @@ qemuMonitorTestNewFromFileFull(const char *fileName, goto error; } =20 - cleanup: return ret; =20 error: qemuMonitorTestFree(ret); - ret =3D NULL; - goto cleanup; + return NULL; } =20 =20 diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 90b7da8055..4cc9fccd4f 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -107,7 +107,6 @@ fakeStoragePoolLookupByName(virConnectPtr conn, const char *name) { g_autofree char *xmlpath =3D NULL; - virStoragePoolPtr ret =3D NULL; =20 if (STRNEQ(name, "inactive")) { xmlpath =3D g_strdup_printf("%s/%s%s.xml", abs_srcdir, @@ -116,14 +115,11 @@ fakeStoragePoolLookupByName(virConnectPtr conn, if (!virFileExists(xmlpath)) { virReportError(VIR_ERR_NO_STORAGE_POOL, "File '%s' not found", xmlpath); - goto cleanup; + return NULL; } } =20 - ret =3D virGetStoragePool(conn, name, fakeUUID, NULL, NULL); - - cleanup: - return ret; + return virGetStoragePool(conn, name, fakeUUID, NULL, NULL); } =20 =20 @@ -132,7 +128,6 @@ fakeStorageVolLookupByName(virStoragePoolPtr pool, const char *name) { g_auto(GStrv) volinfo =3D NULL; - virStorageVolPtr ret =3D NULL; =20 if (STREQ(pool->name, "inactive")) { virReportError(VIR_ERR_OPERATION_INVALID, @@ -155,15 +150,11 @@ fakeStorageVolLookupByName(virStoragePoolPtr pool, if (!volinfo[1]) goto fallback; =20 - ret =3D virGetStorageVol(pool->conn, pool->name, volinfo[1], volinfo[0= ], + return virGetStorageVol(pool->conn, pool->name, volinfo[1], volinfo[0], NULL, NULL); =20 - cleanup: - return ret; - fallback: - ret =3D virGetStorageVol(pool->conn, pool->name, name, "block", NULL, = NULL); - goto cleanup; + return virGetStorageVol(pool->conn, pool->name, name, "block", NULL, N= ULL); } =20 static int @@ -210,11 +201,9 @@ fakeStoragePoolGetXMLDesc(virStoragePoolPtr pool, virReportError(VIR_ERR_INTERNAL_ERROR, "failed to load XML file '%s'", xmlpath); - goto cleanup; + return NULL; } =20 - cleanup: - return xmlbuf; } =20 --=20 2.31.1 From nobody Fri May 3 12:48:53 2024 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=1630789686; cv=none; d=zohomail.com; s=zohoarc; b=FqagPssRll9YXLyqKDikBFvxHm+CO5w2S7VdbEoIQW0Cta/g0MiAwcKvE1GNmxmavWWHJDsSF0lcwMN9bpI+871bdzwK31R86pK7O4DFsIM6Z8R9WycamAKLD3F9rbXkDZwDtIfpBcJ5Ftt3oxi6owTozRR6l2sqj30QQbhQNuY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630789686; 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=r51qFeNCF6ezEJGTgu3bmpvWeigLv7hcy+EbHtWkGOQ=; b=LEEFHZPaPFYMXsNIcQH9isxGmQWmtdh+g8R61KLHVA1Qo12FzIYiQ+UnmHogAKHlPMcrh4be9xGbJzBNfSlgEIDp27/ob4I7JS1/0UmtoI0g146tv5dQ8Wc8K65+ww83oQOrxxE+HIWolOlAwekEbf8ynOkTjDtw48wFLwXOWRA= 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 1630789686019341.98146030971986; Sat, 4 Sep 2021 14:08:06 -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-433-hih2C5xfPYaUhmz9vAmdWQ-1; Sat, 04 Sep 2021 17:07:34 -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 27D2CFC86; Sat, 4 Sep 2021 21:07:30 +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 0C7FE69FC9; Sat, 4 Sep 2021 21:07:30 +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 D4C13180B44F; Sat, 4 Sep 2021 21:07:29 +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 184KimXv008913 for ; Sat, 4 Sep 2021 16:44:48 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3504A1F4; Sat, 4 Sep 2021 20:44:48 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id B33EA2619D for ; Sat, 4 Sep 2021 20:44:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630789685; 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=r51qFeNCF6ezEJGTgu3bmpvWeigLv7hcy+EbHtWkGOQ=; b=URVsG9QtTc/bU+COIEKTQQKCCBLqvqFW2iX9tIGTBNXTwbzVj9Mnjrd8oegpqM0k9Nwh0U oxM5oiQei8wjDqg7+Ffp1vlsDkxo1AEjEDQJj2TjpvSc995swL0exdoJI7qbUsGhwQuT06 LbWCvcyi3fHKSNNfOAhRdYmuC20TGTM= X-MC-Unique: hih2C5xfPYaUhmz9vAmdWQ-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 19/24] tests: vmx: remove pointless labels Date: Sat, 4 Sep 2021 22:44:17 +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.11 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: 1630789687412100001 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Laine Stump --- tests/vmx2xmltest.c | 19 +++++++------------ tests/xml2vmxtest.c | 15 +++++---------- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c index b7f232eb77..0974168cb4 100644 --- a/tests/vmx2xmltest.c +++ b/tests/vmx2xmltest.c @@ -68,7 +68,6 @@ testCapsInit(void) static int testCompareFiles(const char *vmx, const char *xml, bool should_fail_parse) { - int ret =3D -1; g_autofree char *vmxData =3D NULL; g_autofree char *formatted =3D NULL; g_autoptr(virDomainDef) def =3D NULL; @@ -79,31 +78,27 @@ testCompareFiles(const char *vmx, const char *xml, bool= should_fail_parse) def =3D virVMXParseConfig(&ctx, xmlopt, caps, vmxData); if (should_fail_parse) { if (!def) - ret =3D 0; + return 0; else VIR_TEST_DEBUG("passed instead of expected failure"); - goto cleanup; + return -1; } if (!def) - goto cleanup; + return -1; =20 if (!virDomainDefCheckABIStability(def, def, xmlopt)) { fprintf(stderr, "ABI stability check failed on %s", vmx); - goto cleanup; + return -1; } =20 if (!(formatted =3D virDomainDefFormat(def, xmlopt, VIR_DOMAIN_DEF_FORMAT_SECURE))) - goto cleanup; + return -1; =20 if (virTestCompareToFile(formatted, xml) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - - cleanup: - - return ret; + return 0; } =20 struct testInfo { diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c index 8a03237b16..60185746a8 100644 --- a/tests/xml2vmxtest.c +++ b/tests/xml2vmxtest.c @@ -70,7 +70,6 @@ testCapsInit(void) static int testCompareFiles(const char *xml, const char *vmx, int virtualHW_version) { - int result =3D -1; g_autofree char *formatted =3D NULL; g_autoptr(virDomainDef) def =3D NULL; =20 @@ -78,25 +77,21 @@ testCompareFiles(const char *xml, const char *vmx, int = virtualHW_version) VIR_DOMAIN_DEF_PARSE_INACTIVE); =20 if (def =3D=3D NULL) - goto failure; + return -1; =20 if (!virDomainDefCheckABIStability(def, def, xmlopt)) { fprintf(stderr, "ABI stability check failed on %s", xml); - goto failure; + return -1; } =20 formatted =3D virVMXFormatConfig(&ctx, xmlopt, def, virtualHW_version); if (formatted =3D=3D NULL) - goto failure; + return -1; =20 if (virTestCompareToFile(formatted, vmx) < 0) - goto failure; + return -1; =20 - result =3D 0; - - failure: - - return result; + return 0; } =20 struct testInfo { --=20 2.31.1 From nobody Fri May 3 12:48:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1630789660; cv=none; d=zohomail.com; s=zohoarc; b=RZej4IYWT2zpJGXH++4JFYnEn2obU2BstVLpmA1HlWBoNR9esaq0xwU7aHRY/GiAAUvgEMzJxJHIh1v+vdHrEG+5oFy99CEWOz1iRP9xEs9LCaaR6wPxdzUh4j3R0B/2LwlgVWZx1mEP5tww6KUJeBtiSPD00z8wA+yNBiwghnc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630789660; 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=z9OozX4WArNkv06lPr0OPElp7cRofmF9k4PShFJA1bY=; b=b9nQgPm7RwCXaihPwQAVo34fV/dPfG+z9xSiLLyoaIVz/yg9CuZ+dOF7M86M1ygves42ZJUKayChv8KuswPGJ16BOy23yZ9QYExk62cRwGD787ReIkWZsK26LEVEFevDJ5CAvHHu/ZeFPDCGfljktrUwA9LH2R7z8sW/d3Q+338= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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 [170.10.133.124]) by mx.zohomail.com with SMTPS id 1630789660425853.4790004923664; Sat, 4 Sep 2021 14:07:40 -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-290-W3pZwz5VN4iprJNLWNAscg-1; Sat, 04 Sep 2021 17:07:37 -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 98793100670B; Sat, 4 Sep 2021 21:07:32 +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 77D641F4; Sat, 4 Sep 2021 21:07:32 +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 45B8044A66; Sat, 4 Sep 2021 21:07:32 +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 184KinBD008918 for ; Sat, 4 Sep 2021 16:44:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 050352619D; Sat, 4 Sep 2021 20:44:49 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 832581F4 for ; Sat, 4 Sep 2021 20:44:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630789659; 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=z9OozX4WArNkv06lPr0OPElp7cRofmF9k4PShFJA1bY=; b=WM7wFldScZyxi8+elZ+PXrD67Dbc7IwA7IsXBTHF7dpA9jYZxkEoxGZ75VmJ87t5xqICil 9aP3Kr++Zu39yb10AA/87S64VkI4NrIJA1GKh+Xc4LR6DS+dNZhDsKqXBZYGPWOJ5mXQ2T aV5APQogYPVvP0w3w5n7l9lBdKnntZw= X-MC-Unique: W3pZwz5VN4iprJNLWNAscg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 20/24] tests: libxl: remove pointless labels Date: Sat, 4 Sep 2021 22:44:18 +0200 Message-Id: <989d92cb9082dc31b35b9ec2f34235016869a726.1630788206.git.jtomko@redhat.com> 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.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: 1630789662473100001 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Laine Stump --- tests/xlconfigtest.c | 48 ++++++++++++++++++-------------------------- tests/xmconfigtest.c | 37 +++++++++++++--------------------- 2 files changed, 34 insertions(+), 51 deletions(-) diff --git a/tests/xlconfigtest.c b/tests/xlconfigtest.c index 6717377982..d6505f9e12 100644 --- a/tests/xlconfigtest.c +++ b/tests/xlconfigtest.c @@ -68,47 +68,43 @@ testCompareParseXML(const char *xlcfg, const char *xml,= bool replaceVars) g_autoptr(virConf) conf =3D NULL; g_autoptr(virConnect) conn =3D NULL; int wrote =3D 4096; - int ret =3D -1; g_autoptr(virDomainDef) def =3D NULL; g_autofree char *replacedXML =3D NULL; =20 gotxlcfgData =3D g_new0(char, wrote); =20 conn =3D virGetConnect(); - if (!conn) goto fail; + if (!conn) + return -1; =20 if (replaceVars) { if (!(replacedXML =3D testReplaceVarsXML(xml))) - goto fail; + return -1; if (!(def =3D virDomainDefParseString(replacedXML, driver->xmlopt, NULL, VIR_DOMAIN_XML_INACTIVE)= )) - goto fail; + return -1; } else { if (!(def =3D virDomainDefParseFile(xml, driver->xmlopt, NULL, VIR_DOMAIN_XML_INACTIVE))) - goto fail; + return -1; } =20 if (!virDomainDefCheckABIStability(def, def, driver->xmlopt)) { fprintf(stderr, "ABI stability check failed on %s", xml); - goto fail; + return -1; } =20 if (!(conf =3D xenFormatXL(def, conn))) - goto fail; + return -1; =20 if (virConfWriteMem(gotxlcfgData, &wrote, conf) < 0) - goto fail; + return -1; gotxlcfgData[wrote] =3D '\0'; =20 if (virTestCompareToFile(gotxlcfgData, xlcfg) < 0) - goto fail; + return -1; =20 - ret =3D 0; - - fail: - - return ret; + return 0; } =20 /* @@ -121,44 +117,40 @@ testCompareFormatXML(const char *xlcfg, const char *x= ml, bool replaceVars) g_autofree char *xlcfgData =3D NULL; g_autofree char *gotxml =3D NULL; g_autoptr(virConf) conf =3D NULL; - int ret =3D -1; g_autoptr(virConnect) conn =3D NULL; g_autoptr(virDomainDef) def =3D NULL; g_autofree char *replacedXML =3D NULL; g_autoptr(libxlDriverConfig) cfg =3D libxlDriverConfigGet(driver); =20 conn =3D virGetConnect(); - if (!conn) goto fail; + if (!conn) + return -1; =20 if (virTestLoadFile(xlcfg, &xlcfgData) < 0) - goto fail; + return -1; =20 if (!(conf =3D virConfReadString(xlcfgData, 0))) - goto fail; + return -1; =20 if (!(def =3D xenParseXL(conf, cfg->caps, driver->xmlopt))) - goto fail; + return -1; =20 if (!(gotxml =3D virDomainDefFormat(def, driver->xmlopt, VIR_DOMAIN_XML_INACTIVE | VIR_DOMAIN_XML_SECURE))) - goto fail; + return -1; =20 if (replaceVars) { if (!(replacedXML =3D testReplaceVarsXML(xml))) - goto fail; + return -1; if (virTestCompareToString(gotxml, replacedXML) < 0) - goto fail; + return -1; } else { if (virTestCompareToFile(gotxml, xml) < 0) - goto fail; + return -1; } =20 - ret =3D 0; - - fail: - - return ret; + return 0; } =20 =20 diff --git a/tests/xmconfigtest.c b/tests/xmconfigtest.c index bd23e5fd5d..c99d1f2bd9 100644 --- a/tests/xmconfigtest.c +++ b/tests/xmconfigtest.c @@ -41,7 +41,6 @@ testCompareParseXML(const char *xmcfg, const char *xml) { g_autofree char *gotxmcfgData =3D NULL; g_autoptr(virConf) conf =3D NULL; - int ret =3D -1; g_autoptr(virConnect) conn =3D NULL; int wrote =3D 4096; g_autoptr(virDomainDef) def =3D NULL; @@ -49,32 +48,29 @@ testCompareParseXML(const char *xmcfg, const char *xml) gotxmcfgData =3D g_new0(char, wrote); =20 conn =3D virGetConnect(); - if (!conn) goto fail; + if (!conn) + return -1; =20 if (!(def =3D virDomainDefParseFile(xml, driver->xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE))) - goto fail; + return -1; =20 if (!virDomainDefCheckABIStability(def, def, driver->xmlopt)) { fprintf(stderr, "ABI stability check failed on %s", xml); - goto fail; + return -1; } =20 if (!(conf =3D xenFormatXM(conn, def))) - goto fail; + return -1; =20 if (virConfWriteMem(gotxmcfgData, &wrote, conf) < 0) - goto fail; + return -1; gotxmcfgData[wrote] =3D '\0'; =20 if (virTestCompareToFile(gotxmcfgData, xmcfg) < 0) - goto fail; + return -1; =20 - ret =3D 0; - - fail: - - return ret; + return 0; } =20 static int @@ -83,30 +79,25 @@ testCompareFormatXML(const char *xmcfg, const char *xml) g_autofree char *xmcfgData =3D NULL; g_autofree char *gotxml =3D NULL; g_autoptr(virConf) conf =3D NULL; - int ret =3D -1; g_autoptr(virDomainDef) def =3D NULL; g_autoptr(libxlDriverConfig) cfg =3D libxlDriverConfigGet(driver); =20 if (virTestLoadFile(xmcfg, &xmcfgData) < 0) - goto fail; + return -1; =20 if (!(conf =3D virConfReadString(xmcfgData, 0))) - goto fail; + return -1; =20 if (!(def =3D xenParseXM(conf, cfg->caps, driver->xmlopt))) - goto fail; + return -1; =20 if (!(gotxml =3D virDomainDefFormat(def, driver->xmlopt, VIR_DOMAIN_DE= F_FORMAT_SECURE))) - goto fail; + return -1; =20 if (virTestCompareToFile(gotxml, xml) < 0) - goto fail; + return -1; =20 - ret =3D 0; - - fail: - - return ret; + return 0; } =20 =20 --=20 2.31.1 From nobody Fri May 3 12:48:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1630788706; cv=none; d=zohomail.com; s=zohoarc; b=Y8Mc5bMsSJB9dhu7QVHxAEjMznr2Jpo+5zB5GMwfCwLdolvQQga52ueXLSSsRFx3mLToSqvHxaWw6Q5LULGznqg9qni642Cj+2EjU0FoTLRvLUAtStZDaq6cQZM/mTqNSfwcIdbBtqR8uR/m1jtpJrmRNY9Am9lOJCRLybp07GQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630788706; 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=kFkxzQnvDtw1YaEwht1qmZwIS0kq2wcfQLHIK+1Q3AE=; b=QT8Ch3T5esJp9tMPi1o1/CAzCJ8YPW4QsZFBx72OdQQCvQnyTdcbV1juK/uYZzwqs3fjZbtudoSvIk2/1n8lbpfofF7MIts1sLfcLkRFY5kwkFnl+rfiBm+tXcv/Auhx0rbKH0DM4RFWH9UrLjprEPug1H+BKtxu7Fe2GyyFi2U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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 [170.10.133.124]) by mx.zohomail.com with SMTPS id 1630788706065108.41506455520448; Sat, 4 Sep 2021 13:51:46 -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-60-hWpqurteMvuh7plHaHVnlQ-1; Sat, 04 Sep 2021 16:51:43 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 85B95107AD28; Sat, 4 Sep 2021 20:51:38 +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 6B45D60C25; Sat, 4 Sep 2021 20:51:38 +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 405641801021; Sat, 4 Sep 2021 20:51:38 +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 184KinKG008927 for ; Sat, 4 Sep 2021 16:44:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id CA86A2619D; Sat, 4 Sep 2021 20:44:49 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 52B511F4 for ; Sat, 4 Sep 2021 20:44:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630788705; 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=kFkxzQnvDtw1YaEwht1qmZwIS0kq2wcfQLHIK+1Q3AE=; b=dXa7YHDqenbPmpbJICdZS7br9k9XwEN3ToWEh5JCYEwCsRrzMeK4al+1Mz9v5iPtOCtsbb O24BPXix99kWQO87mdmPUTzJNli8Sq/tfQNwAGRvDPAhmvFoWtFKy4t8v58rj9egm98J4p nzwhPIVK+1S41s7WruBmnd1pgYrfDgs= X-MC-Unique: hWpqurteMvuh7plHaHVnlQ-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 21/24] tests: nwfilter: remove pointless labels Date: Sat, 4 Sep 2021 22:44:19 +0200 Message-Id: <6e3fcdb84a9faab3f725a36827acb8c375189e04.1630788206.git.jtomko@redhat.com> 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.13 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: 1630788707438100001 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Laine Stump --- tests/nwfilterebiptablestest.c | 63 ++++++++++++---------------------- 1 file changed, 21 insertions(+), 42 deletions(-) diff --git a/tests/nwfilterebiptablestest.c b/tests/nwfilterebiptablestest.c index 7b32e90d19..9307a10229 100644 --- a/tests/nwfilterebiptablestest.c +++ b/tests/nwfilterebiptablestest.c @@ -102,24 +102,21 @@ testNWFilterEBIPTablesAllTeardown(const void *opaque = G_GNUC_UNUSED) "ebtables --concurrent -t nat -F libvirt-O-vnet0\n" "ebtables --concurrent -t nat -X libvirt-O-vnet0\n"; g_autofree char *actual =3D NULL; - int ret =3D -1; g_autoptr(virCommandDryRunToken) dryRunToken =3D virCommandDryRunToken= New(); =20 virCommandSetDryRun(dryRunToken, &buf, false, true, NULL, NULL); =20 if (ebiptables_driver.allTeardown("vnet0") < 0) - goto cleanup; + return -1; =20 actual =3D virBufferContentAndReset(&buf); =20 if (STRNEQ_NULLABLE(actual, expected)) { virTestDifference(stderr, expected, actual); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -167,24 +164,21 @@ testNWFilterEBIPTablesTearOldRules(const void *opaque= G_GNUC_UNUSED) "ebtables --concurrent -t nat -E libvirt-J-vnet0 libvirt-I-vnet0\n" "ebtables --concurrent -t nat -E libvirt-P-vnet0 libvirt-O-vnet0\n= "; g_autofree char *actual =3D NULL; - int ret =3D -1; g_autoptr(virCommandDryRunToken) dryRunToken =3D virCommandDryRunToken= New(); =20 virCommandSetDryRun(dryRunToken, &buf, false, true, NULL, NULL); =20 if (ebiptables_driver.tearOldRules("vnet0") < 0) - goto cleanup; + return -1; =20 actual =3D virBufferContentAndReset(&buf); =20 if (STRNEQ_NULLABLE(actual, expected)) { virTestDifference(stderr, expected, actual); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -210,24 +204,21 @@ testNWFilterEBIPTablesRemoveBasicRules(const void *op= aque G_GNUC_UNUSED) "ebtables --concurrent -t nat -F libvirt-P-vnet0\n" "ebtables --concurrent -t nat -X libvirt-P-vnet0\n"; g_autofree char *actual =3D NULL; - int ret =3D -1; g_autoptr(virCommandDryRunToken) dryRunToken =3D virCommandDryRunToken= New(); =20 virCommandSetDryRun(dryRunToken, &buf, false, true, NULL, NULL); =20 if (ebiptables_driver.removeBasicRules("vnet0") < 0) - goto cleanup; + return -1; =20 actual =3D virBufferContentAndReset(&buf); =20 if (STRNEQ_NULLABLE(actual, expected)) { virTestDifference(stderr, expected, actual); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -238,24 +229,21 @@ testNWFilterEBIPTablesTearNewRules(const void *opaque= G_GNUC_UNUSED) const char *expected =3D VIR_NWFILTER_NEW_RULES_TEARDOWN; g_autofree char *actual =3D NULL; - int ret =3D -1; g_autoptr(virCommandDryRunToken) dryRunToken =3D virCommandDryRunToken= New(); =20 virCommandSetDryRun(dryRunToken, &buf, false, true, NULL, NULL); =20 if (ebiptables_driver.tearNewRules("vnet0") < 0) - goto cleanup; + return -1; =20 actual =3D virBufferContentAndReset(&buf); =20 if (STRNEQ_NULLABLE(actual, expected)) { virTestDifference(stderr, expected, actual); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -303,25 +291,22 @@ testNWFilterEBIPTablesApplyBasicRules(const void *opa= que G_GNUC_UNUSED) "ebtables --concurrent -t nat -A PREROUTING -i vnet0 -j libvirt-J-= vnet0\n" "ebtables --concurrent -t nat -E libvirt-J-vnet0 libvirt-I-vnet0\n= "; g_autofree char *actual =3D NULL; - int ret =3D -1; virMacAddr mac =3D { .addr =3D { 0x10, 0x20, 0x30, 0x40, 0x50, 0x60 } = }; g_autoptr(virCommandDryRunToken) dryRunToken =3D virCommandDryRunToken= New(); =20 virCommandSetDryRun(dryRunToken, &buf, false, true, NULL, NULL); =20 if (ebiptables_driver.applyBasicRules("vnet0", &mac) < 0) - goto cleanup; + return -1; =20 actual =3D virBufferContentAndReset(&buf); =20 if (STRNEQ_NULLABLE(actual, expected)) { virTestDifference(stderr, expected, actual); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -377,7 +362,6 @@ testNWFilterEBIPTablesApplyDHCPOnlyRules(const void *op= aque G_GNUC_UNUSED) "ebtables --concurrent -t nat -E libvirt-J-vnet0 libvirt-I-vnet0\n" "ebtables --concurrent -t nat -E libvirt-P-vnet0 libvirt-O-vnet0\n= "; g_autofree char *actual =3D NULL; - int ret =3D -1; virMacAddr mac =3D { .addr =3D { 0x10, 0x20, 0x30, 0x40, 0x50, 0x60 } = }; const char *servers[] =3D { "192.168.122.1", "10.0.0.1", "10.0.0.2" }; virNWFilterVarValue val =3D { @@ -394,18 +378,16 @@ testNWFilterEBIPTablesApplyDHCPOnlyRules(const void *= opaque G_GNUC_UNUSED) virCommandSetDryRun(dryRunToken, &buf, false, true, NULL, NULL); =20 if (ebiptables_driver.applyDHCPOnlyRules("vnet0", &mac, &val, false) <= 0) - goto cleanup; + return -1; =20 actual =3D virBufferContentAndReset(&buf); =20 if (STRNEQ_NULLABLE(actual, expected)) { virTestDifference(stderr, expected, actual); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -455,24 +437,21 @@ testNWFilterEBIPTablesApplyDropAllRules(const void *o= paque G_GNUC_UNUSED) "ebtables --concurrent -t nat -E libvirt-J-vnet0 libvirt-I-vnet0\n" "ebtables --concurrent -t nat -E libvirt-P-vnet0 libvirt-O-vnet0\n= "; g_autofree char *actual =3D NULL; - int ret =3D -1; g_autoptr(virCommandDryRunToken) dryRunToken =3D virCommandDryRunToken= New(); =20 virCommandSetDryRun(dryRunToken, &buf, false, true, NULL, NULL); =20 if (ebiptables_driver.applyDropAllRules("vnet0") < 0) - goto cleanup; + return -1; =20 actual =3D virBufferContentAndReset(&buf); =20 if (STRNEQ_NULLABLE(actual, expected)) { virTestDifference(stderr, expected, actual); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 --=20 2.31.1 From nobody Fri May 3 12:48:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1630788785; cv=none; d=zohomail.com; s=zohoarc; b=heP9wMI2xsuojjIIXGOFD/ahXpkmN+xr4ETFl1PIWtVR+Ra5iEUgvXAk6LhWWukpaalDHNXFGklCfR6+Hz/K7b5yn5wg8QO/wQ9BR9NXjCzkTOFPdFxVUQfWUuCzaQrceNS/tY/RPOyHTLeUmaMe69pLJ5Ou7PwFMgeyk2n5Ifo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630788785; 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=FmQfYJGnm6RoIt6PY0iclB2kvipKZstOVKpdDFNoiI4=; b=YPcoWqZjaGqLB5L+jMfyWErcrtUnK0zFrn0nONkxBB3D79oF0jgMbi8sdA22mh27+T5F+OCnSIP3JhxreE+qBk/qY7kggRf9013OLdUxA2p6fCQNxpTdGBbfQBd5x4jrKaRU77YKCqcXxEQCwFbd1rk6uBWo75InWsaEILQseE4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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 [170.10.133.124]) by mx.zohomail.com with SMTPS id 1630788785268947.8916493768261; Sat, 4 Sep 2021 13:53: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-278-dxg7BjUSPGC9Uoh-SgaUjw-1; Sat, 04 Sep 2021 16:51:45 -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 0EBA31854E27; Sat, 4 Sep 2021 20:51:41 +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 E67266B543; Sat, 4 Sep 2021 20:51:40 +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 B9186180BAB5; Sat, 4 Sep 2021 20:51:40 +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 184Kiod5008934 for ; Sat, 4 Sep 2021 16:44:50 -0400 Received: by smtp.corp.redhat.com (Postfix) id 99CD61F4; Sat, 4 Sep 2021 20:44:50 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 232C826367 for ; Sat, 4 Sep 2021 20:44:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630788784; 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=FmQfYJGnm6RoIt6PY0iclB2kvipKZstOVKpdDFNoiI4=; b=Jkz+pEW47P+R4pfWkyMwid3ToPhXwsMGrCpr0P5isOpMHA/+CXzQlgWAyHb/R3C9jA3chM OX7fClEDaJqRdU9ckC0luq+Z47u/rTG5Zs7OnuXCvZR7yZ+LEtngCsUpaF0K2qvUdYogof FvrkY+ktqXebb4l2Pfxlu+sSxWL2oJI= X-MC-Unique: dxg7BjUSPGC9Uoh-SgaUjw-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 22/24] tests: vshtabletest: remove pointless labels Date: Sat, 4 Sep 2021 22:44:20 +0200 Message-Id: <631d796eb3fe1a50cafc267b2e6bd86b9be43159.1630788206.git.jtomko@redhat.com> 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: 1630788785797100001 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Laine Stump --- tests/vshtabletest.c | 71 +++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 43 deletions(-) diff --git a/tests/vshtabletest.c b/tests/vshtabletest.c index 569d7a852f..716b11dbc0 100644 --- a/tests/vshtabletest.c +++ b/tests/vshtabletest.c @@ -81,42 +81,38 @@ testVshTableHeader(const void *opaque G_GNUC_UNUSED) static int testVshTableRowAppend(const void *opaque G_GNUC_UNUSED) { - int ret =3D 0; - g_autoptr(vshTable) table =3D vshTableNew("Id", "Name", NULL); if (!table) - goto cleanup; + return -1; =20 if (vshTableRowAppend(table, NULL) >=3D 0) { fprintf(stderr, "Appending NULL shouldn't work\n"); - ret =3D -1; + return -1; } =20 if (vshTableRowAppend(table, "2", NULL) >=3D 0) { fprintf(stderr, "Appending less items than in header\n"); - ret =3D -1; + return -1; } =20 if (vshTableRowAppend(table, "2", "rhel7.5", "running", NULL) >=3D 0) { fprintf(stderr, "Appending more items than in header\n"); - ret =3D -1; + return -1; } =20 if (vshTableRowAppend(table, "2", "rhel7.5", NULL) < 0) { fprintf(stderr, "Appending same number of items as in header" " should not return NULL\n"); - ret =3D -1; + return -1; } =20 - cleanup: - return ret; + return 0; } =20 static int testUnicode(const void *opaque G_GNUC_UNUSED) { - int ret =3D 0; g_autofree char *act =3D NULL; =20 const char *exp =3D @@ -128,7 +124,7 @@ testUnicode(const void *opaque G_GNUC_UNUSED) =20 table =3D vshTableNew("Id", "=E5=90=8D=E7=A8=B1", "=D0=B3=D0=BE=D1=81= =D1=83=D0=B4=D0=B0=D1=80=D1=81=D1=82=D0=B2=D0=BE", NULL); if (!table) - goto cleanup; + return -1; =20 vshTableRowAppend(table, "1", "fedora28", "running", NULL); vshTableRowAppend(table, "2", "=E3=81=A4=E3=81=B8=E3=82=BDrhel7.5=E3= =81=A4=E3=81=B8=E3=82=BD", "running", @@ -136,17 +132,15 @@ testUnicode(const void *opaque G_GNUC_UNUSED) =20 act =3D vshTablePrintToString(table, true); if (virTestCompareToString(exp, act) < 0) - ret =3D -1; + return -1; =20 - cleanup: - return ret; + return 0; } =20 /* Point of this test is to see how table behaves with right to left writi= ng */ static int testUnicodeArabic(const void *opaque G_GNUC_UNUSED) { - int ret =3D 0; g_autofree char *act =3D NULL; =20 const char *exp =3D @@ -167,7 +161,7 @@ testUnicodeArabic(const void *opaque G_GNUC_UNUSED) =20 table =3D vshTableNew("=EF=BB=A1=EF=BA=8D =EF=BB=A2=EF=BB=A3=EF=BA=8D = =EF=BB=95=EF=BA=8E=EF=BA=8C=EF=BB=A3=EF=BA=93", "=EF=BA=93 =EF=BA=8E=EF=BB= =A0=EF=BA=BC=EF=BB=8B", "=EF=BA=8D=EF=BB=B8=EF=BA=9C=EF=BB=A7=EF=BA=8E=EF= =BB=A7", NULL); if (!table) - goto cleanup; + return -1; vshTableRowAppend(table, "1", "=EF=BB=89=EF=BA=AA=EF=BB=B4=EF=BB=9F =EF=BA=8E=EF= =BB=A0=EF=BA=9C=EF=BB=98=EF=BB=B4=EF=BB=9F =EF=BB=95=EF=BA=8E=EF=BB=A3 =EF= =BB=8A=EF=BB=A7, =D9=A3=D9=A0 =EF=BB=8E=EF=BB=B4=EF=BB=A8=EF=BB=B3=EF=BA=8D= =EF=BB=AE=EF=BA=98=EF=BB=A7=EF=BA=8E=EF=BB=A4=EF=BA=97 =EF=BA=8E=EF=BB=A0= =EF=BA=9B=EF=BA=8E=EF=BB=A0=EF=BA=9B=D8=8C =EF=BA=84=EF=BA=B3=EF=BA=AD, =EF= =BA=A9=EF=BB=AE=EF=BB=9F", @@ -177,17 +171,15 @@ testUnicodeArabic(const void *opaque G_GNUC_UNUSED) NULL); act =3D vshTablePrintToString(table, true); if (virTestCompareToString(exp, act) < 0) - ret =3D -1; + return -1; =20 - cleanup: - return ret; + return 0; } =20 /* Testing zero-width characters by inserting few zero-width spaces */ static int testUnicodeZeroWidthChar(const void *opaque G_GNUC_UNUSED) { - int ret =3D 0; g_autoptr(vshTable) table =3D NULL; const char *exp =3D " I\u200Bd Name \u200BStatus\n" @@ -207,22 +199,20 @@ testUnicodeZeroWidthChar(const void *opaque G_GNUC_UN= USED) =20 table =3D vshTableNew("I\u200Bd", "Name", "\u200BStatus", NULL); if (!table) - goto cleanup; + return -1; vshTableRowAppend(table, "1\u200B", "fedora28", "run\u200Bning", NULL); vshTableRowAppend(table, "2", "rhel7.5", "running", NULL); act =3D vshTablePrintToString(table, true); =20 if (virTestCompareToString(exp, act) < 0) - ret =3D -1; + return -1; =20 - cleanup: - return ret; + return 0; } =20 static int testUnicodeCombiningChar(const void *opaque G_GNUC_UNUSED) { - int ret =3D 0; g_autoptr(vshTable) table =3D NULL; const char *exp =3D " Id N=C3=A1me =E2=93=88tatus\n" @@ -233,23 +223,21 @@ testUnicodeCombiningChar(const void *opaque G_GNUC_UN= USED) =20 table =3D vshTableNew("Id", "N=C3=A1me", "=E2=93=88tatus", NULL); if (!table) - goto cleanup; + return -1; vshTableRowAppend(table, "1", "f=C4=9Bdora28", "running", NULL); vshTableRowAppend(table, "2", "rhel", "running", NULL); act =3D vshTablePrintToString(table, true); =20 if (virTestCompareToString(exp, act) < 0) - ret =3D -1; + return -1; =20 - cleanup: - return ret; + return 0; } =20 /* Testing zero-width characters by inserting few zero-width spaces */ static int testUnicodeNonPrintableChar(const void *opaque G_GNUC_UNUSED) { - int ret =3D 0; g_autoptr(vshTable) table =3D NULL; const char *exp =3D " I\\x09d Name Status\n" @@ -260,22 +248,20 @@ testUnicodeNonPrintableChar(const void *opaque G_GNUC= _UNUSED) =20 table =3D vshTableNew("I\td", "Name", "Status", NULL); if (!table) - goto cleanup; + return -1; vshTableRowAppend(table, "1", "f\aedora28", "running", NULL); vshTableRowAppend(table, "2", "rhel7.5", "running", NULL); act =3D vshTablePrintToString(table, true); =20 if (virTestCompareToString(exp, act) < 0) - ret =3D -1; + return -1; =20 - cleanup: - return ret; + return 0; } =20 static int testNTables(const void *opaque G_GNUC_UNUSED) { - int ret =3D 0; g_autoptr(vshTable) table1 =3D NULL; g_autoptr(vshTable) table2 =3D NULL; g_autoptr(vshTable) table3 =3D NULL; @@ -301,7 +287,7 @@ testNTables(const void *opaque G_GNUC_UNUSED) =20 table1 =3D vshTableNew("Id", "Name", "Status", NULL); if (!table1) - goto cleanup; + return -1; vshTableRowAppend(table1, "1", "fedora28", "running", NULL); vshTableRowAppend(table1, "2", "rhel7.5", "running", NULL); vshTableRowAppend(table1, "3", "gazpacho", "", NULL); @@ -309,12 +295,12 @@ testNTables(const void *opaque G_GNUC_UNUSED) =20 table2 =3D vshTableNew("Id", "Name", "Status", NULL); if (!table2) - goto cleanup; + return -1; act2 =3D vshTablePrintToString(table2, true); =20 table3 =3D vshTableNew("Id", NULL); if (!table3) - goto cleanup; + return -1; vshTableRowAppend(table3, "1", NULL); vshTableRowAppend(table3, "2", NULL); vshTableRowAppend(table3, "3", NULL); @@ -322,14 +308,13 @@ testNTables(const void *opaque G_GNUC_UNUSED) act3 =3D vshTablePrintToString(table3, true); =20 if (virTestCompareToString(exp1, act1) < 0) - ret =3D -1; + return -1; if (virTestCompareToString(exp2, act2) < 0) - ret =3D -1; + return -1; if (virTestCompareToString(exp3, act3) < 0) - ret =3D -1; + return -1; =20 - cleanup: - return ret; + return 0; } =20 static int --=20 2.31.1 From nobody Fri May 3 12:48:53 2024 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=1630788427; cv=none; d=zohomail.com; s=zohoarc; b=SXOfVDegleD7eeB3edS15REr8E2rgUn+ecy4qFqyCBRDAEzLsb3H0sMLaxau5zl8S+ltUA+jsawV/Wulw8ZstYq+zEJSH9nVehQHRw20B9uz6DJDqZ9M2s14B8nAYOe00l886HL5L7JrMBkKMDYCiOzXScbJ85CBJ8qsU5x6BFg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630788427; 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=IGUR0JRKcEvT/Zg2k5Q0To/B1fFWFe8oCfqQEBVgjUI=; b=IAt5PDsaz7HtEVN/ua0Je+J/76ayQGk/amQ+z9bVlmAoJo2gd4E46VewiuF4PQeVEX9cMytzV1UqPU60HNZSLMGDnEt9Bj1xMGFNjeuguyqnyZLqc6CZ0cMHtRZsCSNoA2ND3CyFq9IZc6fi8xljRyz/nnPhoexywZAplHV9anY= 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 1630788427271706.8788440618831; Sat, 4 Sep 2021 13:47:07 -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-457-oJzgQS6eNny4EHJGomZI1w-1; Sat, 04 Sep 2021 16:47:04 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 347BF107ACCA; Sat, 4 Sep 2021 20:46:59 +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 1591E5FC23; Sat, 4 Sep 2021 20:46:59 +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 D9BCA44A62; Sat, 4 Sep 2021 20:46:58 +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 184KipOi008940 for ; Sat, 4 Sep 2021 16:44:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6B7E52619D; Sat, 4 Sep 2021 20:44:51 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id E80A51F4 for ; Sat, 4 Sep 2021 20:44:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630788426; 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=IGUR0JRKcEvT/Zg2k5Q0To/B1fFWFe8oCfqQEBVgjUI=; b=R2yS3LodWJEKu6R/i6UoHC3Afy8Zz3+02EKk6W4S4ypk2qtWPcNQPv4Ot6bdnFBaaSvpkd aa5qwf76iVqBkAtTREoHg8ANxOIzwOEIS3+r5LTWi1KBFqlxJbxY5Ob2IfkFMBmzflhdxf +qmpAT/oOkg2yBbHK7qJxpzcF+h+P9A= X-MC-Unique: oJzgQS6eNny4EHJGomZI1w-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 23/24] tests: vir: remove pointless labels Date: Sat, 4 Sep 2021 22:44:21 +0200 Message-Id: <5d757aeb1d679ae2164411d7d1b278a1c7094c45.1630788206.git.jtomko@redhat.com> 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.16 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: 1630788429142100001 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Laine Stump --- tests/vircapstest.c | 14 +++------ tests/virconftest.c | 38 ++++++++++-------------- tests/vircryptotest.c | 23 +++++---------- tests/virfiletest.c | 49 ++++++++++++------------------- tests/virhostcputest.c | 12 +++----- tests/viriscsitest.c | 15 +++------- tests/virkmodtest.c | 30 ++++++------------- tests/virmacmaptest.c | 31 +++++++------------ tests/virnetworkportxml2xmltest.c | 15 ++++------ tests/virnumamock.c | 7 ++--- tests/virpcitest.c | 22 ++++++-------- tests/virresctrltest.c | 16 ++++------ tests/virscsitest.c | 15 +++------- tests/virstringtest.c | 32 +++++--------------- tests/virsystemdtest.c | 20 ++++--------- 15 files changed, 115 insertions(+), 224 deletions(-) diff --git a/tests/vircapstest.c b/tests/vircapstest.c index ebabbbb9a0..d1b5033844 100644 --- a/tests/vircapstest.c +++ b/tests/vircapstest.c @@ -153,10 +153,8 @@ test_virCapsDomainDataLookupQEMU(const void *data G_GN= UC_UNUSED) int ret =3D 0; g_autoptr(virCaps) caps =3D NULL; =20 - if (!(caps =3D testQemuCapsInit())) { - ret =3D -1; - goto out; - } + if (!(caps =3D testQemuCapsInit())) + return -1; =20 /* Checking each parameter individually */ CAPSCOMP(-1, VIR_ARCH_NONE, VIR_DOMAIN_VIRT_NONE, NULL, NULL, @@ -195,7 +193,6 @@ test_virCapsDomainDataLookupQEMU(const void *data G_GNU= C_UNUSED) "/usr/bin/qemu-system-aarch64", "pc"); CAPS_EXPECT_ERR(-1, VIR_ARCH_NONE, VIR_DOMAIN_VIRT_VMWARE, NULL, "pc"); =20 - out: return ret; } #endif /* WITH_QEMU */ @@ -207,10 +204,8 @@ test_virCapsDomainDataLookupLXC(const void *data G_GNU= C_UNUSED) int ret =3D 0; g_autoptr(virCaps) caps =3D NULL; =20 - if (!(caps =3D testLXCCapsInit())) { - ret =3D -1; - goto out; - } + if (!(caps =3D testLXCCapsInit())) + return -1; =20 CAPSCOMP(-1, VIR_ARCH_NONE, VIR_DOMAIN_VIRT_NONE, NULL, NULL, VIR_DOMAIN_OSTYPE_EXE, VIR_ARCH_X86_64, @@ -219,7 +214,6 @@ test_virCapsDomainDataLookupLXC(const void *data G_GNUC= _UNUSED) VIR_DOMAIN_OSTYPE_EXE, VIR_ARCH_X86_64, VIR_DOMAIN_VIRT_LXC, "/usr/libexec/libvirt_lxc", NULL); =20 - out: return ret; } #endif /* WITH_LXC */ diff --git a/tests/virconftest.c b/tests/virconftest.c index a7189579d3..5d1ad8a612 100644 --- a/tests/virconftest.c +++ b/tests/virconftest.c @@ -67,7 +67,6 @@ static int testConfMemoryNoNewline(const void *opaque G_G= NUC_UNUSED) "uint =3D 12345"; =20 g_autoptr(virConf) conf =3D virConfReadString(srcdata, 0); - int ret =3D -1; virConfValue *val; unsigned long long llvalue; g_autofree char *str =3D NULL; @@ -77,49 +76,47 @@ static int testConfMemoryNoNewline(const void *opaque G= _GNUC_UNUSED) return -1; =20 if (!(val =3D virConfGetValue(conf, "ullong"))) - goto cleanup; + return -1; =20 if (val->type !=3D VIR_CONF_STRING) - goto cleanup; + return -1; =20 if (virStrToLong_ull(val->str, NULL, 10, &llvalue) < 0) - goto cleanup; + return -1; =20 if (llvalue !=3D 123456789) { fprintf(stderr, "Expected '123' got '%llu'\n", llvalue); - goto cleanup; + return -1; } =20 if (virConfGetValueType(conf, "string") !=3D VIR_CONF_STRING) { fprintf(stderr, "expected a string for 'string'\n"); - goto cleanup; + return -1; } =20 if (virConfGetValueString(conf, "string", &str) < 0) - goto cleanup; + return -1; =20 if (STRNEQ_NULLABLE(str, "foo")) { fprintf(stderr, "Expected 'foo' got '%s'\n", str); - goto cleanup; + return -1; } =20 if (virConfGetValueType(conf, "uint") !=3D VIR_CONF_ULLONG) { fprintf(stderr, "expected an unsigned long for 'uint'\n"); - goto cleanup; + return -1; } =20 if (virConfGetValueInt(conf, "uint", &uintvalue) < 0) - goto cleanup; + return -1; =20 if (uintvalue !=3D 12345) { fprintf(stderr, "Expected 12345 got %ud\n", uintvalue); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -338,7 +335,6 @@ static int testConfParseString(const void *opaque G_GNU= C_UNUSED) "int =3D 6963472309248\n" \ "string =3D \"foo\"\n"; =20 - int ret =3D -1; g_autoptr(virConf) conf =3D virConfReadString(srcdata, 0); g_autofree char *str =3D NULL; =20 @@ -348,25 +344,23 @@ static int testConfParseString(const void *opaque G_G= NUC_UNUSED) if (virConfGetValueType(conf, "string") !=3D VIR_CONF_STRING) { fprintf(stderr, "expected a string for 'string'\n"); - goto cleanup; + return -1; } =20 if (virConfGetValueString(conf, "string", &str) < 0) - goto cleanup; + return -1; =20 if (STRNEQ_NULLABLE(str, "foo")) { fprintf(stderr, "Expected 'foo' got '%s'\n", str); - goto cleanup; + return -1; } =20 if (virConfGetValueString(conf, "int", &str) !=3D -1) { fprintf(stderr, "Expected error for 'int'\n"); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 diff --git a/tests/vircryptotest.c b/tests/vircryptotest.c index 2d503a439e..98af476156 100644 --- a/tests/vircryptotest.c +++ b/tests/vircryptotest.c @@ -38,22 +38,19 @@ testCryptoHash(const void *opaque) { const struct testCryptoHashData *data =3D opaque; g_autofree char *actual =3D NULL; - int ret =3D -1; =20 if (virCryptoHashString(data->hash, data->input, &actual) < 0) { fprintf(stderr, "Failed to generate crypto hash\n"); - goto cleanup; + return -1; } =20 if (STRNEQ_NULLABLE(data->output, actual)) { fprintf(stderr, "Expected hash '%s' but got '%s'\n", data->output, NULLSTR(actual)); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -75,7 +72,6 @@ testCryptoEncrypt(const void *opaque) size_t ivlen =3D 16; g_autofree uint8_t *ciphertext =3D NULL; size_t ciphertextlen =3D 0; - int ret =3D -1; =20 if (!virCryptoHaveCipher(data->algorithm)) { fprintf(stderr, "cipher algorithm=3D%d unavailable\n", data->algor= ithm); @@ -88,29 +84,26 @@ testCryptoEncrypt(const void *opaque) if (virRandomBytes(enckey, enckeylen) < 0 || virRandomBytes(iv, ivlen) < 0) { fprintf(stderr, "Failed to generate random bytes\n"); - goto cleanup; + return -1; } =20 if (virCryptoEncryptData(data->algorithm, enckey, enckeylen, iv, ivlen, data->input, data->inputlen, &ciphertext, &ciphertextlen) < 0) - goto cleanup; + return -1; =20 if (data->ciphertextlen !=3D ciphertextlen) { fprintf(stderr, "Expected ciphertextlen(%zu) doesn't match (%zu)\n= ", data->ciphertextlen, ciphertextlen); - goto cleanup; + return -1; } =20 if (memcmp(data->ciphertext, ciphertext, ciphertextlen)) { fprintf(stderr, "Expected ciphertext doesn't match\n"); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - - return ret; + return 0; } =20 =20 diff --git a/tests/virfiletest.c b/tests/virfiletest.c index a6e722b4d2..4b69ea1b69 100644 --- a/tests/virfiletest.c +++ b/tests/virfiletest.c @@ -103,7 +103,6 @@ static int testFileSanitizePath(const void *opaque) { const struct testFileSanitizePathData *data =3D opaque; - int ret =3D -1; g_autofree char *actual =3D NULL; =20 if (!(actual =3D virFileSanitizePath(data->path))) @@ -111,13 +110,10 @@ testFileSanitizePath(const void *opaque) =20 if (STRNEQ(actual, data->expect)) { fprintf(stderr, "\nexpect: '%s'\nactual: '%s'\n", data->expect, ac= tual); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -195,41 +191,38 @@ holesSupported(void) off_t offsets[] =3D {EXTENT, EXTENT, EXTENT, -1}; off_t tmp; VIR_AUTOCLOSE fd =3D -1; - bool ret =3D false; =20 if ((fd =3D makeSparseFile(offsets, true)) < 0) - goto cleanup; + return false; =20 /* The way this works is: there are 4K of data followed by 4K hole fol= lowed * by 4K hole again. Check if the filesystem we are running the test s= uite * on supports holes. */ if ((tmp =3D lseek(fd, 0, SEEK_DATA)) =3D=3D (off_t) -1) - goto cleanup; + return false; =20 if (tmp !=3D 0) - goto cleanup; + return false; =20 if ((tmp =3D lseek(fd, tmp, SEEK_HOLE)) =3D=3D (off_t) -1) - goto cleanup; + return false; =20 if (tmp !=3D EXTENT * 1024) - goto cleanup; + return false; =20 if ((tmp =3D lseek(fd, tmp, SEEK_DATA)) =3D=3D (off_t) -1) - goto cleanup; + return false; =20 if (tmp !=3D 2 * EXTENT * 1024) - goto cleanup; + return false; =20 if ((tmp =3D lseek(fd, tmp, SEEK_HOLE)) =3D=3D (off_t) -1) - goto cleanup; + return false; =20 if (tmp !=3D 3 * EXTENT * 1024) - goto cleanup; + return false; =20 - ret =3D true; - cleanup: - return ret; + return true; } =20 #else /* !WITH_DECL_SEEK_HOLE || !defined(__linux__)*/ @@ -261,11 +254,10 @@ testFileInData(const void *opaque) { const struct testFileInData *data =3D opaque; VIR_AUTOCLOSE fd =3D -1; - int ret =3D -1; size_t i; =20 if ((fd =3D makeSparseFile(data->offsets, data->startData)) < 0) - goto cleanup; + return -1; =20 for (i =3D 0; data->offsets[i] !=3D (off_t) -1; i++) { bool shouldInData =3D data->startData; @@ -277,32 +269,29 @@ testFileInData(const void *opaque) shouldInData =3D !shouldInData; =20 if (virFileInData(fd, &realInData, &realLen) < 0) - goto cleanup; + return -1; =20 if (realInData !=3D shouldInData) { fprintf(stderr, "Unexpected data/hole. Expected %s got %s\n", shouldInData ? "data" : "hole", realInData ? "data" : "hole"); - goto cleanup; + return -1; } =20 shouldLen =3D data->offsets[i] * 1024; if (realLen !=3D shouldLen) { fprintf(stderr, "Unexpected section length. Expected %lld got = %lld\n", shouldLen, realLen); - goto cleanup; + return -1; } =20 if (lseek(fd, shouldLen, SEEK_CUR) < 0) { fprintf(stderr, "Unable to seek\n"); - goto cleanup; + return -1; } } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -319,9 +308,9 @@ testFileIsSharedFSType(const void *opaque G_GNUC_UNUSED) return EXIT_AM_SKIP; #else const struct testFileIsSharedFSType *data =3D opaque; + int ret =3D -1; g_autofree char *mtabFile =3D NULL; bool actual; - int ret =3D -1; =20 mtabFile =3D g_strdup_printf(abs_srcdir "/virfiledata/%s", data->mtabF= ile); =20 diff --git a/tests/virhostcputest.c b/tests/virhostcputest.c index c80cd1581c..746e65727f 100644 --- a/tests/virhostcputest.c +++ b/tests/virhostcputest.c @@ -30,7 +30,6 @@ linuxTestCompareFiles(const char *cpuinfofile, virArch arch, const char *outputfile) { - int ret =3D -1; g_autofree char *actualData =3D NULL; virNodeInfo nodeinfo; g_autoptr(FILE) cpuinfo =3D NULL; @@ -39,7 +38,7 @@ linuxTestCompareFiles(const char *cpuinfofile, if (!cpuinfo) { fprintf(stderr, "unable to open: %s : %s\n", cpuinfofile, g_strerror(errno)); - goto fail; + return -1; } =20 memset(&nodeinfo, 0, sizeof(nodeinfo)); @@ -51,7 +50,7 @@ linuxTestCompareFiles(const char *cpuinfofile, if (virGetLastErrorCode()) VIR_TEST_DEBUG("\n%s", virGetLastErrorMessage()); } - goto fail; + return -1; } =20 actualData =3D g_strdup_printf("CPUs: %u/%u, MHz: %u, Nodes: %u, Socke= ts: %u, " @@ -61,12 +60,9 @@ linuxTestCompareFiles(const char *cpuinfofile, nodeinfo.cores, nodeinfo.threads); =20 if (virTestCompareToFile(actualData, outputfile) < 0) - goto fail; + return -1; =20 - ret =3D 0; - - fail: - return ret; + return 0; } =20 =20 diff --git a/tests/viriscsitest.c b/tests/viriscsitest.c index 7ea761fda6..f2539e47b0 100644 --- a/tests/viriscsitest.c +++ b/tests/viriscsitest.c @@ -211,7 +211,6 @@ testISCSIGetSession(const void *data) const struct testSessionInfo *info =3D data; struct testIscsiadmCbData cbData =3D { 0 }; g_autofree char *actual_session =3D NULL; - int ret =3D -1; g_autoptr(virCommandDryRunToken) dryRunToken =3D virCommandDryRunToken= New(); =20 cbData.output_version =3D info->output_version; @@ -225,13 +224,10 @@ testISCSIGetSession(const void *data) "Expected session: '%s' got: '%s'", NULLSTR(info->expected_session), NULLSTR(actual_session)); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 struct testScanTargetsInfo { @@ -295,17 +291,14 @@ testISCSIConnectionLogin(const void *data) { const struct testConnectionInfoLogin *info =3D data; struct testIscsiadmCbData cbData =3D { 0 }; - int ret =3D -1; g_autoptr(virCommandDryRunToken) dryRunToken =3D virCommandDryRunToken= New(); =20 virCommandSetDryRun(dryRunToken, NULL, false, false, testIscsiadmCb, &= cbData); =20 if (virISCSIConnectionLogin(info->portal, info->initiatoriqn, info->ta= rget) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 diff --git a/tests/virkmodtest.c b/tests/virkmodtest.c index 2f07757c88..d2df3bdb04 100644 --- a/tests/virkmodtest.c +++ b/tests/virkmodtest.c @@ -34,30 +34,25 @@ static int checkOutput(virBuffer *buf, const char *exp_cmd) { - int ret =3D -1; g_autofree char *actual_cmd =3D NULL; =20 if (!(actual_cmd =3D virBufferContentAndReset(buf))) { fprintf(stderr, "cannot compare buffer to exp: %s", exp_cmd); - goto cleanup; + return -1; } =20 if (STRNEQ(exp_cmd, actual_cmd)) { virTestDifference(stderr, exp_cmd, actual_cmd); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 static int testKModLoad(const void *args G_GNUC_UNUSED) { - int ret =3D -1; g_autofree char *errbuf =3D NULL; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; g_autoptr(virCommandDryRunToken) dryRunToken =3D virCommandDryRunToken= New(); @@ -67,23 +62,19 @@ testKModLoad(const void *args G_GNUC_UNUSED) errbuf =3D virKModLoad(MODNAME); if (errbuf) { fprintf(stderr, "Failed to load, error: %s\n", errbuf); - goto cleanup; + return -1; } =20 if (checkOutput(&buf, MODPROBE " -b " MODNAME "\n") < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 static int testKModUnload(const void *args G_GNUC_UNUSED) { - int ret =3D -1; g_autofree char *errbuf =3D NULL; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; g_autoptr(virCommandDryRunToken) dryRunToken =3D virCommandDryRunToken= New(); @@ -93,16 +84,13 @@ testKModUnload(const void *args G_GNUC_UNUSED) errbuf =3D virKModUnload(MODNAME); if (errbuf) { fprintf(stderr, "Failed to unload, error: %s\n", errbuf); - goto cleanup; + return -1; } =20 if (checkOutput(&buf, RMMOD " " MODNAME "\n") < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 diff --git a/tests/virmacmaptest.c b/tests/virmacmaptest.c index 01a3588ed9..9a28c1bed0 100644 --- a/tests/virmacmaptest.c +++ b/tests/virmacmaptest.c @@ -40,12 +40,11 @@ testMACLookup(const void *opaque) GSList *next; size_t i, j; g_autofree char *file =3D NULL; - int ret =3D -1; =20 file =3D g_strdup_printf("%s/virmacmaptestdata/%s.json", abs_srcdir, d= ata->file); =20 if (!(mgr =3D virMacMapNew(file))) - goto cleanup; + return -1; =20 macs =3D virMacMapLookup(mgr, data->domain); =20 @@ -59,7 +58,7 @@ testMACLookup(const void *opaque) fprintf(stderr, "Unexpected %s in the returned list of MACs\n", (const char *) next->data); - goto cleanup; + return -1; } } =20 @@ -72,13 +71,11 @@ testMACLookup(const void *opaque) if (!next) { fprintf(stderr, "Expected %s in the returned list of MACs\n", data->ma= cs[i]); - goto cleanup; + return -1; } } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -90,18 +87,17 @@ testMACRemove(const void *opaque) GSList *macs; size_t i; g_autofree char *file =3D NULL; - int ret =3D -1; =20 file =3D g_strdup_printf("%s/virmacmaptestdata/%s.json", abs_srcdir, d= ata->file); =20 if (!(mgr =3D virMacMapNew(file))) - goto cleanup; + return -1; =20 for (i =3D 0; data->macs && data->macs[i]; i++) { if (virMacMapRemove(mgr, data->domain, data->macs[i]) < 0) { fprintf(stderr, "Error when removing %s from the list of MACs\n", data= ->macs[i]); - goto cleanup; + return -1; } } =20 @@ -109,12 +105,10 @@ testMACRemove(const void *opaque) fprintf(stderr, "Not removed all MACs for domain %s: %s\n", data->domain, (const char *) macs->data); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -124,19 +118,16 @@ testMACFlush(const void *opaque) const struct testData *data =3D opaque; g_autofree char *file =3D NULL; g_autofree char *str =3D NULL; - int ret =3D -1; =20 file =3D g_strdup_printf("%s/virmacmaptestdata/%s.json", abs_srcdir, d= ata->file); =20 if (virMacMapDumpStr(data->mgr, &str) < 0) - goto cleanup; + return -1; =20 if (virTestCompareToFile(str, file) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 diff --git a/tests/virnetworkportxml2xmltest.c b/tests/virnetworkportxml2xm= ltest.c index 8d29db724f..093d855633 100644 --- a/tests/virnetworkportxml2xmltest.c +++ b/tests/virnetworkportxml2xmltest.c @@ -37,21 +37,18 @@ static int testCompareXMLToXMLFiles(const char *expected) { g_autofree char *actual =3D NULL; - int ret =3D -1; g_autoptr(virNetworkPortDef) dev =3D NULL; =20 if (!(dev =3D virNetworkPortDefParseFile(expected))) - goto cleanup; + return -1; =20 if (!(actual =3D virNetworkPortDefFormat(dev))) - goto cleanup; + return -1; =20 if (virTestCompareToFile(actual, expected) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 struct testInfo { @@ -62,14 +59,12 @@ static int testCompareXMLToXMLHelper(const void *data) { const struct testInfo *info =3D data; - int ret =3D -1; g_autofree char *xml =3D NULL; =20 xml =3D g_strdup_printf("%s/virnetworkportxml2xmldata/%s.xml", abs_src= dir, info->name); =20 - ret =3D testCompareXMLToXMLFiles(xml); - return ret; + return testCompareXMLToXMLFiles(xml); } =20 static int diff --git a/tests/virnumamock.c b/tests/virnumamock.c index 6e0293a49e..19c26d1e37 100644 --- a/tests/virnumamock.c +++ b/tests/virnumamock.c @@ -162,7 +162,6 @@ virNumaGetPages(int node, int virNumaGetNodeCPUs(int node, virBitmap **cpus) { - int ret =3D -1; g_autofree char *cpulist =3D NULL; =20 if (virFileReadValueString(&cpulist, @@ -177,9 +176,7 @@ virNumaGetNodeCPUs(int node, virBitmap **cpus) *cpus =3D virBitmapParseUnlimited(cpulist); } if (!*cpus) - goto cleanup; + return -1; =20 - ret =3D virBitmapCountBits(*cpus); - cleanup: - return ret; + return virBitmapCountBits(*cpus); } diff --git a/tests/virpcitest.c b/tests/virpcitest.c index 1ff0330b22..08e137756f 100644 --- a/tests/virpcitest.c +++ b/tests/virpcitest.c @@ -34,22 +34,19 @@ testVirPCIDeviceCheckDriver(virPCIDevice *dev, const ch= ar *expected) { g_autofree char *path =3D NULL; g_autofree char *driver =3D NULL; - int ret =3D -1; =20 if (virPCIDeviceGetDriverPathAndName(dev, &path, &driver) < 0) - goto cleanup; + return -1; =20 if (STRNEQ_NULLABLE(driver, expected)) { virReportError(VIR_ERR_INTERNAL_ERROR, "PCI device %s driver mismatch: %s, expecting %s", virPCIDeviceGetName(dev), NULLSTR(driver), NULLSTR(expected)); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 static int @@ -166,7 +163,6 @@ testVirPCIDeviceReset(const void *opaque G_GNUC_UNUSED) static int testVirPCIDeviceReattach(const void *opaque G_GNUC_UNUSED) { - int ret =3D -1; virPCIDevice *dev[] =3D {NULL, NULL, NULL}; size_t i, nDev =3D G_N_ELEMENTS(dev); g_autoptr(virPCIDeviceList) activeDevs =3D NULL; @@ -175,17 +171,17 @@ testVirPCIDeviceReattach(const void *opaque G_GNUC_UN= USED) =20 if (!(activeDevs =3D virPCIDeviceListNew()) || !(inactiveDevs =3D virPCIDeviceListNew())) - goto cleanup; + return -1; =20 for (i =3D 0; i < nDev; i++) { virPCIDeviceAddress devAddr =3D {.domain =3D 0, .bus =3D 0, .slot =3D i + 1, .function =3D 0}; if (!(dev[i] =3D virPCIDeviceNew(&devAddr))) - goto cleanup; + return -1; =20 if (virPCIDeviceListAdd(inactiveDevs, dev[i]) < 0) { virPCIDeviceFree(dev[i]); - goto cleanup; + return -1; } =20 CHECK_LIST_COUNT(activeDevs, 0); @@ -199,15 +195,15 @@ testVirPCIDeviceReattach(const void *opaque G_GNUC_UN= USED) =20 for (i =3D 0; i < nDev; i++) { if (virPCIDeviceReattach(dev[i], activeDevs, inactiveDevs) < 0) - goto cleanup; + return -1; =20 CHECK_LIST_COUNT(activeDevs, 0); CHECK_LIST_COUNT(inactiveDevs, nDev - i - 1); } =20 - ret =3D 0; + return 0; cleanup: - return ret; + return -1; } =20 struct testPCIDevData { diff --git a/tests/virresctrltest.c b/tests/virresctrltest.c index 0beb9a4df4..c5733a7972 100644 --- a/tests/virresctrltest.c +++ b/tests/virresctrltest.c @@ -20,7 +20,6 @@ test_virResctrlGetUnused(const void *opaque) struct virResctrlData *data =3D (struct virResctrlData *) opaque; g_autofree char *system_dir =3D NULL; g_autofree char *resctrl_dir =3D NULL; - int ret =3D -1; g_autoptr(virResctrlAlloc) alloc =3D NULL; g_autofree char *schemata_str =3D NULL; g_autofree char *schemata_file =3D NULL; @@ -41,7 +40,7 @@ test_virResctrlGetUnused(const void *opaque) caps =3D virCapabilitiesNew(VIR_ARCH_X86_64, false, false); if (!caps || virCapabilitiesInitCaches(caps) < 0) { fprintf(stderr, "Could not initialize capabilities"); - goto cleanup; + return -1; } =20 alloc =3D virResctrlAllocGetUnused(caps->host.resctrl); @@ -50,22 +49,19 @@ test_virResctrlGetUnused(const void *opaque) =20 if (!alloc) { if (data->fail) - ret =3D 0; - goto cleanup; + return 0; + return -1; } else if (data->fail) { VIR_TEST_DEBUG("Error expected but there wasn't any."); - ret =3D -1; - goto cleanup; + return -1; } =20 schemata_str =3D virResctrlAllocFormat(alloc); =20 if (virTestCompareToFile(schemata_str, schemata_file) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 diff --git a/tests/virscsitest.c b/tests/virscsitest.c index d67cd23896..c96699e157 100644 --- a/tests/virscsitest.c +++ b/tests/virscsitest.c @@ -37,18 +37,15 @@ static int test1(const void *data G_GNUC_UNUSED) { g_autofree char *name =3D NULL; - int ret =3D -1; =20 if (!(name =3D virSCSIDeviceGetDevName(virscsi_prefix, "scsi_host1", 0, 0, 0))) return -1; =20 if (STRNEQ(name, "sdh")) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 /* @@ -161,7 +158,6 @@ test2(const void *data G_GNUC_UNUSED) static int create_symlink(const char *tmpdir, const char *src_name, const char *dst_n= ame) { - int ret =3D -1; g_autofree char *src_path =3D NULL; g_autofree char *dst_path =3D NULL; =20 @@ -171,13 +167,10 @@ create_symlink(const char *tmpdir, const char *src_na= me, const char *dst_name) =20 if (symlink(src_path, dst_path) < 0) { VIR_WARN("Failed to create symlink '%s' to '%s'", src_path, dst_pa= th); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 static int diff --git a/tests/virstringtest.c b/tests/virstringtest.c index bbdd17da84..277deca934 100644 --- a/tests/virstringtest.c +++ b/tests/virstringtest.c @@ -223,7 +223,6 @@ testStringReplace(const void *opaque G_GNUC_UNUSED) { const struct stringReplaceData *data =3D opaque; g_autofree char *result =3D NULL; - int ret =3D -1; =20 result =3D virStringReplace(data->haystack, data->oldneedle, @@ -232,13 +231,10 @@ testStringReplace(const void *opaque G_GNUC_UNUSED) if (STRNEQ_NULLABLE(data->result, result)) { fprintf(stderr, "Expected '%s' but got '%s'\n", data->result, NULLSTR(result)); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -400,7 +396,6 @@ struct testStripData { static int testStripIPv6Brackets(const void *args) { const struct testStripData *data =3D args; - int ret =3D -1; g_autofree char *res =3D NULL; =20 res =3D g_strdup(data->string); @@ -410,19 +405,15 @@ static int testStripIPv6Brackets(const void *args) if (STRNEQ_NULLABLE(res, data->result)) { fprintf(stderr, "Returned '%s', expected '%s'\n", NULLSTR(res), NULLSTR(data->result)); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 static int testStripControlChars(const void *args) { const struct testStripData *data =3D args; - int ret =3D -1; g_autofree char *res =3D NULL; =20 res =3D g_strdup(data->string); @@ -432,13 +423,10 @@ static int testStripControlChars(const void *args) if (STRNEQ_NULLABLE(res, data->result)) { fprintf(stderr, "Returned '%s', expected '%s'\n", NULLSTR(res), NULLSTR(data->result)); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 struct testFilterData { @@ -450,7 +438,6 @@ struct testFilterData { static int testFilterChars(const void *args) { const struct testFilterData *data =3D args; - int ret =3D -1; g_autofree char *res =3D NULL; =20 res =3D g_strdup(data->string); @@ -460,13 +447,10 @@ static int testFilterChars(const void *args) if (STRNEQ_NULLABLE(res, data->result)) { fprintf(stderr, "Returned '%s', expected '%s'\n", NULLSTR(res), NULLSTR(data->result)); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 static int diff --git a/tests/virsystemdtest.c b/tests/virsystemdtest.c index 9cf6bfec43..9a063dd1fc 100644 --- a/tests/virsystemdtest.c +++ b/tests/virsystemdtest.c @@ -369,45 +369,37 @@ static int testScopeName(const void *opaque) { const struct testNameData *data =3D opaque; - int ret =3D -1; g_autofree char *actual =3D NULL; =20 if (!(actual =3D virSystemdMakeScopeName(data->name, "lxc", data->lega= cy))) - goto cleanup; + return -1; =20 if (STRNEQ(actual, data->expected)) { fprintf(stderr, "Expected '%s' but got '%s'\n", data->expected, actual); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 static int testMachineName(const void *opaque) { const struct testNameData *data =3D opaque; - int ret =3D -1; g_autofree char *actual =3D NULL; =20 if (!(actual =3D virDomainDriverGenerateMachineName("qemu", data->root, data->id, data->name= , true))) - goto cleanup; + return -1; =20 if (STRNEQ(actual, data->expected)) { fprintf(stderr, "Expected '%s' but got '%s'\n", data->expected, actual); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 typedef int (*virSystemdCanHelper)(bool * result); --=20 2.31.1 From nobody Fri May 3 12:48:53 2024 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=1630788711; cv=none; d=zohomail.com; s=zohoarc; b=j+Mquy/FfOjnCeS4ul3h8QYSu2cVSBbDBKobhVAoPTxl+uEByrhbynN3wZpy+xbw2cC19V1WqYgMEbys1foZ5hpfU9tCu5g8/wzq9I9K2zoD3MS28273sBUYmD6je9NvCL9z91wxsCfaTwtasmeL2S6reiA2StV3FHgOf97L7qo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630788711; 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=l27R2vyJCC782MpuPypU2QlfNuQiNXS8eaOzBg+hZO8=; b=Z/Il80MBiYlnM3q6ZRAXH/ZaaLBi11v01MiGN15nmP6i3xo/002Z58J54Xe6kKr7k7CIpS0V75MXq4xdvj47o0OZQny8ZiRPhY5krPwwvWO+JT+HK9LRLB1x8hVuKII48SulfMsui3YXrhGwYmObMFReUaNCZPKXcHF66BZgVfA= 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 1630788711014339.0622909011985; Sat, 4 Sep 2021 13:51:51 -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-203-C4CBRr3hNUqOXyNWp1h83Q-1; Sat, 04 Sep 2021 16:51:48 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 85E09107ACE4; Sat, 4 Sep 2021 20:51:43 +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 4AE7760C9D; Sat, 4 Sep 2021 20:51:43 +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 1E1CF44A5F; Sat, 4 Sep 2021 20:51:43 +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 184KiqPj008946 for ; Sat, 4 Sep 2021 16:44:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3E5CC2619D; Sat, 4 Sep 2021 20:44:52 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id B9D3A1F4 for ; Sat, 4 Sep 2021 20:44:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630788710; 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=l27R2vyJCC782MpuPypU2QlfNuQiNXS8eaOzBg+hZO8=; b=IPzLO4njmx1G3ZRez4A7u6W5W/hs3N8pR0moJk1Nm0Y19ZIy+4H1I51rfQgFOGmFsqeSaS JJ7AK+MU6aoxKvlRJLh8I2xkiGhvsLDeXlzYiW/iAbx3aLGgXgBT320VHoKKJ2moIOUHrH pn3AaxSz3qSl/wncgYwmFjVkqliPFGE= X-MC-Unique: C4CBRr3hNUqOXyNWp1h83Q-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 24/24] tests: remove pointless labels Date: Sat, 4 Sep 2021 22:44:22 +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.12 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: 1630788711618100001 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Laine Stump --- tests/cputest.c | 42 ++++++++++++-------------------- tests/domaincapstest.c | 39 ++++++++++++----------------- tests/domainconftest.c | 12 +++------ tests/fchosttest.c | 40 +++++++++++------------------- tests/lxcconf2xmltest.c | 16 +++++------- tests/metadatatest.c | 28 +++++++-------------- tests/openvzutilstest.c | 11 +++------ tests/scsihosttest.c | 22 +++++++---------- tests/securityselinuxlabeltest.c | 12 +++------ tests/vmwarevertest.c | 14 ++++------- 10 files changed, 84 insertions(+), 152 deletions(-) diff --git a/tests/cputest.c b/tests/cputest.c index 11305d56c5..0f0621292a 100644 --- a/tests/cputest.c +++ b/tests/cputest.c @@ -520,7 +520,6 @@ static int cpuTestCPUID(bool guest, const void *arg) { const struct data *data =3D arg; - int ret =3D -1; g_autoptr(virCPUData) hostData =3D NULL; g_autofree char *hostFile =3D NULL; g_autofree char *host =3D NULL; @@ -533,7 +532,7 @@ cpuTestCPUID(bool guest, const void *arg) =20 if (virTestLoadFile(hostFile, &host) < 0 || !(hostData =3D virCPUDataParse(host))) - goto cleanup; + return -1; =20 cpu =3D virCPUDefNew(); cpu->arch =3D hostData->arch; @@ -549,21 +548,16 @@ cpuTestCPUID(bool guest, const void *arg) int rc; =20 rc =3D cpuTestGetCPUModels(data, &models); - if (rc !=3D 0) { - ret =3D rc; - goto cleanup; - } + if (rc !=3D 0) + return rc; } =20 if (cpuDecode(cpu, hostData, models) < 0) - goto cleanup; + return -1; =20 result =3D g_strdup_printf("cpuid-%s-%s", data->host, guest ? "guest" = : "host"); =20 - ret =3D cpuTestCompareXML(data->arch, cpu, result); - - cleanup: - return ret; + return cpuTestCompareXML(data->arch, cpu, result); } =20 =20 @@ -729,27 +723,26 @@ cpuTestUpdateLive(const void *arg) g_autoptr(virCPUDef) expected =3D NULL; g_autoptr(virDomainCapsCPUModels) hvModels =3D NULL; g_autoptr(virDomainCapsCPUModels) models =3D NULL; - int ret =3D -1; =20 cpuFile =3D g_strdup_printf("cpuid-%s-guest", data->host); if (!(cpu =3D cpuTestLoadXML(data->arch, cpuFile))) - goto cleanup; + return -1; =20 enabledFile =3D g_strdup_printf("%s/cputestdata/%s-cpuid-%s-enabled.xm= l", abs_srcdir, virArchToString(data->arch),= data->host); if (virTestLoadFile(enabledFile, &enabled) < 0 || !(enabledData =3D virCPUDataParse(enabled))) - goto cleanup; + return -1; =20 disabledFile =3D g_strdup_printf("%s/cputestdata/%s-cpuid-%s-disabled.= xml", abs_srcdir, virArchToString(data->arch)= , data->host); if (virTestLoadFile(disabledFile, &disabled) < 0 || !(disabledData =3D virCPUDataParse(disabled))) - goto cleanup; + return -1; =20 expectedFile =3D g_strdup_printf("cpuid-%s-json", data->host); if (!(expected =3D cpuTestLoadXML(data->arch, expectedFile))) - goto cleanup; + return -1; =20 /* In case the host CPU signature does not exactly match any CPU model= in * src/cpu_map, the CPU model we detect from CPUID may differ from the= one @@ -764,13 +757,11 @@ cpuTestUpdateLive(const void *arg) int rc; =20 if (!(models =3D virDomainCapsCPUModelsNew(0))) - goto cleanup; + return -1; =20 rc =3D cpuTestGetCPUModels(data, &hvModels); - if (rc !=3D 0) { - ret =3D rc; - goto cleanup; - } + if (rc !=3D 0) + return rc; =20 hvModel =3D virDomainCapsCPUModelsGet(hvModels, expected->model); =20 @@ -781,7 +772,7 @@ cpuTestUpdateLive(const void *arg) =20 if (virDomainCapsCPUModelsAdd(models, expected->model, usable, blockers, false) < 0) - goto cleanup; + return -1; =20 cpu->fallback =3D VIR_CPU_FALLBACK_ALLOW; ignore_value(virCPUTranslate(data->arch, cpu, models)); @@ -789,12 +780,9 @@ cpuTestUpdateLive(const void *arg) } =20 if (virCPUUpdateLive(data->arch, cpu, enabledData, disabledData) < 0) - goto cleanup; + return -1; =20 - ret =3D cpuTestUpdateLiveCompare(data->arch, cpu, expected); - - cleanup: - return ret; + return cpuTestUpdateLiveCompare(data->arch, cpu, expected); } =20 =20 diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c index 463ff83890..9ea5bed5c2 100644 --- a/tests/domaincapstest.c +++ b/tests/domaincapstest.c @@ -73,18 +73,17 @@ fillQemuCaps(virDomainCaps *domCaps, const char *machine, virQEMUDriverConfig *cfg) { - int ret =3D -1; g_autofree char *path =3D NULL; g_autoptr(virQEMUCaps) qemuCaps =3D NULL; virDomainCapsLoader *loader =3D &domCaps->os.loader; virDomainVirtType virtType; =20 if (fakeHostCPU(domCaps->arch) < 0) - goto cleanup; + return -1; =20 path =3D g_strdup_printf("%s/%s.%s.xml", TEST_QEMU_CAPS_PATH, name, ar= ch); if (!(qemuCaps =3D qemuTestParseCapabilitiesArch(domCaps->arch, path))) - goto cleanup; + return -1; =20 if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) virtType =3D VIR_DOMAIN_VIRT_KVM; @@ -103,7 +102,7 @@ fillQemuCaps(virDomainCaps *domCaps, false, cfg->firmwares, cfg->nfirmwares) < 0) - goto cleanup; + return -1; =20 /* The function above tries to query host's VFIO capabilities by calli= ng * qemuHostdevHostSupportsPassthroughVFIO() which, however, can't be @@ -123,11 +122,9 @@ fillQemuCaps(virDomainCaps *domCaps, "/usr/share/AAVMF/AAVMF32_CODE.fd", "/usr/share/OVMF/OVMF_CODE.fd", NULL) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } #endif /* WITH_QEMU */ =20 @@ -167,19 +164,16 @@ static int fillBhyveCaps(virDomainCaps *domCaps, unsigned int *bhyve_caps) { g_autofree virDomainCapsStringValues *firmwares =3D NULL; - int ret =3D -1; =20 firmwares =3D g_new0(virDomainCapsStringValues, 1); =20 if (fillStringValues(firmwares, "/foo/bar", "/foo/baz", NULL) < 0) - goto cleanup; + return -1; =20 if (virBhyveDomainCapsFill(domCaps, *bhyve_caps, firmwares) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } #endif /* WITH_BHYVE */ =20 @@ -208,14 +202,13 @@ test_virDomainCapsFormat(const void *opaque) g_autoptr(virDomainCaps) domCaps =3D NULL; g_autofree char *path =3D NULL; g_autofree char *domCapsXML =3D NULL; - int ret =3D -1; =20 path =3D g_strdup_printf("%s/domaincapsdata/%s.xml", abs_srcdir, data-= >name); =20 if (!(domCaps =3D virDomainCapsNew(data->emulator, data->machine, virArchFromString(data->arch), data->type))) - goto cleanup; + return -1; =20 switch (data->capsType) { case CAPS_NONE: @@ -225,33 +218,31 @@ test_virDomainCapsFormat(const void *opaque) #if WITH_QEMU if (fillQemuCaps(domCaps, data->capsName, data->arch, data->machin= e, data->capsOpaque) < 0) - goto cleanup; + return -1; #endif break; =20 case CAPS_LIBXL: #if WITH_LIBXL if (fillXenCaps(domCaps) < 0) - goto cleanup; + return -1; #endif break; case CAPS_BHYVE: #if WITH_BHYVE if (fillBhyveCaps(domCaps, data->capsOpaque) < 0) - goto cleanup; + return -1; #endif break; } =20 if (!(domCapsXML =3D virDomainCapsFormat(domCaps))) - goto cleanup; + return -1; =20 if (virTestCompareToFile(domCapsXML, path) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 diff --git a/tests/domainconftest.c b/tests/domainconftest.c index aaf58bcf93..71fd1f7b73 100644 --- a/tests/domainconftest.c +++ b/tests/domainconftest.c @@ -40,7 +40,6 @@ struct testGetFilesystemData { =20 static int testGetFilesystem(const void *opaque) { - int ret =3D -1; g_autoptr(virDomainDef) def =3D NULL; g_autofree char *filename =3D NULL; const struct testGetFilesystemData *data =3D opaque; @@ -50,7 +49,7 @@ static int testGetFilesystem(const void *opaque) data->filename); =20 if (!(def =3D virDomainDefParseFile(filename, xmlopt, NULL, 0))) - goto cleanup; + return -1; =20 fsdef =3D virDomainGetFilesystemForTarget(def, data->path); @@ -58,20 +57,17 @@ static int testGetFilesystem(const void *opaque) if (data->expectEntry) { fprintf(stderr, "Expected FS for path '%s' in '%s'\n", data->path, filename); - goto cleanup; + return -1; } } else { if (!data->expectEntry) { fprintf(stderr, "Unexpected FS for path '%s' in '%s'\n", data->path, filename); - goto cleanup; + return -1; } } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 static int diff --git a/tests/fchosttest.c b/tests/fchosttest.c index 707dd7e410..dc1503e9a7 100644 --- a/tests/fchosttest.c +++ b/tests/fchosttest.c @@ -123,7 +123,6 @@ test3(const void *data G_GNUC_UNUSED) g_autofree char *fabric_wwn =3D NULL; g_autofree char *max_vports =3D NULL; g_autofree char *vports =3D NULL; - int ret =3D -1; =20 if (!(wwnn =3D virVHBAGetConfig(TEST_FC_HOST_PREFIX, TEST_FC_HOST_NUM, "node_name"))) @@ -131,31 +130,29 @@ test3(const void *data G_GNUC_UNUSED) =20 if (!(wwpn =3D virVHBAGetConfig(TEST_FC_HOST_PREFIX, TEST_FC_HOST_NUM, "port_name"))) - goto cleanup; + return -1; =20 if (!(fabric_wwn =3D virVHBAGetConfig(TEST_FC_HOST_PREFIX, TEST_FC_HOS= T_NUM, "fabric_name"))) - goto cleanup; + return -1; =20 if (!(max_vports =3D virVHBAGetConfig(TEST_FC_HOST_PREFIX, TEST_FC_HOS= T_NUM, "max_npiv_vports"))) - goto cleanup; + return -1; =20 =20 if (!(vports =3D virVHBAGetConfig(TEST_FC_HOST_PREFIX, TEST_FC_HOST_NU= M, "npiv_vports_inuse"))) - goto cleanup; + return -1; =20 if (STRNEQ(expect_wwnn, wwnn) || STRNEQ(expect_wwpn, wwpn) || STRNEQ(expect_fabric_wwn, fabric_wwn) || STRNEQ(expect_max_vports, max_vports) || STRNEQ(expect_vports, vports)) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 /* Test virVHBAGetHostByWWN */ @@ -164,7 +161,6 @@ test4(const void *data G_GNUC_UNUSED) { const char *expect_hostname =3D "host5"; g_autofree char *hostname =3D NULL; - int ret =3D -1; =20 if (!(hostname =3D virVHBAGetHostByWWN(TEST_FC_HOST_PREFIX, "2001001b32a9da4e", @@ -172,11 +168,9 @@ test4(const void *data G_GNUC_UNUSED) return -1; =20 if (STRNEQ(hostname, expect_hostname)) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 /* Test virVHBAFindVportHost @@ -188,17 +182,14 @@ test5(const void *data G_GNUC_UNUSED) { const char *expect_hostname =3D "host5"; g_autofree char *hostname =3D NULL; - int ret =3D -1; =20 if (!(hostname =3D virVHBAFindVportHost(TEST_FC_HOST_PREFIX))) return -1; =20 if (STRNEQ(hostname, expect_hostname)) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 /* Test virVHBAGetConfig fabric name optional */ @@ -210,7 +201,6 @@ test6(const void *data G_GNUC_UNUSED) g_autofree char *wwnn =3D NULL; g_autofree char *wwpn =3D NULL; g_autofree char *fabric_wwn =3D NULL; - int ret =3D -1; =20 if (!(wwnn =3D virVHBAGetConfig(TEST_FC_HOST_PREFIX, TEST_FC_HOST_NUM_= NO_FAB, "node_name"))) @@ -218,20 +208,18 @@ test6(const void *data G_GNUC_UNUSED) =20 if (!(wwpn =3D virVHBAGetConfig(TEST_FC_HOST_PREFIX, TEST_FC_HOST_NUM_= NO_FAB, "port_name"))) - goto cleanup; + return -1; =20 if ((fabric_wwn =3D virVHBAGetConfig(TEST_FC_HOST_PREFIX, TEST_FC_HOST_NUM_NO_FAB, "fabric_name"))) - goto cleanup; + return -1; =20 if (STRNEQ(expect_wwnn, wwnn) || STRNEQ(expect_wwpn, wwpn)) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 diff --git a/tests/lxcconf2xmltest.c b/tests/lxcconf2xmltest.c index be70671d68..09f6465567 100644 --- a/tests/lxcconf2xmltest.c +++ b/tests/lxcconf2xmltest.c @@ -25,33 +25,29 @@ testCompareXMLToConfigFiles(const char *xmlfile, const char *configfile, bool expectError) { - int ret =3D -1; g_autofree char *config =3D NULL; g_autofree char *actualxml =3D NULL; g_autoptr(virDomainDef) vmdef =3D NULL; =20 if (virTestLoadFile(configfile, &config) < 0) - goto fail; + return -1; =20 vmdef =3D lxcParseConfigString(config, driver->caps, driver->xmlopt); if ((vmdef && expectError) || (!vmdef && !expectError)) - goto fail; + return -1; =20 if (vmdef) { if (testSanitizeDef(vmdef) < 0) - goto fail; + return -1; =20 if (!(actualxml =3D virDomainDefFormat(vmdef, driver->xmlopt, 0))) - goto fail; + return -1; =20 if (virTestCompareToFile(actualxml, xmlfile) < 0) - goto fail; + return -1; } =20 - ret =3D 0; - - fail: - return ret; + return 0; } =20 struct testInfo { diff --git a/tests/metadatatest.c b/tests/metadatatest.c index 5112912161..b56428fde5 100644 --- a/tests/metadatatest.c +++ b/tests/metadatatest.c @@ -91,7 +91,6 @@ verifyMetadata(virDomainPtr dom, const char *expectAPI, const char *uri) { - bool ret =3D false; g_autofree char *metadataXML =3D NULL; g_autofree char *metadataAPI =3D NULL; =20 @@ -102,13 +101,13 @@ verifyMetadata(virDomainPtr dom, virReportError(VIR_ERR_INTERNAL_ERROR, "expected no metadata in API, but got:\n[%s]", metadataAPI); - goto cleanup; + return false; } } else { if (!(metadataAPI =3D virDomainGetMetadata(dom, VIR_DOMAIN_METADATA_ELEME= NT, uri, 0))) - goto cleanup; + return false; =20 metadataXMLConvertApostrophe(metadataAPI); =20 @@ -117,7 +116,7 @@ verifyMetadata(virDomainPtr dom, "XML metadata in API doesn't match expected met= adata: " "expected:\n[%s]\ngot:\n[%s]", expectAPI, metadataAPI); - goto cleanup; + return false; } =20 } @@ -127,11 +126,11 @@ verifyMetadata(virDomainPtr dom, virReportError(VIR_ERR_INTERNAL_ERROR, "expected no metadata in XML, but got:\n[%s]", metadataXML); - goto cleanup; + return false; } } else { if (!(metadataXML =3D getMetadataFromXML(dom))) - goto cleanup; + return false; =20 metadataXMLConvertApostrophe(metadataXML); =20 @@ -140,15 +139,11 @@ verifyMetadata(virDomainPtr dom, "XML in dump doesn't match expected metadata: " "expected:\n[%s]\ngot:\n[%s]", expectXML, metadataXML); - goto cleanup; + return false; } } =20 - ret =3D true; - - cleanup: - - return ret; + return true; } =20 =20 @@ -213,7 +208,6 @@ testTextMetadata(const void *data) { const struct metadataTest *test =3D data; g_autofree char *actual =3D NULL; - int ret =3D -1; =20 if (virDomainSetMetadata(test->dom, test->type, test->data, NULL, NULL= , 0) < 0) { if (test->fail) @@ -228,14 +222,10 @@ testTextMetadata(const void *data) "expected metadata doesn't match actual: " "expected:'%s'\ngot: '%s'", NULLSTR(test->data), NULLSTR(actual)); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - - return ret; + return 0; } =20 #define TEST_TEXT_METADATA(INDEX, TYPE, DATA, EXPECT, FAIL) \ diff --git a/tests/openvzutilstest.c b/tests/openvzutilstest.c index 3ebf38f104..7e6c0b60bb 100644 --- a/tests/openvzutilstest.c +++ b/tests/openvzutilstest.c @@ -36,7 +36,6 @@ static struct testConfigParam configParams[] =3D { static int testReadConfigParam(const void *data G_GNUC_UNUSED) { - int result =3D -1; size_t i; g_autofree char *conf =3D NULL; g_autofree char *value =3D NULL; @@ -46,7 +45,7 @@ testReadConfigParam(const void *data G_GNUC_UNUSED) for (i =3D 0; i < G_N_ELEMENTS(configParams); ++i) { if (openvzReadConfigParam(conf, configParams[i].param, &value) !=3D configParams[i].ret) { - goto cleanup; + return -1; } =20 if (configParams[i].ret !=3D 1) @@ -54,15 +53,11 @@ testReadConfigParam(const void *data G_GNUC_UNUSED) =20 if (STRNEQ(configParams[i].value, value)) { virTestDifference(stderr, configParams[i].value, value); - goto cleanup; + return -1; } } =20 - result =3D 0; - - cleanup: - - return result; + return 0; } =20 static int diff --git a/tests/scsihosttest.c b/tests/scsihosttest.c index aeb91da691..cb66a479e3 100644 --- a/tests/scsihosttest.c +++ b/tests/scsihosttest.c @@ -70,7 +70,6 @@ create_scsihost(const char *fakesysfsdir, const char *dev= icepath, g_autofree char *unique_id_path =3D NULL; g_autofree char *link_path =3D NULL; char *spot; - int ret =3D -1; VIR_AUTOCLOSE fd =3D -1; =20 unique_id_path =3D g_strdup_printf("%s/devices/pci0000:00/%s/unique_id= ", @@ -83,13 +82,13 @@ create_scsihost(const char *fakesysfsdir, const char *d= evicepath, */ if (!(spot =3D strstr(unique_id_path, "unique_id"))) { fprintf(stderr, "Did not find unique_id in path\n"); - goto cleanup; + return -1; } spot--; *spot =3D '\0'; if (g_mkdir_with_parents(unique_id_path, 0755) < 0) { fprintf(stderr, "Unable to make path to '%s'\n", unique_id_path); - goto cleanup; + return -1; } *spot =3D '/'; =20 @@ -98,45 +97,42 @@ create_scsihost(const char *fakesysfsdir, const char *d= evicepath, */ if (!(spot =3D strstr(link_path, hostname))) { fprintf(stderr, "Did not find hostname in path\n"); - goto cleanup; + return -1; } spot--; *spot =3D '\0'; if (g_mkdir_with_parents(link_path, 0755) < 0) { fprintf(stderr, "Unable to make path to '%s'\n", link_path); - goto cleanup; + return -1; } *spot =3D '/'; =20 if ((fd =3D open(unique_id_path, O_CREAT|O_WRONLY, 0444)) < 0) { fprintf(stderr, "Unable to create '%s'\n", unique_id_path); - goto cleanup; + return -1; } =20 if (safewrite(fd, unique_id, 1) !=3D 1) { fprintf(stderr, "Unable to write '%s'\n", unique_id); - goto cleanup; + return -1; } VIR_DEBUG("Created unique_id '%s'", unique_id_path); =20 /* The link is to the path not the file - so remove the file */ if (!(spot =3D strstr(unique_id_path, "unique_id"))) { fprintf(stderr, "Did not find unique_id in path\n"); - goto cleanup; + return -1; } spot--; *spot =3D '\0'; if (symlink(unique_id_path, link_path) < 0) { fprintf(stderr, "Unable to create symlink '%s' to '%s'\n", link_path, unique_id_path); - goto cleanup; + return -1; } VIR_DEBUG("Created symlink '%s'", link_path); =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 static int diff --git a/tests/securityselinuxlabeltest.c b/tests/securityselinuxlabelt= est.c index 2e5941d7ef..87b2fc738a 100644 --- a/tests/securityselinuxlabeltest.c +++ b/tests/securityselinuxlabeltest.c @@ -99,7 +99,6 @@ testSELinuxLoadFileList(const char *testname, testSELinuxFile **files, size_t *nfiles) { - int ret =3D -1; g_autofree char *path =3D NULL; g_autoptr(FILE) fp =3D NULL; g_autofree char *line =3D NULL; @@ -111,7 +110,7 @@ testSELinuxLoadFileList(const char *testname, testname); =20 if (!(fp =3D fopen(path, "r"))) - goto cleanup; + return -1; =20 line =3D g_new0(char, 1024); =20 @@ -119,7 +118,7 @@ testSELinuxLoadFileList(const char *testname, char *file =3D NULL, *context =3D NULL, *tmp; if (!fgets(line, 1024, fp)) { if (!feof(fp)) - goto cleanup; + return -1; break; } =20 @@ -128,7 +127,7 @@ testSELinuxLoadFileList(const char *testname, virReportError(VIR_ERR_INTERNAL_ERROR, "unexpected format for line '%s'", line); - goto cleanup; + return -1; } *tmp =3D '\0'; tmp++; @@ -148,10 +147,7 @@ testSELinuxLoadFileList(const char *testname, (*files)[(*nfiles)-1].context =3D context; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 diff --git a/tests/vmwarevertest.c b/tests/vmwarevertest.c index 7cb358795f..cdbd58fb4f 100644 --- a/tests/vmwarevertest.c +++ b/tests/vmwarevertest.c @@ -37,7 +37,6 @@ static int testVerStrParse(const void *data) { const struct testInfo *info =3D data; - int ret =3D -1; g_autofree char *path =3D NULL; g_autofree char *databuf =3D NULL; unsigned long version; @@ -46,24 +45,21 @@ testVerStrParse(const void *data) path =3D g_strdup_printf("%s/vmwareverdata/%s.txt", abs_srcdir, info->= name); =20 if (virTestLoadFile(path, &databuf) < 0) - goto cleanup; + return -1; =20 if ((vmware_type =3D vmwareDriverTypeFromString(info->vmware_type)) < = 0) - goto cleanup; + return -1; =20 if (vmwareParseVersionStr(vmware_type, databuf, &version) < 0) - goto cleanup; + return -1; =20 if (version !=3D info->version) { fprintf(stderr, "%s: parsed versions do not match: got %lu, " "expected %lu\n", info->name, version, info->version); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 static int --=20 2.31.1