[igt-dev] tests: add missing braces around initializer

Petri Latvala petri.latvala at intel.com
Thu Jul 23 07:32:03 UTC 2020


On Wed, Jul 22, 2020 at 02:45:04PM +0300, Ville Syrjälä wrote:
> On Wed, Jul 22, 2020 at 10:56:03AM +0300, Petri Latvala wrote:
> > On Tue, Jul 21, 2020 at 11:15:21AM -0700, Carlos Santa wrote:
> > > In some sandboxes the toolchain complains about missing braces
> > > around initializer, however, adding an extra pair of braces
> > > fixes it, see below:
> > > 
> > > ../tests/kms_plane_cursor.c: In function '__real_main_302':
> > > ../tests/kms_plane_cursor.c:305:2 error: missing braces around initializer [-Werror=missing-braces]
> > > 	data_t data = { 0 };
> > > 
> > 
> > Argh, gcc.
> > 
> > C++ supports initializing with empty braces ( data_t data = {}; ) and
> > C doesn't,
> 
> It works just fine. We use it extensively all over.

Hmm, indeed.

Although we're both correct; that's a gcc extension. I can't find any
documentation about that, the closest I can find is
https://gcc.gnu.org/legacy-ml/gcc/2019-07/msg00066.html explaining
where it _probably_ comes from.

As we explicitly use std=gnu11, using empty brace initialization
instead of { 0 } sounds like the way forward here.


-- 
Petri Latvala


More information about the igt-dev mailing list