[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 03/28] qemu-img: Don't leak errors when outputtin
From: |
Eric Blake |
Subject: |
[Qemu-devel] [PATCH v4 03/28] qemu-img: Don't leak errors when outputting JSON |
Date: |
Wed, 18 May 2016 22:40:49 -0600 |
If our JSON output ever encounters an error, we would just silently
leak the local variable. Instead, assert that our usage won't fail.
Signed-off-by: Eric Blake <address@hidden>
---
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 b4f93ce..3aa7fb3 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -479,12 +479,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);
@@ -2170,12 +2169,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);
@@ -2187,11 +2185,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
- [Qemu-devel] [PATCH v4 00/28] Add qapi-to-JSON and clone visitors, Eric Blake, 2016/05/19
- [Qemu-devel] [PATCH v4 05/28] qapi: Add new visit_free() function, Eric Blake, 2016/05/19
- [Qemu-devel] [PATCH v4 02/28] qapi: Improve use of qmp/types.h, Eric Blake, 2016/05/19
- [Qemu-devel] [PATCH v4 03/28] qemu-img: Don't leak errors when outputting JSON,
Eric Blake <=
- [Qemu-devel] [PATCH v4 06/28] opts-visitor: Favor new visit_free() function, Eric Blake, 2016/05/19
- [Qemu-devel] [PATCH v4 08/28] qmp-input-visitor: Favor new visit_free() function, Eric Blake, 2016/05/19
- [Qemu-devel] [PATCH v4 07/28] string-input-visitor: Favor new visit_free() function, Eric Blake, 2016/05/19
- [Qemu-devel] [PATCH v4 01/28] qapi: Rename (one) qjson.h to qobject-json.h, Eric Blake, 2016/05/19
- [Qemu-devel] [PATCH v4 09/28] string-output-visitor: Favor new visit_free() function, Eric Blake, 2016/05/19
- [Qemu-devel] [PATCH v4 04/28] qapi: Add parameter to visit_end_*, Eric Blake, 2016/05/19
- [Qemu-devel] [PATCH v4 15/28] replay: Use new QAPI cloning, Eric Blake, 2016/05/19
- [Qemu-devel] [PATCH v4 11/28] tests: Factor out common code in qapi output tests, Eric Blake, 2016/05/19
- [Qemu-devel] [PATCH v4 10/28] qmp-output-visitor: Favor new visit_free() function, Eric Blake, 2016/05/19
- [Qemu-devel] [PATCH v4 14/28] sockets: Use new QAPI cloning, Eric Blake, 2016/05/19