The qapi visitor contract allows us to visit a virtual structure, where we don't have any corresponding qapi struct. Most such uses pass NULL for @obj; but these two callers were passing a dummy pointer, which then gets allocated to heap memory but then immediately freed without use. Clean this up to suppress unwanted allocation, like we do elsewhere.
Signed-off-by: Eric Blake <ebl...@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lur...@redhat.com> --- v10: resplit 4/37 and 5/37 by action rather than file, retain R-b. v9: no change v8: no change v7: place earlier in series, drop attempts to provide a 'kind' string, drop bogus avoidance of qmp_object_del() on error v6: new patch, split from RFC on v5 7/46 --- hmp.c | 4 +--- vl.c | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/hmp.c b/hmp.c index 54f2620..9537f7b 100644 --- a/hmp.c +++ b/hmp.c @@ -1656,7 +1656,6 @@ void hmp_object_add(Monitor *mon, const QDict *qdict) QemuOpts *opts; char *type = NULL; char *id = NULL; - void *dummy = NULL; OptsVisitor *ov; QDict *pdict; @@ -1668,7 +1667,7 @@ void hmp_object_add(Monitor *mon, const QDict *qdict) ov = opts_visitor_new(opts); pdict = qdict_clone_shallow(qdict); - visit_start_struct(opts_get_visitor(ov), &dummy, NULL, NULL, 0, &err); + visit_start_struct(opts_get_visitor(ov), NULL, NULL, NULL, 0, &err); if (err) { goto out_clean; } @@ -1700,7 +1699,6 @@ out_clean: qemu_opts_del(opts); g_free(id); g_free(type); - g_free(dummy); out: hmp_handle_error(mon, &err); diff --git a/vl.c b/vl.c index f043009..b96590a 100644 --- a/vl.c +++ b/vl.c @@ -2824,7 +2824,6 @@ static int object_create(void *opaque, QemuOpts *opts, Error **errp) Error *err = NULL; char *type = NULL; char *id = NULL; - void *dummy = NULL; OptsVisitor *ov; QDict *pdict; bool (*type_predicate)(const char *) = opaque; @@ -2832,7 +2831,7 @@ static int object_create(void *opaque, QemuOpts *opts, Error **errp) ov = opts_visitor_new(opts); pdict = qemu_opts_to_qdict(opts, NULL); - visit_start_struct(opts_get_visitor(ov), &dummy, NULL, NULL, 0, &err); + visit_start_struct(opts_get_visitor(ov), NULL, NULL, NULL, 0, &err); if (err) { goto out; } @@ -2867,7 +2866,6 @@ out: QDECREF(pdict); g_free(id); g_free(type); - g_free(dummy); if (err) { error_report_err(err); return -1; -- 2.5.0