Browse Source
The C code generator fails to honor 'if' conditions of command and
event arguments.
For instance, tests/qapi-schema/qapi-schema-test.json has
{ 'event': 'TEST_IF_EVENT',
'data': { 'foo': 'TestIfStruct',
'bar': { 'type': ['str'], 'if': 'TEST_IF_EVT_ARG' } },
'if': { 'all': ['TEST_IF_EVT', 'TEST_IF_STRUCT'] } }
Generated tests/test-qapi-events.h fails to honor the TEST_IF_EVT_ARG
condition:
#if defined(TEST_IF_EVT) && defined(TEST_IF_STRUCT)
void qapi_event_send_test_if_event(TestIfStruct *foo, strList *bar);
#endif /* defined(TEST_IF_EVT) && defined(TEST_IF_STRUCT) */
Only uses so far are in tests/.
We could fix the generator to emit something like
#if defined(TEST_IF_EVT) && defined(TEST_IF_STRUCT)
void qapi_event_send_test_if_event(TestIfStruct *foo
#if defined(TEST_IF_EVT_ARG)
, strList *bar
#endif
);
#endif /* defined(TEST_IF_EVT) && defined(TEST_IF_STRUCT) */
Ugly. Calls become similarly ugly. Not worth fixing.
Conditional arguments work fine with 'boxed': true, simply because
complex types with conditional members work fine. Not worth breaking.
Reject conditional arguments unless boxed.
Move the tests cases covering unboxed conditional arguments out of
tests/qapi-schema/qapi-schema-test.json. Cover boxed conditional
arguments there instead.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20230316071325.492471-15-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
pull/235/head
16 changed files with 48 additions and 22 deletions
@ -0,0 +1,2 @@ |
|||
args-if-implicit.json: In command 'test-if-cmd': |
|||
args-if-implicit.json:1: conditional command arguments require 'boxed': true |
|||
@ -0,0 +1,4 @@ |
|||
{ 'command': 'test-if-cmd', |
|||
'data': { |
|||
'foo': 'int', |
|||
'bar': { 'type': 'str', 'if': 'TEST_IF_CMD_ARG' } } } |
|||
@ -0,0 +1,2 @@ |
|||
args-if-unboxed.json: In command 'test-if-cmd': |
|||
args-if-unboxed.json:5: conditional command arguments require 'boxed': true |
|||
@ -0,0 +1,6 @@ |
|||
{ 'struct': 'TestIfCmdArgs', |
|||
'data': { |
|||
'foo': 'int', |
|||
'bar': { 'type': 'str', 'if': 'TEST_IF_CMD_ARG' } } } |
|||
{ 'command': 'test-if-cmd', |
|||
'data': 'TestIfCmdArgs' } |
|||
@ -0,0 +1,2 @@ |
|||
tests/qapi-schema/event-args-if-unboxed.json: In event 'TEST_IF_EVENT': |
|||
tests/qapi-schema/event-args-if-unboxed.json:1: event's 'data' members may have 'if' conditions only with 'boxed': true |
|||
@ -0,0 +1,4 @@ |
|||
{ 'event': 'TEST_IF_EVENT', |
|||
'data': { |
|||
'foo': 'int', |
|||
'bar': { 'type': 'str', 'if': 'TEST_IF_CMD_ARG' } } } |
|||
Loading…
Reference in new issue