diff --git a/qemu/scripts/qapi-event.py b/qemu/scripts/qapi-event.py index afdf9015..10ad7bb1 100644 --- a/qemu/scripts/qapi-event.py +++ b/qemu/scripts/qapi-event.py @@ -68,7 +68,7 @@ def gen_event_send(name, arg_type): ''', proto=gen_event_send_proto(name, arg_type)) - if arg_type and arg_type.members: + if arg_type and not arg_type.is_empty(): assert not arg_type.variants ret += mcgen(''' QObject *obj; @@ -88,7 +88,7 @@ def gen_event_send(name, arg_type): ''', name=name) - if arg_type and arg_type.members: + if arg_type and not arg_type.is_empty(): ret += mcgen(''' v = qmp_output_visitor_new(&obj); @@ -116,7 +116,7 @@ def gen_event_send(name, arg_type): ''', c_enum=c_enum_const(event_enum_name, name)) - if arg_type and arg_type.members: + if arg_type and not arg_type.is_empty(): ret += mcgen(''' out: visit_free(v); diff --git a/qemu/scripts/qapi-types.py b/qemu/scripts/qapi-types.py index 7fba35db..4aca34e1 100644 --- a/qemu/scripts/qapi-types.py +++ b/qemu/scripts/qapi-types.py @@ -89,7 +89,7 @@ struct %(c_name)s { # potential issues with attempting to malloc space for zero-length # structs in C, and also incompatibility with C++ (where an empty # struct is size 1). - if not (base and base.members) and not members and not variants: + if (not base or base.is_empty()) and not members and not variants: ret += mcgen(''' char qapi_dummy_for_empty_struct; ''') diff --git a/qemu/scripts/qapi.py b/qemu/scripts/qapi.py index b897b560..9e700afa 100644 --- a/qemu/scripts/qapi.py +++ b/qemu/scripts/qapi.py @@ -1005,6 +1005,10 @@ class QAPISchemaObjectType(QAPISchemaType): # _def_predefineds() return self.name.startswith('q_') + def is_empty(self): + assert self.members is not None + return not self.members and not self.variants + def c_name(self): assert self.name != 'q_empty' return QAPISchemaType.c_name(self)