]> git.proxmox.com Git - mirror_qemu.git/commitdiff
qapi-commands: Drop useless initialization
authorMarkus Armbruster <armbru@redhat.com>
Fri, 31 Jul 2015 16:51:18 +0000 (18:51 +0200)
committerMarkus Armbruster <armbru@redhat.com>
Fri, 4 Sep 2015 13:47:15 +0000 (15:47 +0200)
In generated command handlers, the assignment to retval dominates its
only use.  Therefore, its initialization is useless.  Drop it.

Suggested-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
docs/qapi-code-gen.txt
scripts/qapi-commands.py

index a253e27d5fac405d25aed73d881a3d1257664781..7cb852e6141a5753b30b11d8059f1684e229a7fa 100644 (file)
@@ -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;
index cfbd59c84e9708542c215e5ad2b54e2126ce515c..8bf84a77dd895f80000db918fe741b4018a97038 100644 (file)
@@ -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)