[BusyBox] Applet Hashing for Busybox

Gaute B Strokkenes gs234 at cam.ac.uk
Tue Oct 24 19:30:06 UTC 2000


Mark Whitley <markw at lineo.com> writes:

> On Tue, Oct 24, 2000 at 12:35:32PM +0100, Gaute B Strokkenes wrote:
> 
> > > All the same, it would probably be good to have a tool that could
> > > check the applet list or even generate an alphabetized list, just to
> > > make sure that everything's set up properly.
> 
> True. Actually, now that I look at your patch again, I see that you've
> obviated one of the reasons for needing a pre-processing helper app: getting
> the size of the array. With your line:
> 
> #define NUM_APPLETS (sizeof(applets) / sizeof(struct BB_applet) -1)

Standard trick.

> I don't think any compile-time checking would need to be done at all.
> 
> > I think it would be sufficient to have main() go through the array and
> > check that everything is in proper order, and only include this code
> > when doing non-debug builds.
> 
> Hmmm... I'm not so sure I like the idea of putting that stuff into busybox
> itself. BUT if it's in the debug build only... Hmmm. Still not sure. I think
> I'd be more inclined to have an auxillary shell script / C proggie that could
> do the checking independently of busybox.

Hm.  It's only seven lines or so:

#ifdef DEBUG
struct BB_applet *a = applets;

while (a[0].name && a[1].name) {
        if (strcmp (a[0].name, a[1].name) >= 0)
                die_crash_burn();
        a++;
}
#endif

It just seems simpler than mucking about with the build process, but
you're probably in a better position than me to judge.

I don't really think it's necessary at all, though.  If people break
the ordering they will certainly notice when they can't run their
applets anymore.

> All things considered, though, I like your binary search approach
> better than my hashing one. In short, your patch wins.

Thanks. 8-)

> The only other thing I'd like to do is break out the listing of applets from
> busybox.c into applets.h; I think that would be better organized. In addition
> to making it more obvious where the listing of applets is, I could also put a
> big nasty message at the top of the file that says: "This file is to remain
> alphabetized at all times! If anyone breaks the alphabetization, we will hunt
> you down and kill you!" or something equally dreadful.

"If you value your kneecaps, ..."

> So, unless you have any other comments / code to add I'll apply your patch to
> busybox, break out the applets into applets.h and check it all in to CVS.

Well, applets.h sounds like an include file, but the applets list is
an array.  Putting concrete variables etc. in an include file is
evil(tm), and a classic way to shoot yourself in the foot.  I would
put it in a .c file, but it's your program.

-- 
Gaute Strokkenes
Dehydrated EGGS are STREWN across ROULETTE TABLES..





More information about the busybox mailing list