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>
This commit is contained in:
parent
c7eb39cbd4
commit
911ee36d41
10
qemu-img.c
10
qemu-img.c
|
@ -490,12 +490,11 @@ fail:
|
||||||
|
|
||||||
static void dump_json_image_check(ImageCheck *check, bool quiet)
|
static void dump_json_image_check(ImageCheck *check, bool quiet)
|
||||||
{
|
{
|
||||||
Error *local_err = NULL;
|
|
||||||
QString *str;
|
QString *str;
|
||||||
QmpOutputVisitor *ov = qmp_output_visitor_new();
|
QmpOutputVisitor *ov = qmp_output_visitor_new();
|
||||||
QObject *obj;
|
QObject *obj;
|
||||||
visit_type_ImageCheck(qmp_output_get_visitor(ov), NULL, &check,
|
visit_type_ImageCheck(qmp_output_get_visitor(ov), NULL, &check,
|
||||||
&local_err);
|
&error_abort);
|
||||||
obj = qmp_output_get_qobject(ov);
|
obj = qmp_output_get_qobject(ov);
|
||||||
str = qobject_to_json_pretty(obj);
|
str = qobject_to_json_pretty(obj);
|
||||||
assert(str != NULL);
|
assert(str != NULL);
|
||||||
|
@ -2181,12 +2180,11 @@ static void dump_snapshots(BlockDriverState *bs)
|
||||||
|
|
||||||
static void dump_json_image_info_list(ImageInfoList *list)
|
static void dump_json_image_info_list(ImageInfoList *list)
|
||||||
{
|
{
|
||||||
Error *local_err = NULL;
|
|
||||||
QString *str;
|
QString *str;
|
||||||
QmpOutputVisitor *ov = qmp_output_visitor_new();
|
QmpOutputVisitor *ov = qmp_output_visitor_new();
|
||||||
QObject *obj;
|
QObject *obj;
|
||||||
visit_type_ImageInfoList(qmp_output_get_visitor(ov), NULL, &list,
|
visit_type_ImageInfoList(qmp_output_get_visitor(ov), NULL, &list,
|
||||||
&local_err);
|
&error_abort);
|
||||||
obj = qmp_output_get_qobject(ov);
|
obj = qmp_output_get_qobject(ov);
|
||||||
str = qobject_to_json_pretty(obj);
|
str = qobject_to_json_pretty(obj);
|
||||||
assert(str != NULL);
|
assert(str != NULL);
|
||||||
|
@ -2198,11 +2196,11 @@ static void dump_json_image_info_list(ImageInfoList *list)
|
||||||
|
|
||||||
static void dump_json_image_info(ImageInfo *info)
|
static void dump_json_image_info(ImageInfo *info)
|
||||||
{
|
{
|
||||||
Error *local_err = NULL;
|
|
||||||
QString *str;
|
QString *str;
|
||||||
QmpOutputVisitor *ov = qmp_output_visitor_new();
|
QmpOutputVisitor *ov = qmp_output_visitor_new();
|
||||||
QObject *obj;
|
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);
|
obj = qmp_output_get_qobject(ov);
|
||||||
str = qobject_to_json_pretty(obj);
|
str = qobject_to_json_pretty(obj);
|
||||||
assert(str != NULL);
|
assert(str != NULL);
|
||||||
|
|
Loading…
Reference in New Issue