On Thu, Mar 16, 2023 at 08:13:24AM +0100, Markus Armbruster wrote: > The generated member visit neglects to emit #if around a conditional > struct member's has_ variable. For instance, > tests/qapi-schema/qapi-schema-test.json generates > > #if defined(TEST_IF_STRUCT) > bool visit_type_TestIfStruct_members(Visitor *v, TestIfStruct *obj, Error > **errp) > { > ---> bool has_baz = !!obj->baz; > ... > > Won't compile when TEST_IF_STRUCT is defined and TEST_IF_STRUCT_MEMBER > isn't. > > Fix that the obvious way: > > #if defined(TEST_IF_STRUCT_MEMBER) > bool has_baz = !!obj->baz; > #endif /* defined(TEST_IF_STRUCT_MEMBER) */ > > Fixes: 44ea9d9be33c (qapi: Start to elide redundant has_FOO in generated C) > Signed-off-by: Marc-André Lureau <marcandre.lur...@redhat.com> > Signed-off-by: Markus Armbruster <arm...@redhat.com> > --- > scripts/qapi/visit.py | 2 ++ > 1 file changed, 2 insertions(+)
Reviewed-by: Eric Blake <ebl...@redhat.com> -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org