From: Markus Armbruster Date: Fri, 31 Jul 2015 16:51:18 +0000 (+0200) Subject: qapi-commands: Drop useless initialization X-Git-Tag: qemu-xen-4.8.0-rc1~841^2~8 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=3f99144cd9afbf51a7fbddf20b921402c2d4f68c;p=qemu-xen.git qapi-commands: Drop useless initialization 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 --- diff --git a/docs/qapi-code-gen.txt b/docs/qapi-code-gen.txt index a253e27d5f..7cb852e614 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 cfbd59c84e..8bf84a77dd 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)