From nobody Sat Nov 15 04:15:18 2025 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=1592988035; cv=none; d=zohomail.com; s=zohoarc; b=UcsrtvUxvLS4SrKnVJxfsfGY1rgteMdIXyKjKNlpxYKrrCfy2LDFSNRbVqwZmeip3fsXu6Ip3Z1QALWANIR28GQw2G/LeSNNLiSGIq1/41szhPFEE2yhgF6mXI42A7fg6tX74d7tAfV2LV+f1sHukhPs3cLI8AFPf197hBwJzUU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592988035; 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=cxTLHfiCWM0O/z4f4HQNOjq7KJfhAU9G227IZ4L2IA8=; b=l+JrlslSQByI7iYuuyuHFseJ9kjgof7WCu5fGZ9YDAHkc863aKV8MU4HTv0Cdh+/EhNliLElfnGr5h4HkEDXmLHSKQY/C9jLFDE6mTVP5zPdiB2CTFVq5jncWZjzsQ2F7X1cyIqbvf7JGxHrhuBpwqWf6rMVF+2BQkngxMw8ZAc= 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 1592988035958405.733738490953; Wed, 24 Jun 2020 01:40:35 -0700 (PDT) Received: from localhost ([::1]:47842 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jo0xO-0006Ty-Ib for importer@patchew.org; Wed, 24 Jun 2020 04:40:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48234) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jo0uh-0000Yw-Fl for qemu-devel@nongnu.org; Wed, 24 Jun 2020 04:37:47 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:45131 helo=us-smtp-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 1jo0ue-00023Z-I9 for qemu-devel@nongnu.org; Wed, 24 Jun 2020 04:37:47 -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-276-gD0R8nByPpO9tVUiEpT4cQ-1; Wed, 24 Jun 2020 04:37:41 -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 000D41B18BC3 for ; Wed, 24 Jun 2020 08:37:40 +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 9FDE17E59A for ; Wed, 24 Jun 2020 08:37:40 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 8B1AD1138473; Wed, 24 Jun 2020 10:37:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592987863; 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=cxTLHfiCWM0O/z4f4HQNOjq7KJfhAU9G227IZ4L2IA8=; b=iguFRPkQcGfU6iA9djevE86qPO2oROzGTYuNb+1FfBnKkiHGoyzqFiwlY1Y1Zv6+QSax+7 e5Oq+XeGpIAnILgzwalHTsTuAX4uQkzaa91PSdD6UhMsCCzvJFEDRjlHMjeYwrAqJ7zS1x kt9LRM595EwBc9ebPpk0mk8S2kGrfck= X-MC-Unique: gD0R8nByPpO9tVUiEpT4cQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 05/25] tests: Use error_free_or_abort() where appropriate Date: Wed, 24 Jun 2020 10:37:17 +0200 Message-Id: <20200624083737.3086768-6-armbru@redhat.com> In-Reply-To: <20200624083737.3086768-1-armbru@redhat.com> References: <20200624083737.3086768-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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=205.139.110.120; envelope-from=armbru@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/24 03:27:53 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 Reviewed-by: Eric Blake --- 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 8c71734e1a..e1e0a96661 100644 --- a/tests/check-qom-proplist.c +++ b/tests/check-qom-proplist.c @@ -491,17 +491,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