From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Petri Latvala <petri.latvala@intel.com>
Cc: igt-dev@lists.freedesktop.org
Subject: Re: [igt-dev] tests: add missing braces around initializer
Date: Wed, 22 Jul 2020 14:45:04 +0300 [thread overview]
Message-ID: <20200722114504.GC6112@intel.com> (raw)
In-Reply-To: <20200722075603.GR20883@platvala-desk.ger.corp.intel.com>
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.
> leaving only the commonly used { 0 } idiom to mean "I just
> want to zero-initialize this object, don't care about the
> structure". Even better, due to the brace elision clause in the spec,
> that construct is fully defined and means exactly fully
> zero-initializing the aggregate object regardless of its structure.
>
> I could agree with this change if the initialization used non-zero
> values but just adding braces to make the compiler believe you really
> meant this...
>
> I wonder if playing around with -Wmissing-initializer
> -Wno-missing-braces lets us leave the code as { 0 } for elegance,
> while still get a warning for actual incorrect use...
>
> Which version of gcc was this on?
>
>
> --
> Petri Latvala
> _______________________________________________
> igt-dev mailing list
> igt-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/igt-dev
--
Ville Syrjälä
Intel
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next prev parent reply other threads:[~2020-07-22 11:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-21 18:15 [igt-dev] tests: add missing braces around initializer Carlos Santa
2020-07-21 18:43 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2020-07-21 23:19 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2020-07-22 7:56 ` [igt-dev] " Petri Latvala
2020-07-22 11:45 ` Ville Syrjälä [this message]
2020-07-23 7:32 ` Petri Latvala
2020-07-23 15:35 ` Carlos Santa
2020-07-23 15:29 ` Carlos Santa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200722114504.GC6112@intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=petri.latvala@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox