From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: armbru@redhat.com, "Kevin Wolf" <kwolf@redhat.com>,
"Max Reitz" <mreitz@redhat.com>,
"Michael Roth" <mdroth@linux.vnet.ibm.com>,
"Andreas Färber" <afaerber@suse.de>,
"Daniel P. Berrange" <berrange@redhat.com>,
"Gerd Hoffmann" <kraxel@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"open list:Block layer core" <qemu-block@nongnu.org>
Subject: [Qemu-devel] [PATCH v5 09/15] qmp-output-visitor: Favor new visit_free() function
Date: Thu, 9 Jun 2016 10:48:40 -0600 [thread overview]
Message-ID: <1465490926-28625-10-git-send-email-eblake@redhat.com> (raw)
In-Reply-To: <1465490926-28625-1-git-send-email-eblake@redhat.com>
Now that we have a polymorphic visit_free(), we no longer need
qmp_output_visitor_cleanup(); however, we still need to
expose the subtype for qmp_output_get_qobject().
Signed-off-by: Eric Blake <eblake@redhat.com>
---
v5: blank line after declaration
v4: new patch
---
include/qapi/qmp-output-visitor.h | 1 -
block/qapi.c | 2 +-
blockdev.c | 2 +-
qapi/qmp-output-visitor.c | 14 ++++----------
qemu-img.c | 6 +++---
qom/qom-qobject.c | 2 +-
replay/replay-input.c | 2 +-
tests/check-qnull.c | 2 +-
tests/test-qmp-output-visitor.c | 2 +-
util/qemu-sockets.c | 2 +-
10 files changed, 14 insertions(+), 21 deletions(-)
diff --git a/include/qapi/qmp-output-visitor.h b/include/qapi/qmp-output-visitor.h
index 2266770..29c9a2e 100644
--- a/include/qapi/qmp-output-visitor.h
+++ b/include/qapi/qmp-output-visitor.h
@@ -20,7 +20,6 @@
typedef struct QmpOutputVisitor QmpOutputVisitor;
QmpOutputVisitor *qmp_output_visitor_new(void);
-void qmp_output_visitor_cleanup(QmpOutputVisitor *v);
QObject *qmp_output_get_qobject(QmpOutputVisitor *v);
Visitor *qmp_output_get_visitor(QmpOutputVisitor *v);
diff --git a/block/qapi.c b/block/qapi.c
index 5594f74..41fe4f9 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -699,7 +699,7 @@ void bdrv_image_info_specific_dump(fprintf_function func_fprintf, void *f,
assert(qobject_type(obj) == QTYPE_QDICT);
data = qdict_get(qobject_to_qdict(obj), "data");
dump_qobject(func_fprintf, f, 1, data);
- qmp_output_visitor_cleanup(ov);
+ visit_free(qmp_output_get_visitor(ov));
}
void bdrv_image_info_dump(fprintf_function func_fprintf, void *f,
diff --git a/blockdev.c b/blockdev.c
index 7fd515a..1437dd7 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -4013,7 +4013,7 @@ void qmp_blockdev_add(BlockdevOptions *options, Error **errp)
}
fail:
- qmp_output_visitor_cleanup(ov);
+ visit_free(qmp_output_get_visitor(ov));
}
void qmp_x_blockdev_del(bool has_id, const char *id,
diff --git a/qapi/qmp-output-visitor.c b/qapi/qmp-output-visitor.c
index 5f0035c..3d12623 100644
--- a/qapi/qmp-output-visitor.c
+++ b/qapi/qmp-output-visitor.c
@@ -217,21 +217,15 @@ Visitor *qmp_output_get_visitor(QmpOutputVisitor *v)
static void qmp_output_free(Visitor *v)
{
QmpOutputVisitor *qov = to_qov(v);
-
- qmp_output_visitor_cleanup(qov);
-}
-
-void qmp_output_visitor_cleanup(QmpOutputVisitor *v)
-{
QStackEntry *e, *tmp;
- QTAILQ_FOREACH_SAFE(e, &v->stack, node, tmp) {
- QTAILQ_REMOVE(&v->stack, e, node);
+ QTAILQ_FOREACH_SAFE(e, &qov->stack, node, tmp) {
+ QTAILQ_REMOVE(&qov->stack, e, node);
g_free(e);
}
- qobject_decref(v->root);
- g_free(v);
+ qobject_decref(qov->root);
+ g_free(qov);
}
QmpOutputVisitor *qmp_output_visitor_new(void)
diff --git a/qemu-img.c b/qemu-img.c
index c4a8647..4a58578 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -493,7 +493,7 @@ static void dump_json_image_check(ImageCheck *check, bool quiet)
assert(str != NULL);
qprintf(quiet, "%s\n", qstring_get_str(str));
qobject_decref(obj);
- qmp_output_visitor_cleanup(ov);
+ visit_free(qmp_output_get_visitor(ov));
QDECREF(str);
}
@@ -2183,7 +2183,7 @@ static void dump_json_image_info_list(ImageInfoList *list)
assert(str != NULL);
printf("%s\n", qstring_get_str(str));
qobject_decref(obj);
- qmp_output_visitor_cleanup(ov);
+ visit_free(qmp_output_get_visitor(ov));
QDECREF(str);
}
@@ -2199,7 +2199,7 @@ static void dump_json_image_info(ImageInfo *info)
assert(str != NULL);
printf("%s\n", qstring_get_str(str));
qobject_decref(obj);
- qmp_output_visitor_cleanup(ov);
+ visit_free(qmp_output_get_visitor(ov));
QDECREF(str);
}
diff --git a/qom/qom-qobject.c b/qom/qom-qobject.c
index c3c9188..6714565 100644
--- a/qom/qom-qobject.c
+++ b/qom/qom-qobject.c
@@ -41,6 +41,6 @@ QObject *object_property_get_qobject(Object *obj, const char *name,
ret = qmp_output_get_qobject(qov);
}
error_propagate(errp, local_err);
- qmp_output_visitor_cleanup(qov);
+ visit_free(qmp_output_get_visitor(qov));
return ret;
}
diff --git a/replay/replay-input.c b/replay/replay-input.c
index 7b6fa93..9cbb4c1 100644
--- a/replay/replay-input.c
+++ b/replay/replay-input.c
@@ -31,7 +31,7 @@ static InputEvent *qapi_clone_InputEvent(InputEvent *src)
ov = qmp_output_get_visitor(qov);
visit_type_InputEvent(ov, NULL, &src, &error_abort);
obj = qmp_output_get_qobject(qov);
- qmp_output_visitor_cleanup(qov);
+ visit_free(ov);
if (!obj) {
return NULL;
}
diff --git a/tests/check-qnull.c b/tests/check-qnull.c
index d0412e4..6310bf7 100644
--- a/tests/check-qnull.c
+++ b/tests/check-qnull.c
@@ -58,7 +58,7 @@ static void qnull_visit_test(void)
obj = qmp_output_get_qobject(qov);
g_assert(obj == &qnull_);
qobject_decref(obj);
- qmp_output_visitor_cleanup(qov);
+ visit_free(qmp_output_get_visitor(qov));
g_assert(qnull_.refcnt == 1);
}
diff --git a/tests/test-qmp-output-visitor.c b/tests/test-qmp-output-visitor.c
index 75c8e1b..45d87fb 100644
--- a/tests/test-qmp-output-visitor.c
+++ b/tests/test-qmp-output-visitor.c
@@ -38,7 +38,7 @@ static void visitor_output_setup(TestOutputVisitorData *data,
static void visitor_output_teardown(TestOutputVisitorData *data,
const void *unused)
{
- qmp_output_visitor_cleanup(data->qov);
+ visit_free(data->ov);
data->qov = NULL;
data->ov = NULL;
}
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index 2737ed8..7eb1873 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -1139,7 +1139,7 @@ void qapi_copy_SocketAddress(SocketAddress **p_dest,
ov = qmp_output_get_visitor(qov);
visit_type_SocketAddress(ov, NULL, &src, &error_abort);
obj = qmp_output_get_qobject(qov);
- qmp_output_visitor_cleanup(qov);
+ visit_free(ov);
if (!obj) {
return;
}
--
2.5.5
next prev parent reply other threads:[~2016-06-09 16:49 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-09 16:48 [Qemu-devel] [PATCH v5 00/15] Add clone visitor Eric Blake
2016-06-09 16:48 ` [Qemu-devel] [PATCH v5 01/15] qapi: Improve use of qmp/types.h Eric Blake
2016-06-09 16:48 ` [Qemu-devel] [PATCH v5 02/15] qemu-img: Don't leak errors when outputting JSON Eric Blake
2016-06-09 16:48 ` [Qemu-devel] [PATCH v5 03/15] qapi: Add parameter to visit_end_* Eric Blake
2016-06-09 16:48 ` [Qemu-devel] [PATCH v5 04/15] qapi: Add new visit_free() function Eric Blake
2016-06-09 16:48 ` [Qemu-devel] [PATCH v5 05/15] opts-visitor: Favor " Eric Blake
2016-06-09 16:48 ` [Qemu-devel] [PATCH v5 06/15] string-input-visitor: " Eric Blake
2016-06-09 16:48 ` [Qemu-devel] [PATCH v5 07/15] qmp-input-visitor: " Eric Blake
2016-06-09 16:48 ` [Qemu-devel] [PATCH v5 08/15] string-output-visitor: " Eric Blake
2016-06-09 16:48 ` Eric Blake [this message]
2016-06-09 16:48 ` [Qemu-devel] [PATCH v5 10/15] tests: Clean up test-string-output-visitor Eric Blake
2016-06-09 16:48 ` [Qemu-devel] [PATCH v5 11/15] tests: Factor out common code in qapi output tests Eric Blake
2016-06-09 16:48 ` [Qemu-devel] [PATCH v5 12/15] qapi: Add new visit_complete() function Eric Blake
2016-06-09 16:48 ` [Qemu-devel] [PATCH v5 13/15] qapi: Add new clone visitor Eric Blake
2016-06-09 16:48 ` [Qemu-devel] [PATCH v5 14/15] sockets: Use new QAPI cloning Eric Blake
2016-06-09 16:48 ` [Qemu-devel] [PATCH v5 15/15] replay: " Eric Blake
2016-06-13 14:19 ` [Qemu-devel] [PATCH v5 00/15] Add clone visitor Markus Armbruster
2016-07-01 11:48 ` Markus Armbruster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1465490926-28625-10-git-send-email-eblake@redhat.com \
--to=eblake@redhat.com \
--cc=afaerber@suse.de \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=kraxel@redhat.com \
--cc=kwolf@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).