aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2016-06-09 10:48:38 -0600
committerMarkus Armbruster <armbru@redhat.com>2016-07-06 10:52:04 +0200
commitb70ce1018a251c0c33498d9c927a07cade655a5e (patch)
tree6f11b7166523750427c3bdf8f468567a80a0aea5 /tests
parent7a0525c7be6b38d32d586e3fd12e7377ded21faa (diff)
qmp-input-visitor: Favor new visit_free() function
Now that we have a polymorphic visit_free(), we no longer need qmp_input_visitor_cleanup(); which in turn means we no longer need to return a subtype from qmp_input_visitor_new() nor a public upcast function. Generated code changes to qmp-marshal.c look like: |@@ -52,11 +52,10 @@ void qmp_marshal_add_fd(QDict *args, QOb | { | Error *err = NULL; | AddfdInfo *retval; |- QmpInputVisitor *qiv = qmp_input_visitor_new(QOBJECT(args), true); | Visitor *v; | q_obj_add_fd_arg arg = {0}; | |- v = qmp_input_get_visitor(qiv); |+ v = qmp_input_visitor_new(QOBJECT(args), true); | visit_start_struct(v, NULL, NULL, 0, &err); | if (err) { | goto out; Signed-off-by: Eric Blake <eblake@redhat.com> Message-Id: <1465490926-28625-8-git-send-email-eblake@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/check-qnull.c8
-rw-r--r--tests/test-qmp-commands.c8
-rw-r--r--tests/test-qmp-input-strict.c12
-rw-r--r--tests/test-qmp-input-visitor.c12
-rw-r--r--tests/test-visitor-serialization.c6
5 files changed, 17 insertions, 29 deletions
diff --git a/tests/check-qnull.c b/tests/check-qnull.c
index 05d562d494..d0412e4169 100644
--- a/tests/check-qnull.c
+++ b/tests/check-qnull.c
@@ -38,7 +38,7 @@ static void qnull_visit_test(void)
{
QObject *obj;
QmpOutputVisitor *qov;
- QmpInputVisitor *qiv;
+ Visitor *v;
/*
* Most tests of interactions between QObject and visitors are in
@@ -48,10 +48,10 @@ static void qnull_visit_test(void)
g_assert(qnull_.refcnt == 1);
obj = qnull();
- qiv = qmp_input_visitor_new(obj, true);
+ v = qmp_input_visitor_new(obj, true);
qobject_decref(obj);
- visit_type_null(qmp_input_get_visitor(qiv), NULL, &error_abort);
- qmp_input_visitor_cleanup(qiv);
+ visit_type_null(v, NULL, &error_abort);
+ visit_free(v);
qov = qmp_output_visitor_new();
visit_type_null(qmp_output_get_visitor(qov), NULL, &error_abort);
diff --git a/tests/test-qmp-commands.c b/tests/test-qmp-commands.c
index e8f619d331..8ffeb045cd 100644
--- a/tests/test-qmp-commands.c
+++ b/tests/test-qmp-commands.c
@@ -216,14 +216,14 @@ static void test_dealloc_partial(void)
/* create partial object */
{
QDict *ud2_dict;
- QmpInputVisitor *qiv;
+ Visitor *v;
ud2_dict = qdict_new();
qdict_put_obj(ud2_dict, "string0", QOBJECT(qstring_from_str(text)));
- qiv = qmp_input_visitor_new(QOBJECT(ud2_dict), true);
- visit_type_UserDefTwo(qmp_input_get_visitor(qiv), NULL, &ud2, &err);
- qmp_input_visitor_cleanup(qiv);
+ v = qmp_input_visitor_new(QOBJECT(ud2_dict), true);
+ visit_type_UserDefTwo(v, NULL, &ud2, &err);
+ visit_free(v);
QDECREF(ud2_dict);
}
diff --git a/tests/test-qmp-input-strict.c b/tests/test-qmp-input-strict.c
index 79739e9808..814550ac71 100644
--- a/tests/test-qmp-input-strict.c
+++ b/tests/test-qmp-input-strict.c
@@ -26,7 +26,7 @@
typedef struct TestInputVisitorData {
QObject *obj;
- QmpInputVisitor *qiv;
+ Visitor *qiv;
} TestInputVisitorData;
static void validate_teardown(TestInputVisitorData *data,
@@ -36,7 +36,7 @@ static void validate_teardown(TestInputVisitorData *data,
data->obj = NULL;
if (data->qiv) {
- qmp_input_visitor_cleanup(data->qiv);
+ visit_free(data->qiv);
data->qiv = NULL;
}
}
@@ -48,8 +48,6 @@ static Visitor *validate_test_init_internal(TestInputVisitorData *data,
const char *json_string,
va_list *ap)
{
- Visitor *v;
-
validate_teardown(data, NULL);
data->obj = qobject_from_jsonv(json_string, ap);
@@ -57,11 +55,7 @@ static Visitor *validate_test_init_internal(TestInputVisitorData *data,
data->qiv = qmp_input_visitor_new(data->obj, true);
g_assert(data->qiv);
-
- v = qmp_input_get_visitor(data->qiv);
- g_assert(v);
-
- return v;
+ return data->qiv;
}
static GCC_FMT_ATTR(2, 3)
diff --git a/tests/test-qmp-input-visitor.c b/tests/test-qmp-input-visitor.c
index b236183ec0..f583dce3ed 100644
--- a/tests/test-qmp-input-visitor.c
+++ b/tests/test-qmp-input-visitor.c
@@ -22,7 +22,7 @@
typedef struct TestInputVisitorData {
QObject *obj;
- QmpInputVisitor *qiv;
+ Visitor *qiv;
} TestInputVisitorData;
static void visitor_input_teardown(TestInputVisitorData *data,
@@ -32,7 +32,7 @@ static void visitor_input_teardown(TestInputVisitorData *data,
data->obj = NULL;
if (data->qiv) {
- qmp_input_visitor_cleanup(data->qiv);
+ visit_free(data->qiv);
data->qiv = NULL;
}
}
@@ -44,8 +44,6 @@ static Visitor *visitor_input_test_init_internal(TestInputVisitorData *data,
const char *json_string,
va_list *ap)
{
- Visitor *v;
-
visitor_input_teardown(data, NULL);
data->obj = qobject_from_jsonv(json_string, ap);
@@ -53,11 +51,7 @@ static Visitor *visitor_input_test_init_internal(TestInputVisitorData *data,
data->qiv = qmp_input_visitor_new(data->obj, false);
g_assert(data->qiv);
-
- v = qmp_input_get_visitor(data->qiv);
- g_assert(v);
-
- return v;
+ return data->qiv;
}
static GCC_FMT_ATTR(2, 3)
diff --git a/tests/test-visitor-serialization.c b/tests/test-visitor-serialization.c
index c3c8634294..0766dcc5a1 100644
--- a/tests/test-visitor-serialization.c
+++ b/tests/test-visitor-serialization.c
@@ -1013,7 +1013,7 @@ static PrimitiveType pt_values[] = {
typedef struct QmpSerializeData {
QmpOutputVisitor *qov;
- QmpInputVisitor *qiv;
+ Visitor *qiv;
} QmpSerializeData;
static void qmp_serialize(void *native_in, void **datap,
@@ -1041,14 +1041,14 @@ static void qmp_deserialize(void **native_out, void *datap,
d->qiv = qmp_input_visitor_new(obj, true);
qobject_decref(obj_orig);
qobject_decref(obj);
- visit(qmp_input_get_visitor(d->qiv), native_out, errp);
+ visit(d->qiv, native_out, errp);
}
static void qmp_cleanup(void *datap)
{
QmpSerializeData *d = datap;
qmp_output_visitor_cleanup(d->qov);
- qmp_input_visitor_cleanup(d->qiv);
+ visit_free(d->qiv);
g_free(d);
}