[pisa-src] Re: r1765 - trunk/pisacd/cdservers.c

  • From: Diego Biurrun <diego@xxxxxxxxxx>
  • To: pisa-src@xxxxxxxxxxxxx
  • Date: Wed, 25 Nov 2009 15:51:09 +0100

On Wed, Nov 25, 2009 at 09:29:11AM +0100, Tobias Heer wrote:
> 
> Am 24.11.2009 um 15:48 schrieb Thomas Jansen:
> 
> >     if (!pisa_servers_lookup_dns(dn, &hit, &remote))
> >             goto failed;
> > 
> > -   /* TODO: If no conmgr entry exists we have to build one... */
> > -   if (!(entry = pisa_conmgr_findby_hit(cd_ctx.conlist, &hit)))
> > -           goto failed;
> > -   pisa_nat_upgrade_preliminary(cd_ctx.natlist, nat, &remote, entry, NULL);
> > +   /* Find an existing conmgr entry for the service gateway or create a
> > +    * new one */
> > +   entry = pisa_conmgr_findby_hit(cd_ctx.conlist, &hit);
> > +   if (!entry) {
> > +           entry = pisa_conmgr_add(cd_ctx.conlist, &hit, 
> > PISASD_DEFAULT_PORTNUM_CONTROL, type);
> > +           if (!entry)
> > +                   goto failed;
> > +   }
> > 
> > +   pisa_nat_upgrade_preliminary(cd_ctx.natlist, nat, &remote, entry, NULL);
> >     return;
> > 
> > failed:
>
> Ain't there a better way to do error handling here? I never really
> liked the goto jumps in HIPL but this kind of takes it to the extreme.
> I guess one could put all of these into one big if statement but that
> wouldn't make it much nicer either.

You never heard what Linus had to say about goto statements in the Linux
kernel?  It's a nice rant and a fun read, so follow this link:

http://lkml.org/lkml/2003/1/12/151

money quote: 

  > However, I have always been taught, and have always believed that
  > "goto"s are inherently evil.  They are the creators of spaghetti code

  No, you've been brainwashed by CS people who thought that Niklaus Wirth
  actually knew what he was talking about. He didn't. He doesn't have a
  frigging clue.

:)

Diego

Other related posts: