[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 25/26] qapi-commands: Drop useless initialization
From: |
Markus Armbruster |
Subject: |
[Qemu-devel] [PATCH 25/26] qapi-commands: Drop useless initialization |
Date: |
Tue, 4 Aug 2015 11:18:15 +0200 |
In generated command handlers, the assignment to retval dominates its
only use. Therefore, its initialization is useless. Drop it.
Suggested-by: Eric Blake <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>
---
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 279c681..6e09fed 100644
--- a/docs/qapi-code-gen.txt
+++ b/docs/qapi-code-gen.txt
@@ -743,7 +743,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)
--
2.4.3
- [Qemu-devel] [PATCH 02/26] qapi: Clean up cgen() and mcgen(), (continued)
- [Qemu-devel] [PATCH 02/26] qapi: Clean up cgen() and mcgen(), Markus Armbruster, 2015/08/04
- [Qemu-devel] [PATCH 07/26] qapi: Fix generated code when flat union has member 'kind', Markus Armbruster, 2015/08/04
- [Qemu-devel] [PATCH 20/26] qapi: Fix to reject union command and event arguments, Markus Armbruster, 2015/08/04
- [Qemu-devel] [PATCH 25/26] qapi-commands: Drop useless initialization,
Markus Armbruster <=
- [Qemu-devel] [PATCH 16/26] qapi: Document flaws in checking of names, Markus Armbruster, 2015/08/04
- [Qemu-devel] [PATCH 17/26] tests/qapi-schema: Restore test case for flat union base bug, Markus Armbruster, 2015/08/04
- [Qemu-devel] [PATCH 14/26] qapi: Document that input visitor semantics are prone to leaks, Markus Armbruster, 2015/08/04
- [Qemu-devel] [PATCH 19/26] qapi-tests: New tests for union, alternate command arguments, Markus Armbruster, 2015/08/04
- [Qemu-devel] [PATCH 03/26] qapi: Simplify guardname(), Markus Armbruster, 2015/08/04
- [Qemu-devel] [PATCH 13/26] tests/qapi-schema: Document events with base don't work, Markus Armbruster, 2015/08/04
- [Qemu-devel] [PATCH 09/26] qapi-visit: Fix generated code when schema has forward refs, Markus Armbruster, 2015/08/04
- [Qemu-devel] [PATCH 06/26] qapi: Drop unused and useless parameters and variables, Markus Armbruster, 2015/08/04