[Spice-devel] [PATCH server] tests: Initialize all members of SpiceBaseInterface struct
Frediano Ziglio
fziglio at redhat.com
Thu Jun 22 15:20:27 UTC 2017
>
> When compiling, -Werror=missing-field-initializers is enabled.
> However, gcc fails to see that all the members of the
> SpiceBaseInterface struct are initialized:
>
> test-display-base.c:844:5: error: missing initializer for field
> 'description' of 'SpiceBaseInterface'
> [-Werror=missing-field-initializers] .base.description = "test
> spice virtual channel char device",
>
In my environment it compile without problems. Which compiler
and version are you using? Can you add this information to the
commit message?
> The solution is to initialize .base member as a structure at once
> instead of multiple times per each member.
>
> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> ---
> server/tests/test-display-base.c | 10 ++++++----
> server/tests/test-leaks.c | 10 ++++++----
> server/tests/test-playback.c | 10 ++++++----
> server/tests/test-vdagent.c | 10 ++++++----
> 4 files changed, 24 insertions(+), 16 deletions(-)
>
> diff --git a/server/tests/test-display-base.c
> b/server/tests/test-display-base.c
> index 636c505c..88638bde 100644
> --- a/server/tests/test-display-base.c
> +++ b/server/tests/test-display-base.c
> @@ -840,10 +840,12 @@ static void vmc_state(SPICE_GNUC_UNUSED
> SpiceCharDeviceInstance *sin,
>
>
> static SpiceCharDeviceInterface vdagent_sif = {
> - .base.type = SPICE_INTERFACE_CHAR_DEVICE,
> - .base.description = "test spice virtual channel char device",
> - .base.major_version = SPICE_INTERFACE_CHAR_DEVICE_MAJOR,
> - .base.minor_version = SPICE_INTERFACE_CHAR_DEVICE_MINOR,
> + .base = {
> + .type = SPICE_INTERFACE_CHAR_DEVICE,
> + .description = "test spice virtual channel char device",
> + .major_version = SPICE_INTERFACE_CHAR_DEVICE_MAJOR,
> + .minor_version = SPICE_INTERFACE_CHAR_DEVICE_MINOR,
> + },
> .state = vmc_state,
> .write = vmc_write,
> .read = vmc_read,
> diff --git a/server/tests/test-leaks.c b/server/tests/test-leaks.c
> index 4985a1e3..74ab2afd 100644
> --- a/server/tests/test-leaks.c
> +++ b/server/tests/test-leaks.c
> @@ -88,10 +88,12 @@ static void vmc_state(SPICE_GNUC_UNUSED
> SpiceCharDeviceInstance *sin,
> }
>
> static SpiceCharDeviceInterface vmc_interface = {
> - .base.type = SPICE_INTERFACE_CHAR_DEVICE,
> - .base.description = "test spice virtual channel char device",
> - .base.major_version = SPICE_INTERFACE_CHAR_DEVICE_MAJOR,
> - .base.minor_version = SPICE_INTERFACE_CHAR_DEVICE_MINOR,
> + .base = {
> + .type = SPICE_INTERFACE_CHAR_DEVICE,
> + .description = "test spice virtual channel char device",
> + .major_version = SPICE_INTERFACE_CHAR_DEVICE_MAJOR,
> + .minor_version = SPICE_INTERFACE_CHAR_DEVICE_MINOR,
> + },
> .state = vmc_state,
> .write = vmc_write,
> .read = vmc_read,
> diff --git a/server/tests/test-playback.c b/server/tests/test-playback.c
> index bad11a00..9e53e322 100644
> --- a/server/tests/test-playback.c
> +++ b/server/tests/test-playback.c
> @@ -37,10 +37,12 @@
> SpicePlaybackInstance playback_instance;
>
> static const SpicePlaybackInterface playback_sif = {
> - .base.type = SPICE_INTERFACE_PLAYBACK,
> - .base.description = "test playback",
> - .base.major_version = SPICE_INTERFACE_PLAYBACK_MAJOR,
> - .base.minor_version = SPICE_INTERFACE_PLAYBACK_MINOR,
> + .base = {
> + .type = SPICE_INTERFACE_PLAYBACK,
> + .description = "test playback",
> + .major_version = SPICE_INTERFACE_PLAYBACK_MAJOR,
> + .minor_version = SPICE_INTERFACE_PLAYBACK_MINOR,
> + }
> };
>
> uint32_t *frame;
> diff --git a/server/tests/test-vdagent.c b/server/tests/test-vdagent.c
> index e1d8b82c..232e9824 100644
> --- a/server/tests/test-vdagent.c
> +++ b/server/tests/test-vdagent.c
> @@ -94,10 +94,12 @@ static void vmc_state(SPICE_GNUC_UNUSED
> SpiceCharDeviceInstance *sin,
> }
>
> static SpiceCharDeviceInterface vmc_interface = {
> - .base.type = SPICE_INTERFACE_CHAR_DEVICE,
> - .base.description = "test spice virtual channel char device",
> - .base.major_version = SPICE_INTERFACE_CHAR_DEVICE_MAJOR,
> - .base.minor_version = SPICE_INTERFACE_CHAR_DEVICE_MINOR,
> + .base = {
> + .type = SPICE_INTERFACE_CHAR_DEVICE,
> + .description = "test spice virtual channel char device",
> + .major_version = SPICE_INTERFACE_CHAR_DEVICE_MAJOR,
> + .minor_version = SPICE_INTERFACE_CHAR_DEVICE_MINOR,
> + },
> .state = vmc_state,
> .write = vmc_write,
> .read = vmc_read,
Patch looks fine
Frediano
More information about the Spice-devel
mailing list