[Spice-devel] [PATCH server] tests: Initialize all members of SpiceBaseInterface struct

Frediano Ziglio fziglio at redhat.com
Fri Jun 23 08:58:47 UTC 2017



----- Original Message -----
> From: "Michal Privoznik" <mprivozn at redhat.com>
> To: "Frediano Ziglio" <fziglio at redhat.com>
> Cc: spice-devel at lists.freedesktop.org
> Sent: Thursday, June 22, 2017 4:39:07 PM
> Subject: Re: [Spice-devel] [PATCH server] tests: Initialize all members of SpiceBaseInterface struct
> 
> On 06/22/2017 05:20 PM, Frediano Ziglio wrote:
> >>
> >> 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?
> 
> Sure:
> 
> $ gcc --version
> gcc (Gentoo 4.9.4 p1.0, pie-0.6.4) 4.9.4
> Copyright (C) 2015 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> 
> Also, this is a gentoo box. I don't have a commit rights, so do you want me
> to update the commit message and resend? Or will the commiter fix this
> before pushing?
> 
> Michal
> 

You can update and post again or I can change before pushing it.

What about, simply:
******
When compiling, -Werror=missing-field-initializers is enabled.
However, some gcc versions (like Gentoo 4.9.4 one) fail 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",

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>
******

Frediano


More information about the Spice-devel mailing list