On Thu, Jan 05, 2023 at 11:09:57AM +0100, Theo Buehler wrote:
> On Thu, Jan 05, 2023 at 11:03:04AM +0100, Claudio Jeker wrote:
> > gcc4 does not really support C99 initalizers. It works most of the time
> > but fails for more complex structs. Just fall back to memset() here.
> 
> deraadt used { {0} } in kr_send_dependon(). Apparently that works.
> I really don't understand why we can't use a 24 years old standard.

It is very annoying. Would be nice if our gcc would allow it since c99
initalizers are a good thing. Not sure I like the { { 0 } } fix. Another
option is to init a specific value e.g.
        struct bgpd_addr gateway = { .aid = 0 };
but again this is just an ugly workaround.

We could silence the warning in gcc but I'm not a big fan of that since
        struct bgpd_addr gateway = { 1 };
should get us a warning.
gcc fixed this in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64709
but the code was already quite different to what we have.

As a third option one could use the C23
        struct bgpd_addr gateway = { };
This seems to work with our gcc and llvm.
 
> > -- 
> > :wq Claudio
> > 
> > Index: kroute.c
> > ===================================================================
> > RCS file: /cvs/src/usr.sbin/bgpd/kroute.c,v
> > retrieving revision 1.303
> > diff -u -p -r1.303 kroute.c
> > --- kroute.c        28 Dec 2022 21:30:16 -0000      1.303
> > +++ kroute.c        5 Jan 2023 09:55:39 -0000
> > @@ -2159,10 +2159,12 @@ kroute6_validate(struct kroute6 *kr)
> >  int
> >  knexthop_true_nexthop(struct ktable *kt, struct kroute_full *kf)
> >  {
> > -   struct bgpd_addr gateway = { 0 };
> > +   struct bgpd_addr gateway;
> >     struct knexthop *kn;
> >     struct kroute   *kr;
> >     struct kroute6  *kr6;
> > +
> > +   memset(&gateway, 0, sizeof(gateway));
> >  
> >     /*
> >      * Ignore the nexthop for VPN routes. The gateway is forced
> > 
> 

-- 
:wq Claudio

Reply via email to