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>,
"open list:Block layer core" <qemu-block@nongnu.org>
Subject: [Qemu-devel] [PATCH v5 02/15] qemu-img: Don't leak errors when outputting JSON
Date: Thu, 9 Jun 2016 10:48:33 -0600 [thread overview]
Message-ID: <1465490926-28625-3-git-send-email-eblake@redhat.com> (raw)
In-Reply-To: <1465490926-28625-1-git-send-email-eblake@redhat.com>
If our JSON output ever encounters an error, we would just silently
leak the error object. Instead, assert that our usage won't fail.
Signed-off-by: Eric Blake <eblake@redhat.com>
---
v5: commit message wording tweak
v4: new patch (split out from v3 14/18)
---
qemu-img.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/qemu-img.c b/qemu-img.c
index 251386b..c4a8647 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -483,12 +483,11 @@ fail:
static void dump_json_image_check(ImageCheck *check, bool quiet)
{
- Error *local_err = NULL;
QString *str;
QmpOutputVisitor *ov = qmp_output_visitor_new();
QObject *obj;
visit_type_ImageCheck(qmp_output_get_visitor(ov), NULL, &check,
- &local_err);
+ &error_abort);
obj = qmp_output_get_qobject(ov);
str = qobject_to_json_pretty(obj);
assert(str != NULL);
@@ -2174,12 +2173,11 @@ static void dump_snapshots(BlockDriverState *bs)
static void dump_json_image_info_list(ImageInfoList *list)
{
- Error *local_err = NULL;
QString *str;
QmpOutputVisitor *ov = qmp_output_visitor_new();
QObject *obj;
visit_type_ImageInfoList(qmp_output_get_visitor(ov), NULL, &list,
- &local_err);
+ &error_abort);
obj = qmp_output_get_qobject(ov);
str = qobject_to_json_pretty(obj);
assert(str != NULL);
@@ -2191,11 +2189,11 @@ static void dump_json_image_info_list(ImageInfoList *list)
static void dump_json_image_info(ImageInfo *info)
{
- Error *local_err = NULL;
QString *str;
QmpOutputVisitor *ov = qmp_output_visitor_new();
QObject *obj;
- visit_type_ImageInfo(qmp_output_get_visitor(ov), NULL, &info, &local_err);
+ visit_type_ImageInfo(qmp_output_get_visitor(ov), NULL, &info,
+ &error_abort);
obj = qmp_output_get_qobject(ov);
str = qobject_to_json_pretty(obj);
assert(str != NULL);
--
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 ` Eric Blake [this message]
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 ` [Qemu-devel] [PATCH v5 09/15] qmp-output-visitor: " Eric Blake
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-3-git-send-email-eblake@redhat.com \
--to=eblake@redhat.com \
--cc=armbru@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@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).