* [Qemu-devel] [PATCH] tests: Use error_free_or_abort() where appropriate
@ 2017-02-17 20:15 Markus Armbruster
2017-02-17 20:39 ` Eric Blake
0 siblings, 1 reply; 2+ messages in thread
From: Markus Armbruster @ 2017-02-17 20:15 UTC (permalink / raw)
To: qemu-devel; +Cc: mdroth
Done with this Coccinelle semantic patch:
@@
expression E;
@@
- g_assert(E);
- error_free(E);
+ error_free_or_abort(&E);
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
tests/test-qemu-opts.c | 3 +--
tests/test-qobject-output-visitor.c | 6 ++----
2 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/tests/test-qemu-opts.c b/tests/test-qemu-opts.c
index a505a3e..d08e8a6 100644
--- a/tests/test-qemu-opts.c
+++ b/tests/test-qemu-opts.c
@@ -79,8 +79,7 @@ static void test_find_unknown_opts(void)
/* should not return anything, we don't have an "unknown" option */
list = qemu_find_opts_err("unknown", &err);
g_assert(list == NULL);
- g_assert(err);
- error_free(err);
+ error_free_or_abort(&err);
}
static void test_qemu_find_opts(void)
diff --git a/tests/test-qobject-output-visitor.c b/tests/test-qobject-output-visitor.c
index 4e2d79c..58019e2 100644
--- a/tests/test-qobject-output-visitor.c
+++ b/tests/test-qobject-output-visitor.c
@@ -146,8 +146,7 @@ static void test_visitor_out_enum_errors(TestOutputVisitorData *data,
for (i = 0; i < ARRAY_SIZE(bad_values) ; i++) {
err = NULL;
visit_type_EnumOne(data->ov, "unused", &bad_values[i], &err);
- g_assert(err);
- error_free(err);
+ error_free_or_abort(&err);
visitor_reset(data);
}
}
@@ -251,8 +250,7 @@ static void test_visitor_out_struct_errors(TestOutputVisitorData *data,
u.has_enum1 = true;
u.enum1 = bad_values[i];
visit_type_UserDefOne(data->ov, "unused", &pu, &err);
- g_assert(err);
- error_free(err);
+ error_free_or_abort(&err);
visitor_reset(data);
}
}
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH] tests: Use error_free_or_abort() where appropriate
2017-02-17 20:15 [Qemu-devel] [PATCH] tests: Use error_free_or_abort() where appropriate Markus Armbruster
@ 2017-02-17 20:39 ` Eric Blake
0 siblings, 0 replies; 2+ messages in thread
From: Eric Blake @ 2017-02-17 20:39 UTC (permalink / raw)
To: Markus Armbruster, qemu-devel; +Cc: mdroth
[-- Attachment #1: Type: text/plain, Size: 714 bytes --]
On 02/17/2017 02:15 PM, Markus Armbruster wrote:
> Done with this Coccinelle semantic patch:
>
> @@
> expression E;
> @@
> - g_assert(E);
> - error_free(E);
> + error_free_or_abort(&E);
>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
> tests/test-qemu-opts.c | 3 +--
> tests/test-qobject-output-visitor.c | 6 ++----
> 2 files changed, 3 insertions(+), 6 deletions(-)
Nice that it doesn't find many uses (it means we've already swept the
tests for this pattern manually).
Reviewed-by: Eric Blake <eblake@redhat.com>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-02-17 20:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-17 20:15 [Qemu-devel] [PATCH] tests: Use error_free_or_abort() where appropriate Markus Armbruster
2017-02-17 20:39 ` Eric Blake
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).