From patchwork Fri Jan 29 13:48:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 8163361 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id DFD389F38B for ; Fri, 29 Jan 2016 13:53:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4C9062038E for ; Fri, 29 Jan 2016 13:53:11 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 797582038A for ; Fri, 29 Jan 2016 13:53:10 +0000 (UTC) Received: from localhost ([::1]:34246 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aP9U5-0002CN-Tc for patchwork-qemu-devel@patchwork.kernel.org; Fri, 29 Jan 2016 08:53:09 -0500 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) Received: from red.redhat.com (ovpn-113-130.phx2.redhat.com [10.3.113.130]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u0TDn5FG019157; Fri, 29 Jan 2016 08:49:08 -0500 From: Eric Blake To: qemu-devel@nongnu.org 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 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: marcandre.lureau@redhat.com, Paolo Bonzini , armbru@redhat.com, Luiz Capitulino Subject: [Qemu-devel] [PATCH v10 06/25] 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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;