aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2016-06-09 10:48:33 -0600
committerMarkus Armbruster <armbru@redhat.com>2016-07-06 10:52:04 +0200
commit911ee36d411ee9b3540855642b53219b6a974992 (patch)
tree0be8dc9e62ea924b578570dad13ff19ddb98274b
parentc7eb39cbd4304ca55c760c0cb33ce235c457546c (diff)
qemu-img: Don't leak errors when outputting JSON
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> Message-Id: <1465490926-28625-3-git-send-email-eblake@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
-rw-r--r--qemu-img.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/qemu-img.c b/qemu-img.c
index 3322a1e5fc..debd7f1383 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -490,12 +490,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);
@@ -2181,12 +2180,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);
@@ -2198,11 +2196,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);