[BusyBox] Clean up

Jason Schoon floydpink at gmail.com
Tue Jul 26 08:09:57 MDT 2005


That was basically my original idea, but Rob pointed out that
multiline blocks are really messy in that scenario.

I think from a preprocessor and compiler standpoint it is all cool,
but you will make some people scratch their heads the first time they
see:

CLEAN_UP({free(foo); close(sockfd)});

Curly braces inside of parens just isn't something you generally see.



On 7/26/05, Tito <farmatito at tiscali.it> wrote:
> Hi,
> This is just a horrible solution for the clean up problem but:
> 
> 1) it allows multiline blocks
> 2) the code is not compiled if the config option is not set
> 3) doesn't need an if
> 4) doesn't need variables to be set
> 5) it looks bad
> 6) nobody will like it.
> 
> in config.h
> 
> #define CONFIG_FEATURE_CLEAN_UP
> 
> in busybox.h
> 
> #ifdef CONFIG_FEATURE_CLEAN_UP
> #define CLEAN_UP(x)             x
> #else
> #define CLEAN_UP(x)
> #endif
> 
> So in the ifconfig.c case it would look like:
> 
> > --- networking/ifconfig.c
> > +++ networking/ifconfig.c
> > @@ -558,6 +558,9 @@
> > continue;
> > } /* end of while-loop */
> >
> > +CLEAN_UP(close(sockfd));
> > return goterr;
> > }
> 
> CAVEAT: This is untested and maybe doesn't work at all,
>                  just an idea.
>                  If somebody is interested I can try if it work.
>                  if somebody knows that it doesn't work please
>                  tell me, so I'll learn the lesson and spare time.
> 
> Ciao,
> Tito
> 
> 
> _______________________________________________
> busybox mailing list
> busybox at mail.busybox.net
> http://busybox.net/mailman/listinfo/busybox
> 
> 
>


More information about the busybox mailing list