Re: [libvirt] [PATCH] Remove MAX_TAP_ID, take 3

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Matthias Bolte wrote:  [Thu Jul 30 2009, 06:04:40AM EDT]
> 2009/7/30 Mark McLoughlin <markmc@xxxxxxxxxx>:
> > 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

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]