[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 02/15] qapi: Fix command with named empty argument ty
From: |
Markus Armbruster |
Subject: |
[Qemu-devel] [PULL 02/15] qapi: Fix command with named empty argument type |
Date: |
Fri, 18 Mar 2016 11:04:16 +0100 |
From: Eric Blake <address@hidden>
The generator special-cased
{ 'command':'foo', 'data': {} }
to avoid emitting a visitor variable, but failed to see that
{ 'struct':'NamedEmptyType, 'data': {} }
{ 'command':'foo', 'data':'NamedEmptyType' }
needs the same treatment. There, the generator happily generates a
visitor to get no arguments, and a visitor to destroy no arguments;
and the compiler isn't happy with that, as demonstrated by the updated
qapi-schema-test.json:
tests/test-qmp-marshal.c: In function ‘qmp_marshal_user_def_cmd0’:
tests/test-qmp-marshal.c:264:14: error: variable ‘v’ set but not used
[-Werror=unused-but-set-variable]
Visitor *v;
^
No change to generated code except for the testsuite addition.
Signed-off-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>
---
scripts/qapi-commands.py | 4 ++--
tests/qapi-schema/qapi-schema-test.json | 2 ++
tests/qapi-schema/qapi-schema-test.out | 2 ++
tests/test-qmp-commands.c | 5 +++++
4 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py
index edcbd10..3784f33 100644
--- a/scripts/qapi-commands.py
+++ b/scripts/qapi-commands.py
@@ -66,7 +66,7 @@ def gen_marshal_vars(arg_type, ret_type):
''',
c_type=ret_type.c_type())
- if arg_type:
+ if arg_type and arg_type.members:
ret += mcgen('''
QmpInputVisitor *qiv = qmp_input_visitor_new_strict(QOBJECT(args));
QapiDeallocVisitor *qdv;
@@ -98,7 +98,7 @@ def gen_marshal_vars(arg_type, ret_type):
def gen_marshal_input_visit(arg_type, dealloc=False):
ret = ''
- if not arg_type:
+ if not arg_type or not arg_type.members:
return ret
if dealloc:
diff --git a/tests/qapi-schema/qapi-schema-test.json
b/tests/qapi-schema/qapi-schema-test.json
index 728659e..e722748 100644
--- a/tests/qapi-schema/qapi-schema-test.json
+++ b/tests/qapi-schema/qapi-schema-test.json
@@ -18,6 +18,8 @@
{ 'struct': 'Empty1', 'data': { } }
{ 'struct': 'Empty2', 'base': 'Empty1', 'data': { } }
+{ 'command': 'user_def_cmd0', 'data': 'Empty2', 'returns': 'Empty2' }
+
# for testing override of default naming heuristic
{ 'enum': 'QEnumTwo',
'prefix': 'QENUM_TWO',
diff --git a/tests/qapi-schema/qapi-schema-test.out
b/tests/qapi-schema/qapi-schema-test.out
index f5e2a73..f531961 100644
--- a/tests/qapi-schema/qapi-schema-test.out
+++ b/tests/qapi-schema/qapi-schema-test.out
@@ -203,6 +203,8 @@ command guest-sync :obj-guest-sync-arg -> any
gen=True success_response=True
command user_def_cmd None -> None
gen=True success_response=True
+command user_def_cmd0 Empty2 -> Empty2
+ gen=True success_response=True
command user_def_cmd1 :obj-user_def_cmd1-arg -> None
gen=True success_response=True
command user_def_cmd2 :obj-user_def_cmd2-arg -> UserDefTwo
diff --git a/tests/test-qmp-commands.c b/tests/test-qmp-commands.c
index d6171f2..650ba46 100644
--- a/tests/test-qmp-commands.c
+++ b/tests/test-qmp-commands.c
@@ -13,6 +13,11 @@ void qmp_user_def_cmd(Error **errp)
{
}
+Empty2 *qmp_user_def_cmd0(Error **errp)
+{
+ return g_new0(Empty2, 1);
+}
+
void qmp_user_def_cmd1(UserDefOne * ud1, Error **errp)
{
}
--
2.4.3
- [Qemu-devel] [PULL 00/15] QAPI patches for 2016-03-18, Markus Armbruster, 2016/03/18
- [Qemu-devel] [PULL 01/15] qapi: Assert in places where variants are not handled, Markus Armbruster, 2016/03/18
- [Qemu-devel] [PULL 14/15] qapi: Allow anonymous base for flat union, Markus Armbruster, 2016/03/18
- [Qemu-devel] [PULL 08/15] qapi-commands: Utilize implicit struct visits, Markus Armbruster, 2016/03/18
- [Qemu-devel] [PULL 06/15] qapi-event: Drop qmp_output_get_qobject() null check, Markus Armbruster, 2016/03/18
- [Qemu-devel] [PULL 04/15] qapi: Adjust names of implicit types, Markus Armbruster, 2016/03/18
- [Qemu-devel] [PULL 10/15] qapi: Inline gen_visit_members() into lone caller, Markus Armbruster, 2016/03/18
- [Qemu-devel] [PULL 15/15] qapi: Use anonymous bases in QMP flat unions, Markus Armbruster, 2016/03/18
- [Qemu-devel] [PULL 02/15] qapi: Fix command with named empty argument type,
Markus Armbruster <=
- [Qemu-devel] [PULL 11/15] qapi: Drop unused c_null(), Markus Armbruster, 2016/03/18
- [Qemu-devel] [PULL 13/15] qapi: Make BlockdevOptions doc example closer to reality, Markus Armbruster, 2016/03/18
- [Qemu-devel] [PULL 09/15] qapi-commands: Inline single-use helpers of gen_marshal(), Markus Armbruster, 2016/03/18
- [Qemu-devel] [PULL 03/15] qapi: Make c_type() more OO-like, Markus Armbruster, 2016/03/18
- [Qemu-devel] [PULL 05/15] qapi: Emit implicit structs in generated C, Markus Armbruster, 2016/03/18
- [Qemu-devel] [PULL 07/15] qapi-event: Utilize implicit struct visits, Markus Armbruster, 2016/03/18
- [Qemu-devel] [PULL 12/15] qapi: Don't special-case simple union wrappers, Markus Armbruster, 2016/03/18
- Re: [Qemu-devel] [PULL 00/15] QAPI patches for 2016-03-18, Peter Maydell, 2016/03/18