[PATCH 2/2] first stab at NOFORK applet support

Denis Vlasenko vda at ilport.com.ua
Fri May 12 15:50:22 UTC 2006


On Thursday 11 May 2006 17:57, Rob Landley wrote:
> On Wednesday 10 May 2006 2:36 am, Denis Vlasenko wrote:
> > > Manually maintained black magic is the worst kind.  It's ok if you do it
> > > once and it works for all users.  At the very least if the build breaks
> > > if you don't do it right in such a way that you get an obvious and
> > > preferably informative error message.
> >
> > What kind of breakage do you have in mind? A missed bss object?
> > Or incorrect BSS_SIZE_sed value?
> 
> Just generally having the sizes wrong.  I'm all for build time breakage, 
> because we notice that before it eats anybody's data or gets deployed and 
> fails in the field.  Run-time breakage has a chance to actually ship, which 
> would suck.

I agree, and that's why I have that CHECK_BSS_SIZE macro:

+#define CHECK_BSS_SIZE(applet) \
+       do { \
+       if(sizeof(struct BSSDATA) > BSS_SIZE_##applet) BUG_wrong_bss_size(); \
+       if(sizeof(struct BSSDATA) > BSS_BUFFER_MAXSIZE) BUG_bss_buffer_too_small(); \
+       } while(0)

If someone will specify BSS_SIZE_sed smaller than actual size of
sed's bss data, it will fail to link.

Add another if:
        if(sizeof(struct BSSDATA) < BSS_SIZE_##applet + 128) BUG_bss_size_too_large();

and you will catch BSS_SIZEs which a significantly bigger than sed needs.

It's a bit ugly, yes, but it allows to NOT move variable declarations
out of sed.c into some centralized place (that place is bound to become
one big mess of structs and variables from dozens of unrelated applets).
--
vda



More information about the busybox mailing list