From patchwork Tue Feb 9 11:37:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 580762 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 098DA14031E for ; Tue, 9 Feb 2016 22:42:56 +1100 (AEDT) Received: from localhost ([::1]:54595 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aT6h4-0008AD-4O for incoming@patchwork.ozlabs.org; Tue, 09 Feb 2016 06:42:54 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34218) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aT6cW-0007rr-JW for qemu-devel@nongnu.org; Tue, 09 Feb 2016 06:38:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aT6cS-0002yc-F8 for qemu-devel@nongnu.org; Tue, 09 Feb 2016 06:38:12 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42524) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aT6cS-0002yN-9m for qemu-devel@nongnu.org; Tue, 09 Feb 2016 06:38:08 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id EC07C14CAB0 for ; Tue, 9 Feb 2016 11:38:07 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-34.ams2.redhat.com [10.36.116.34]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u19Bc6k8025257 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 9 Feb 2016 06:38:07 -0500 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id CB986300BD78; Tue, 9 Feb 2016 12:38:03 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Tue, 9 Feb 2016 12:37:42 +0100 Message-Id: <1455017883-25867-11-git-send-email-armbru@redhat.com> In-Reply-To: <1455017883-25867-1-git-send-email-armbru@redhat.com> References: <1455017883-25867-1-git-send-email-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 10/31] hmp: Drop pointless allocation during qapi visit X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Eric Blake 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é Lureau Message-Id: <1454075341-13658-7-git-send-email-eblake@redhat.com> Signed-off-by: Markus Armbruster --- hmp.c | 4 +--- vl.c | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/hmp.c b/hmp.c index cb03a15..6071a0b 100644 --- a/hmp.c +++ b/hmp.c @@ -1657,7 +1657,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; @@ -1669,7 +1668,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; } @@ -1701,7 +1700,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 c581e39..db51ebd 100644 --- a/vl.c +++ b/vl.c @@ -2821,7 +2821,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; @@ -2829,7 +2828,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; } @@ -2864,7 +2863,6 @@ out: QDECREF(pdict); g_free(id); g_free(type); - g_free(dummy); if (err) { error_report_err(err); return -1;