From nobody Mon Feb 9 20:11:02 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1592822795; cv=none; d=zohomail.com; s=zohoarc; b=n/S9EuzDgiAIXGr/9S9DSYShfYA2Y+8ypQdzowul5q3pmtHSmrZOGpE1yOEw2dqDgUovU/oKzRWhkqhIWjOHKxVqsPRWxpkCknc2rxTVwRnBMAxwB5DDPXqnLw9HQNuuAXuW6vh3dlFLGcKR99xKMnV4nVQn7X0IpTWe2SP5cq8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592822795; 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=Iut4Ff1MUId/Q14AI43HHOe4BqHaWd0dUndKiXhQMWU=; b=eOeXP3tPCF38AwhfmL0E4G0jYYWx4YDMDQx+/1Y5+5hdHpVYTxj+ircEVDpFMdIj4vSAE8whOFHjLuVoFTdo1LHrZiKe+WcO5ht0wvdRLRF2Z3JdDSDvzE5YBPWfcHY6lJu6oZOsbrflJyBan0+p4xYYqB2paieaeQTBpbVkz+0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592822795772549.156694689267; Mon, 22 Jun 2020 03:46:35 -0700 (PDT) Received: from localhost ([::1]:58326 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jnJyE-000402-F0 for importer@patchew.org; Mon, 22 Jun 2020 06:46:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40006) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jnJum-0007OH-NZ for qemu-devel@nongnu.org; Mon, 22 Jun 2020 06:43:00 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:54608 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jnJuk-0005MF-86 for qemu-devel@nongnu.org; Mon, 22 Jun 2020 06:43:00 -0400 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-271-QocUEQb3PBCk7w3IImr2BA-1; Mon, 22 Jun 2020 06:42:55 -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 AF220835B43 for ; Mon, 22 Jun 2020 10:42:54 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-121.ams2.redhat.com [10.36.112.121]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 55B2460BEC for ; Mon, 22 Jun 2020 10:42:54 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 138001138473; Mon, 22 Jun 2020 12:42:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592822577; h=from:from: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; bh=Iut4Ff1MUId/Q14AI43HHOe4BqHaWd0dUndKiXhQMWU=; b=elBfEhyuE1gKlnfpEejJSnxMk5wzRBLtA/1SklTcWNzY12yVfpg+/K2URSYKHhNQ0xWaS0 NQnC9OR6LLZFq3/RAdk/aFNv2KBIopc9t2VGumvQ4v1J8YX1W0s7JLdlQ6f2P/oooDbzqh Yh7+E1Ui/Kw2o46obgYkx6f1sicvPjM= X-MC-Unique: QocUEQb3PBCk7w3IImr2BA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 05/22] tests: Use error_free_or_abort() where appropriate Date: Mon, 22 Jun 2020 12:42:33 +0200 Message-Id: <20200622104250.1404835-6-armbru@redhat.com> In-Reply-To: <20200622104250.1404835-1-armbru@redhat.com> References: <20200622104250.1404835-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/22 02:57:26 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Replace g_assert(err !=3D NULL); error_free(err); err =3D NULL; and variations thereof by error_free_or_abort(&err); Signed-off-by: Markus Armbruster --- tests/check-block-qdict.c | 24 ++++++------------------ tests/check-qom-proplist.c | 7 ++----- tests/test-base64.c | 3 +-- tests/test-bdrv-graph-mod.c | 4 +--- tests/test-block-iothread.c | 3 +-- tests/test-crypto-cipher.c | 8 ++------ tests/test-io-task.c | 4 +--- 7 files changed, 14 insertions(+), 39 deletions(-) diff --git a/tests/check-block-qdict.c b/tests/check-block-qdict.c index 73d3e9f574..5a25825093 100644 --- a/tests/check-block-qdict.c +++ b/tests/check-block-qdict.c @@ -610,9 +610,7 @@ static void qdict_rename_keys_test(void) copy =3D qdict_clone_shallow(dict); qdict_rename_keys(copy, renames, &local_err); =20 - g_assert(local_err !=3D NULL); - error_free(local_err); - local_err =3D NULL; + error_free_or_abort(&local_err); =20 g_assert_cmpstr(qdict_get_str(copy, "abc"), =3D=3D, "foo"); g_assert_cmpstr(qdict_get_str(copy, "abcdef"), =3D=3D, "bar"); @@ -649,9 +647,7 @@ static void qdict_crumple_test_bad_inputs(void) qdict_put_str(src, "rule.0.policy", "allow"); =20 g_assert(qdict_crumple(src, &error) =3D=3D NULL); - g_assert(error !=3D NULL); - error_free(error); - error =3D NULL; + error_free_or_abort(&error); qobject_unref(src); =20 src =3D qdict_new(); @@ -660,9 +656,7 @@ static void qdict_crumple_test_bad_inputs(void) qdict_put_str(src, "rule.a", "allow"); =20 g_assert(qdict_crumple(src, &error) =3D=3D NULL); - g_assert(error !=3D NULL); - error_free(error); - error =3D NULL; + error_free_or_abort(&error); qobject_unref(src); =20 src =3D qdict_new(); @@ -673,9 +667,7 @@ static void qdict_crumple_test_bad_inputs(void) qdict_put_str(src, "rule.b", "allow"); =20 g_assert(qdict_crumple(src, &error) =3D=3D NULL); - g_assert(error !=3D NULL); - error_free(error); - error =3D NULL; + error_free_or_abort(&error); qobject_unref(src); =20 src =3D qdict_new(); @@ -684,9 +676,7 @@ static void qdict_crumple_test_bad_inputs(void) qdict_put_str(src, "rule.3", "allow"); =20 g_assert(qdict_crumple(src, &error) =3D=3D NULL); - g_assert(error !=3D NULL); - error_free(error); - error =3D NULL; + error_free_or_abort(&error); qobject_unref(src); =20 src =3D qdict_new(); @@ -695,9 +685,7 @@ static void qdict_crumple_test_bad_inputs(void) qdict_put_str(src, "rule.+1", "allow"); =20 g_assert(qdict_crumple(src, &error) =3D=3D NULL); - g_assert(error !=3D NULL); - error_free(error); - error =3D NULL; + error_free_or_abort(&error); qobject_unref(src); } =20 diff --git a/tests/check-qom-proplist.c b/tests/check-qom-proplist.c index 13a824cfae..a44d6e1171 100644 --- a/tests/check-qom-proplist.c +++ b/tests/check-qom-proplist.c @@ -494,17 +494,14 @@ static void test_dummy_getenum(void) "av", "BadAnimal", &err); - g_assert(err !=3D NULL); - error_free(err); - err =3D NULL; + error_free_or_abort(&err); =20 /* A non-enum property name */ val =3D object_property_get_enum(OBJECT(dobj), "iv", "DummyAnimal", &err); - g_assert(err !=3D NULL); - error_free(err); + error_free_or_abort(&err); =20 object_unparent(OBJECT(dobj)); } diff --git a/tests/test-base64.c b/tests/test-base64.c index ec122ceba5..a7f722c459 100644 --- a/tests/test-base64.c +++ b/tests/test-base64.c @@ -54,10 +54,9 @@ static void test_base64_bad(const char *input, &len, &err); =20 - g_assert(err !=3D NULL); + error_free_or_abort(&err); g_assert(actual =3D=3D NULL); g_assert_cmpint(len, =3D=3D, 0); - error_free(err); } =20 =20 diff --git a/tests/test-bdrv-graph-mod.c b/tests/test-bdrv-graph-mod.c index f93f3168b0..8cff13830e 100644 --- a/tests/test-bdrv-graph-mod.c +++ b/tests/test-bdrv-graph-mod.c @@ -115,9 +115,7 @@ static void test_update_perm_tree(void) BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, &error_abo= rt); =20 bdrv_append(filter, bs, &local_err); - - g_assert_nonnull(local_err); - error_free(local_err); + error_free_or_abort(&local_err); =20 blk_unref(root); } diff --git a/tests/test-block-iothread.c b/tests/test-block-iothread.c index a953794be2..3f866a35c6 100644 --- a/tests/test-block-iothread.c +++ b/tests/test-block-iothread.c @@ -650,8 +650,7 @@ static void test_propagate_mirror(void) blk_insert_bs(blk, src, &error_abort); =20 bdrv_try_set_aio_context(target, ctx, &local_err); - g_assert(local_err); - error_free(local_err); + error_free_or_abort(&local_err); =20 g_assert(blk_get_aio_context(blk) =3D=3D main_ctx); g_assert(bdrv_get_aio_context(src) =3D=3D main_ctx); diff --git a/tests/test-crypto-cipher.c b/tests/test-crypto-cipher.c index 07fa2fa616..bebba1a4f4 100644 --- a/tests/test-crypto-cipher.c +++ b/tests/test-crypto-cipher.c @@ -761,10 +761,7 @@ static void test_cipher_short_plaintext(void) sizeof(plaintext1), &err); g_assert(ret =3D=3D -1); - g_assert(err !=3D NULL); - - error_free(err); - err =3D NULL; + error_free_or_abort(&err); =20 /* Should report an error as plaintext is larger than * block size, but not a multiple of block size @@ -775,9 +772,8 @@ static void test_cipher_short_plaintext(void) sizeof(plaintext2), &err); g_assert(ret =3D=3D -1); - g_assert(err !=3D NULL); + error_free_or_abort(&err); =20 - error_free(err); qcrypto_cipher_free(cipher); } =20 diff --git a/tests/test-io-task.c b/tests/test-io-task.c index c8a3813d49..85e7a98da5 100644 --- a/tests/test-io-task.c +++ b/tests/test-io-task.c @@ -240,9 +240,7 @@ static void test_task_thread_failure(void) object_unref(obj); =20 g_assert(data.source =3D=3D obj); - g_assert(data.err !=3D NULL); - - error_free(data.err); + error_free_or_abort(&data.err); =20 self =3D g_thread_self(); =20 --=20 2.26.2