[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v10 06/25] hmp: Drop pointless allocation during qap
From: |
Eric Blake |
Subject: |
[Qemu-devel] [PATCH v10 06/25] hmp: Drop pointless allocation during qapi visit |
Date: |
Fri, 29 Jan 2016 06:48:42 -0700 |
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 <address@hidden>
Reviewed-by: Marc-André Lureau <address@hidden>
---
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
- [Qemu-devel] [PATCH v10 00/25] qapi visitor cleanups part 1 (post-introspection cleanups subset E), Eric Blake, 2016/01/29
- [Qemu-devel] [PATCH v10 04/25] qapi: Dealloc visitor does not need a type_size(), Eric Blake, 2016/01/29
- [Qemu-devel] [PATCH v10 07/25] hmp: Cache use of qapi visitor, Eric Blake, 2016/01/29
- [Qemu-devel] [PATCH v10 01/25] qobject: Document more shortcomings in our number handling, Eric Blake, 2016/01/29
- [Qemu-devel] [PATCH v10 05/25] qapi: Drop dead parameter in gen_params(), Eric Blake, 2016/01/29
- [Qemu-devel] [PATCH v10 08/25] vl: Ensure qapi visitor properly ends struct visit, Eric Blake, 2016/01/29
- [Qemu-devel] [PATCH v10 11/25] qapi: Track all failures between visit_start/stop, Eric Blake, 2016/01/29
- [Qemu-devel] [PATCH v10 03/25] qapi: Drop dead dealloc visitor variable, Eric Blake, 2016/01/29
- [Qemu-devel] [PATCH v10 13/25] qapi: Prefer type_int64 over type_int in visitors, Eric Blake, 2016/01/29
- [Qemu-devel] [PATCH v10 14/25] qapi: Make all visitors supply uint64 callbacks, Eric Blake, 2016/01/29
- [Qemu-devel] [PATCH v10 06/25] hmp: Drop pointless allocation during qapi visit,
Eric Blake <=
- [Qemu-devel] [PATCH v10 09/25] balloon: Improve use of qapi visitor, Eric Blake, 2016/01/29
- [Qemu-devel] [PATCH v10 16/25] qapi: Don't cast Enum* to int*, Eric Blake, 2016/01/29
- [Qemu-devel] [PATCH v10 02/25] qapi: Avoid use of misnamed DO_UPCAST(), Eric Blake, 2016/01/29
- [Qemu-devel] [PATCH v10 17/25] qom: Use typedef for Visitor, Eric Blake, 2016/01/29
- [Qemu-devel] [PATCH v10 25/25] qmp: Don't abuse stack to track qmp-output root, Eric Blake, 2016/01/29
- [Qemu-devel] [PATCH v10 15/25] qapi: Consolidate visitor small integer callbacks, Eric Blake, 2016/01/29
- [Qemu-devel] [PATCH v10 22/25] qapi: Tighten qmp_input_end_list(), Eric Blake, 2016/01/29
- [Qemu-devel] [PATCH v10 23/25] qapi: Drop unused error argument for list and implicit struct, Eric Blake, 2016/01/29
- [Qemu-devel] [PATCH v10 21/25] qapi: Drop unused 'kind' for struct/enum visit, Eric Blake, 2016/01/29
- [Qemu-devel] [PATCH v10 10/25] qapi: Improve generated event use of qapi visitor, Eric Blake, 2016/01/29