From patchwork Fri Aug 28 16:46:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 511978 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 9C1CF14018C for ; Sat, 29 Aug 2015 02:58:21 +1000 (AEST) Received: from localhost ([::1]:49027 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZVMyp-0003zx-LO for incoming@patchwork.ozlabs.org; Fri, 28 Aug 2015 12:58:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54376) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZVMnA-0008GD-VM for qemu-devel@nongnu.org; Fri, 28 Aug 2015 12:46:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZVMn9-0000NT-Au for qemu-devel@nongnu.org; Fri, 28 Aug 2015 12:46:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35397) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZVMn8-0000Mb-Nd for qemu-devel@nongnu.org; Fri, 28 Aug 2015 12:46:15 -0400 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 5C39A8F03F; Fri, 28 Aug 2015 16:46:14 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-73.ams2.redhat.com [10.36.116.73]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t7SGkBF2026762 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 28 Aug 2015 12:46:13 -0400 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 897AB3001115; Fri, 28 Aug 2015 18:46:07 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Fri, 28 Aug 2015 18:46:05 +0200 Message-Id: <1440780366-7177-26-git-send-email-armbru@redhat.com> In-Reply-To: <1440780366-7177-1-git-send-email-armbru@redhat.com> References: <1440780366-7177-1-git-send-email-armbru@redhat.com> 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 Cc: mdroth@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH v2 25/26] qapi-commands: Drop useless initialization 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 In generated command handlers, the assignment to retval dominates its only use. Therefore, its initialization is useless. Drop it. Suggested-by: Eric Blake Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- docs/qapi-code-gen.txt | 2 +- scripts/qapi-commands.py | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/docs/qapi-code-gen.txt b/docs/qapi-code-gen.txt index a253e27..7cb852e 100644 --- a/docs/qapi-code-gen.txt +++ b/docs/qapi-code-gen.txt @@ -742,7 +742,7 @@ Example: static void qmp_marshal_input_my_command(QDict *args, QObject **ret, Error **errp) { Error *local_err = NULL; - UserDefOne *retval = NULL; + UserDefOne *retval; QmpInputVisitor *mi = qmp_input_visitor_new_strict(QOBJECT(args)); QapiDeallocVisitor *md; Visitor *v; diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py index cfbd59c..8bf84a7 100644 --- a/scripts/qapi-commands.py +++ b/scripts/qapi-commands.py @@ -205,14 +205,10 @@ def gen_marshal_input(name, args, ret_type, middle_mode): header=hdr) if ret_type: - if is_c_ptr(ret_type): - retval = " %s retval = NULL;" % c_type(ret_type) - else: - retval = " %s retval;" % c_type(ret_type) ret += mcgen(''' -%(retval)s + %(c_type)s retval; ''', - retval=retval) + c_type=c_type(ret_type)) if len(args) > 0: ret += gen_visitor_input_containers_decl(args)