Matthias Bolte wrote: [Thu Jul 30 2009, 06:04:40AM EDT]
2009/7/30 Mark McLoughlin <markmc(a)redhat.com>:
> On Thu, 2009-07-30 at 02:58 +0200, Matthias Bolte wrote:
>>
>> The follow change makes GCC happy again:
>>
>> - struct ifreq ifr = {0};
>> + struct ifreq ifr = {{{0}}, {{0, {0}}}};
>
> AFAIR, this works?
>
> struct ifreq ifr = {0,};
>
> Cheers,
> Mark.
>
No, it doesn't, I tested it. The problem is the internal structure of
ifreq. GCC complains until the initializer matches this structure. Or
use memset like all other bridge functions do:
struct ifreq ifr;
memset(&ifr, 0, sizeof(struct ifreq));
It's unfortunate, really... In general, one would prefer to ask
the compiler for a zeroed structure on the stack than to call
memset, which clutters the code and reduces the opportunity for
the compiler to optimize. For arrays, {0} works with -Wall
-Werror; the unspecified elements are zeroed. But it looks like
there's no simple zero-initializer for structs.
Aron