From nobody Tue Feb 10 01:14:49 2026 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=1639338545; cv=none; d=zohomail.com; s=zohoarc; b=NO48GqppssVzT41koTtUS3HmhAPDDj/P9AB8lScDHI+JbZjywb1dvX2BwbALWi31FoYHYT41lBKGzcTWr7SSCSzw1f5/KEjOn6sSFqa1tKEM33Wz6y/zO+VHn1bOLJDWIP/9EkXTOik56tx8XTugzQC1TaAQabEemjid2HYIx/4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639338545; 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=/LvcJF1C+maNmNrd/X22BjRqSnyYA+dUbE0XxIMDq3g=; b=GriXZ23tdt7Tjayr6cYmnl7o0AsYUB8Shu2CnYaA8LHExJXu2DCMcuW9nYjbINeY7sKbhk84W+5XoZ7Wiaj5rJ7rlo+MlVVtBTqEHmq3yJaB6EpKswR1Bhk0IMtnIPETn3Y4VqxtDut2fXgoe3kpaWYBEDq9hRuXfe6/nt7LzsA= 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 1639338545029721.5108542538679; Sun, 12 Dec 2021 11:49:05 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-480-LhVMFwD1NT2yydSbvf5fvA-1; Sun, 12 Dec 2021 14:49:00 -0500 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 518352F26; Sun, 12 Dec 2021 19:48:56 +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 3587760FDD; Sun, 12 Dec 2021 19:48:56 +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 ECB954A7CB; Sun, 12 Dec 2021 19:48:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1BCJmZil018860 for ; Sun, 12 Dec 2021 14:48:35 -0500 Received: by smtp.corp.redhat.com (Postfix) id 919C55BE03; Sun, 12 Dec 2021 19:48:35 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.2.16.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5EC1F5D6D7 for ; Sun, 12 Dec 2021 19:48:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639338544; 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=/LvcJF1C+maNmNrd/X22BjRqSnyYA+dUbE0XxIMDq3g=; b=TGkU05kFQ2AbMt8VDNESyzQ1Y2LzvNygmwl+QBW5LhXCXRiz/nFE9TmKhyxnh+07JYmR6/ 2a9lgaXeudH5Dsn+FGwc78TQ32oTfqOZ5rbCSovgTQNlf6HFRj2oyjbZ+EHvUSyxg2a0IT z1Os3CFZ0X353DiIgPYlAVHeEljhHiU= X-MC-Unique: LhVMFwD1NT2yydSbvf5fvA-1 From: Laine Stump To: libvir-list@redhat.com Subject: [libvirt PATCH 05/12] tests: remove unnecessary ret variables and cleanup labels Date: Sun, 12 Dec 2021 14:48:23 -0500 Message-Id: <20211212194830.292379-6-laine@redhat.com> In-Reply-To: <20211212194830.292379-1-laine@redhat.com> References: <20211212194830.292379-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1639338546307100002 Content-Type: text/plain; charset="utf-8" Several functions were simplified to remove the only cleanup code at the cleanup label, making it unnecessary. Signed-off-by: Laine Stump --- tests/virfirewalltest.c | 92 ++++++++++++++--------------------------- 1 file changed, 31 insertions(+), 61 deletions(-) diff --git a/tests/virfirewalltest.c b/tests/virfirewalltest.c index e6c41d89fa..724d3081f1 100644 --- a/tests/virfirewalltest.c +++ b/tests/virfirewalltest.c @@ -64,7 +64,6 @@ testFirewallSingleGroup(const void *opaque G_GNUC_UNUSED) { g_auto(virBuffer) cmdbuf =3D VIR_BUFFER_INITIALIZER; g_autoptr(virFirewall) fw =3D virFirewallNew(); - int ret =3D -1; const char *actual =3D NULL; const char *expected =3D IPTABLES " -w -A INPUT --source 192.168.122.1 --jump ACCEPT\n" @@ -87,19 +86,17 @@ testFirewallSingleGroup(const void *opaque G_GNUC_UNUSE= D) "--jump", "REJECT", NULL); =20 if (virFirewallApply(fw) < 0) - goto cleanup; + return -1; =20 actual =3D virBufferCurrentContent(&cmdbuf); =20 if (STRNEQ_NULLABLE(expected, actual)) { fprintf(stderr, "Unexpected command execution\n"); virTestDifference(stderr, expected, actual); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -108,7 +105,6 @@ testFirewallRemoveRule(const void *opaque G_GNUC_UNUSED) { g_auto(virBuffer) cmdbuf =3D VIR_BUFFER_INITIALIZER; g_autoptr(virFirewall) fw =3D virFirewallNew(); - int ret =3D -1; const char *actual =3D NULL; const char *expected =3D IPTABLES " -w -A INPUT --source 192.168.122.1 --jump ACCEPT\n" @@ -137,19 +133,17 @@ testFirewallRemoveRule(const void *opaque G_GNUC_UNUS= ED) virFirewallRuleAddArgList(fw, fwrule, "--jump", "REJECT", NULL); =20 if (virFirewallApply(fw) < 0) - goto cleanup; + return -1; =20 actual =3D virBufferCurrentContent(&cmdbuf); =20 if (STRNEQ_NULLABLE(expected, actual)) { fprintf(stderr, "Unexpected command execution\n"); virTestDifference(stderr, expected, actual); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -158,7 +152,6 @@ testFirewallManyGroups(const void *opaque G_GNUC_UNUSED) { g_auto(virBuffer) cmdbuf =3D VIR_BUFFER_INITIALIZER; g_autoptr(virFirewall) fw =3D virFirewallNew(); - int ret =3D -1; const char *actual =3D NULL; const char *expected =3D IPTABLES " -w -A INPUT --source 192.168.122.1 --jump ACCEPT\n" @@ -194,19 +187,17 @@ testFirewallManyGroups(const void *opaque G_GNUC_UNUS= ED) =20 =20 if (virFirewallApply(fw) < 0) - goto cleanup; + return -1; =20 actual =3D virBufferCurrentContent(&cmdbuf); =20 if (STRNEQ_NULLABLE(expected, actual)) { fprintf(stderr, "Unexpected command execution\n"); virTestDifference(stderr, expected, actual); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 static void @@ -236,7 +227,6 @@ testFirewallIgnoreFailGroup(const void *opaque G_GNUC_U= NUSED) { g_auto(virBuffer) cmdbuf =3D VIR_BUFFER_INITIALIZER; g_autoptr(virFirewall) fw =3D virFirewallNew(); - int ret =3D -1; const char *actual =3D NULL; const char *expected =3D IPTABLES " -w -A INPUT --source 192.168.122.1 --jump ACCEPT\n" @@ -272,19 +262,17 @@ testFirewallIgnoreFailGroup(const void *opaque G_GNUC= _UNUSED) =20 =20 if (virFirewallApply(fw) < 0) - goto cleanup; + return -1; =20 actual =3D virBufferCurrentContent(&cmdbuf); =20 if (STRNEQ_NULLABLE(expected, actual)) { fprintf(stderr, "Unexpected command execution\n"); virTestDifference(stderr, expected, actual); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -293,7 +281,6 @@ testFirewallIgnoreFailRule(const void *opaque G_GNUC_UN= USED) { g_auto(virBuffer) cmdbuf =3D VIR_BUFFER_INITIALIZER; g_autoptr(virFirewall) fw =3D virFirewallNew(); - int ret =3D -1; const char *actual =3D NULL; const char *expected =3D IPTABLES " -w -A INPUT --source 192.168.122.1 --jump ACCEPT\n" @@ -328,19 +315,17 @@ testFirewallIgnoreFailRule(const void *opaque G_GNUC_= UNUSED) =20 =20 if (virFirewallApply(fw) < 0) - goto cleanup; + return -1; =20 actual =3D virBufferCurrentContent(&cmdbuf); =20 if (STRNEQ_NULLABLE(expected, actual)) { fprintf(stderr, "Unexpected command execution\n"); virTestDifference(stderr, expected, actual); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -349,7 +334,6 @@ testFirewallNoRollback(const void *opaque G_GNUC_UNUSED) { g_auto(virBuffer) cmdbuf =3D VIR_BUFFER_INITIALIZER; g_autoptr(virFirewall) fw =3D virFirewallNew(); - int ret =3D -1; const char *actual =3D NULL; const char *expected =3D IPTABLES " -w -A INPUT --source 192.168.122.1 --jump ACCEPT\n" @@ -377,7 +361,7 @@ testFirewallNoRollback(const void *opaque G_GNUC_UNUSED) =20 if (virFirewallApply(fw) =3D=3D 0) { fprintf(stderr, "Firewall apply unexpectedly worked\n"); - goto cleanup; + return -1; } =20 actual =3D virBufferCurrentContent(&cmdbuf); @@ -385,12 +369,10 @@ testFirewallNoRollback(const void *opaque G_GNUC_UNUS= ED) if (STRNEQ_NULLABLE(expected, actual)) { fprintf(stderr, "Unexpected command execution\n"); virTestDifference(stderr, expected, actual); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 static int @@ -398,7 +380,6 @@ testFirewallSingleRollback(const void *opaque G_GNUC_UN= USED) { g_auto(virBuffer) cmdbuf =3D VIR_BUFFER_INITIALIZER; g_autoptr(virFirewall) fw =3D virFirewallNew(); - int ret =3D -1; const char *actual =3D NULL; const char *expected =3D IPTABLES " -w -A INPUT --source 192.168.122.1 --jump ACCEPT\n" @@ -446,7 +427,7 @@ testFirewallSingleRollback(const void *opaque G_GNUC_UN= USED) =20 if (virFirewallApply(fw) =3D=3D 0) { fprintf(stderr, "Firewall apply unexpectedly worked\n"); - goto cleanup; + return -1; } =20 actual =3D virBufferCurrentContent(&cmdbuf); @@ -454,12 +435,10 @@ testFirewallSingleRollback(const void *opaque G_GNUC_= UNUSED) if (STRNEQ_NULLABLE(expected, actual)) { fprintf(stderr, "Unexpected command execution\n"); virTestDifference(stderr, expected, actual); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 static int @@ -467,7 +446,6 @@ testFirewallManyRollback(const void *opaque G_GNUC_UNUS= ED) { g_auto(virBuffer) cmdbuf =3D VIR_BUFFER_INITIALIZER; g_autoptr(virFirewall) fw =3D virFirewallNew(); - int ret =3D -1; const char *actual =3D NULL; const char *expected =3D IPTABLES " -w -A INPUT --source 192.168.122.1 --jump ACCEPT\n" @@ -518,7 +496,7 @@ testFirewallManyRollback(const void *opaque G_GNUC_UNUS= ED) =20 if (virFirewallApply(fw) =3D=3D 0) { fprintf(stderr, "Firewall apply unexpectedly worked\n"); - goto cleanup; + return -1; } =20 actual =3D virBufferCurrentContent(&cmdbuf); @@ -526,12 +504,10 @@ testFirewallManyRollback(const void *opaque G_GNUC_UN= USED) if (STRNEQ_NULLABLE(expected, actual)) { fprintf(stderr, "Unexpected command execution\n"); virTestDifference(stderr, expected, actual); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 static int @@ -539,7 +515,6 @@ testFirewallChainedRollback(const void *opaque G_GNUC_U= NUSED) { g_auto(virBuffer) cmdbuf =3D VIR_BUFFER_INITIALIZER; g_autoptr(virFirewall) fw =3D virFirewallNew(); - int ret =3D -1; const char *actual =3D NULL; const char *expected =3D IPTABLES " -w -A INPUT --source 192.168.122.1 --jump ACCEPT\n" @@ -620,7 +595,7 @@ testFirewallChainedRollback(const void *opaque G_GNUC_U= NUSED) =20 if (virFirewallApply(fw) =3D=3D 0) { fprintf(stderr, "Firewall apply unexpectedly worked\n"); - goto cleanup; + return -1; } =20 actual =3D virBufferCurrentContent(&cmdbuf); @@ -628,12 +603,10 @@ testFirewallChainedRollback(const void *opaque G_GNUC= _UNUSED) if (STRNEQ_NULLABLE(expected, actual)) { fprintf(stderr, "Unexpected command execution\n"); virTestDifference(stderr, expected, actual); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -720,7 +693,6 @@ testFirewallQuery(const void *opaque G_GNUC_UNUSED) { g_auto(virBuffer) cmdbuf =3D VIR_BUFFER_INITIALIZER; g_autoptr(virFirewall) fw =3D virFirewallNew(); - int ret =3D -1; const char *actual =3D NULL; const char *expected =3D IPTABLES " -w -A INPUT --source 192.168.122.1 --jump ACCEPT\n" @@ -783,24 +755,22 @@ testFirewallQuery(const void *opaque G_GNUC_UNUSED) "--jump", "REJECT", NULL); =20 if (virFirewallApply(fw) < 0) - goto cleanup; + return -1; =20 actual =3D virBufferCurrentContent(&cmdbuf); =20 if (expectedLineError) { fprintf(stderr, "Got some unexpected query data\n"); - goto cleanup; + return -1; } =20 if (STRNEQ_NULLABLE(expected, actual)) { fprintf(stderr, "Unexpected command execution\n"); virTestDifference(stderr, expected, actual); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 --=20 2.33.1