C++ does not allow designated initializers to refer to members of
anonymous unions. The QXLInterface struct contains an anonymous union
with attached_worker/attache_worker, and the original code used
`{ .attached_worker = attached_worker }` which mixed a non-designated
clause (the outer braces without a field name) with designated clauses
for the other struct members, producing:
error: either all initializer clauses should be designated or none
of them should be
Simply removing the braces (`.attached_worker = attached_worker`) does
not help either, because C++ compilers do not recognize anonymous union
members as valid designators at the enclosing struct level.
Work around this by using an immediately-invoked lambda: the designated
initializer list skips the anonymous union (which gets zero-initialized),
and the lambda assigns `attached_worker` explicitly before returning
the fully initialized struct.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Found with modernize-use-nullptr
NULL in C++ is 0 whereas it is a void pointer in C. Avoids implicit
conversions.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Acked-by: Frediano Ziglio <freddy77@gmail.com>
Fix this error reported by some older Gnu C++ compilers:
./server/tests/test-display-base.cpp:818:1: sorry, unimplemented: non-trivial designated initializers not supported
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This flag allows to catch variables or arguments hiding other
variables or attributes.
It helps avoiding some possible mistakes.
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@gmail.com>
Instead of including spice.h directly include an header that wraps
it. This allows to remove the SPICE_SERVER_INTERNAL define.
Currently is used to rename SpiceCharDeviceInstance to RedCharDevice
and reduce its visibility to hidden. This remove some warnings
and some weird code in the source.
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>