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

  • From: Tobias Heer <heer@xxxxxxxxxxxxxxxxx>
  • To: pisa-src@xxxxxxxxxxxxx
  • Date: Wed, 25 Nov 2009 09:29:11 +0100

Am 24.11.2009 um 15:48 schrieb Thomas Jansen:

> +     /* Look up the service in DNS */
>       if (!pisa_servers_build_domain_name(&nat->local_private, dn, 
> sizeof(dn)))
>               goto failed;
>       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.

In addition I really don't like the omission of braces for one-line if 
statements. This is quite error-prone, especially if people who have not 
written the code continue to work with it. I kon it is syntactically correct 
and it is slightly shorter but it is often the source of errors that are hard 
to find.

Tobias



--  

Dipl.-Inform. Tobias Heer, Ph.D. Student
Distributed Systems Group 
RWTH Aachen University, Germany
tel: +49 241 80 207 76
web: http://ds.cs.rwth-aachen.de/members/heer








Other related posts: