[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v6 14/23] qapi: Fix command with named empty argumen
From: |
Eric Blake |
Subject: |
[Qemu-devel] [PATCH v6 14/23] qapi: Fix command with named empty argument type |
Date: |
Wed, 25 Nov 2015 17:23:11 -0700 |
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. Without a fix to the generator, the
change to qapi-schema-test.json fails to compile with:
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;
^
Signed-off-by: Eric Blake <address@hidden>
---
v6: new patch
---
scripts/qapi-commands.py | 6 +++---
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, 12 insertions(+), 3 deletions(-)
diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py
index 561e47a..38cbffc 100644
--- a/scripts/qapi-commands.py
+++ b/scripts/qapi-commands.py
@@ -65,7 +65,7 @@ def gen_marshal_vars(arg_type, ret_type):
''',
c_type=ret_type.c_type())
- if arg_type:
+ if arg_type and not arg_type.is_empty():
ret += mcgen('''
QmpInputVisitor *qiv = qmp_input_visitor_new_strict(QOBJECT(args));
QapiDeallocVisitor *qdv;
@@ -97,7 +97,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 arg_type.is_empty():
return ret
if dealloc:
@@ -177,7 +177,7 @@ def gen_marshal(name, arg_type, ret_type):
# 'goto out' produced by gen_marshal_input_visit->gen_visit_fields()
# for each arg_type member, and by gen_call() for ret_type
- if (arg_type and arg_type.members) or ret_type:
+ if (arg_type and not arg_type.is_empty()) or ret_type:
ret += mcgen('''
out:
diff --git a/tests/qapi-schema/qapi-schema-test.json
b/tests/qapi-schema/qapi-schema-test.json
index 4b89527..a0fdb88 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 2c546b7..d8f9108 100644
--- a/tests/qapi-schema/qapi-schema-test.out
+++ b/tests/qapi-schema/qapi-schema-test.out
@@ -198,6 +198,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 9f35b80..b132775 100644
--- a/tests/test-qmp-commands.c
+++ b/tests/test-qmp-commands.c
@@ -12,6 +12,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] [PATCH v6 00/23] qapi visitor cleanups (post-introspection cleanups subset E), Eric Blake, 2015/11/25
- [Qemu-devel] [PATCH v6 04/23] qapi: Don't cast Enum* to int*, Eric Blake, 2015/11/25
- [Qemu-devel] [PATCH v6 03/23] qapi: Consolidate visitor integer callbacks, Eric Blake, 2015/11/25
- [Qemu-devel] [PATCH v6 02/23] qapi: Require int64/uint64 implementation, Eric Blake, 2015/11/25
- [Qemu-devel] [PATCH v6 06/23] qapi: Don't abuse stack to track qmp-output root, Eric Blake, 2015/11/25
- [Qemu-devel] [PATCH v6 05/23] qmp: Fix reference-counting of qnull on empty output visit, Eric Blake, 2015/11/25
- [Qemu-devel] [PATCH v6 01/23] qapi: Make all visitors supply int64/uint64 callbacks, Eric Blake, 2015/11/25
- [Qemu-devel] [PATCH v6 09/23] hmp: Improve use of qapi visitor, Eric Blake, 2015/11/25
- [Qemu-devel] [PATCH v6 11/23] ppc: Improve use of qapi visitors, Eric Blake, 2015/11/25
- [Qemu-devel] [PATCH v6 14/23] qapi: Fix command with named empty argument type,
Eric Blake <=
- [Qemu-devel] [PATCH v6 16/23] qapi: Track all failures between visit_start/stop, Eric Blake, 2015/11/25
- [Qemu-devel] [PATCH v6 10/23] vl: Improve use of qapi visitor, Eric Blake, 2015/11/25
- [Qemu-devel] [PATCH v6 13/23] qapi: Add type.is_empty() helper, Eric Blake, 2015/11/25
- [Qemu-devel] [PATCH v6 15/23] qapi: Improve generated event use of qapi visitor, Eric Blake, 2015/11/25
- [Qemu-devel] [PATCH v6 19/23] qapi-visit: Unify struct and union visit, Eric Blake, 2015/11/25
- [Qemu-devel] [PATCH v6 18/23] qapi: Canonicalize missing object to :empty, Eric Blake, 2015/11/25
- [Qemu-devel] [PATCH v6 23/23] qapi: Change visit_type_FOO() to no longer return partial objects, Eric Blake, 2015/11/25
- [Qemu-devel] [PATCH v6 22/23] qapi: Split visit_end_struct() into pieces, Eric Blake, 2015/11/25
- [Qemu-devel] [PATCH v6 12/23] balloon: Improve use of qapi visitor, Eric Blake, 2015/11/25
- [Qemu-devel] [PATCH v6 07/23] qapi: Document visitor interfaces, Eric Blake, 2015/11/25