Received: from eggs.gnu.org ([2001:4830:134:3::10]:41327) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aP9QE-0003U7-FO for qemu-devel@nongnu.org; Fri, 29 Jan 2016 08:49:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aP9QD-0001HZ-7r for qemu-devel@nongnu.org; Fri, 29 Jan 2016 08:49:10 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41705) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aP9QD-0001HV-23 for qemu-devel@nongnu.org; Fri, 29 Jan 2016 08:49:09 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id A6776693E6 for ; Fri, 29 Jan 2016 13:49:08 +0000 (UTC) From: Eric Blake Date: Fri, 29 Jan 2016 06:48:42 -0700 Message-Id: <1454075341-13658-7-git-send-email-eblake@redhat.com> In-Reply-To: <1454075341-13658-1-git-send-email-eblake@redhat.com> References: <1454075341-13658-1-git-send-email-eblake@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH v10 06/25] hmp: Drop pointless allocation during qapi visit List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, Paolo Bonzini , armbru@redhat.com, Luiz Capitulino 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 Reviewed-by: Marc-Andr=C3=A9 Lureau --- 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 *qdic= t) QemuOpts *opts; char *type =3D NULL; char *id =3D NULL; - void *dummy =3D NULL; OptsVisitor *ov; QDict *pdict; @@ -1668,7 +1667,7 @@ void hmp_object_add(Monitor *mon, const QDict *qdic= t) ov =3D opts_visitor_new(opts); pdict =3D 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 *op= ts, Error **errp) Error *err =3D NULL; char *type =3D NULL; char *id =3D NULL; - void *dummy =3D NULL; OptsVisitor *ov; QDict *pdict; bool (*type_predicate)(const char *) =3D opaque; @@ -2832,7 +2831,7 @@ static int object_create(void *opaque, QemuOpts *op= ts, Error **errp) ov =3D opts_visitor_new(opts); pdict =3D 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; --=20 2.5.0