implenting BB variations of standard system calls

Robert P. J. Day rpjday at mindspring.com
Thu Apr 20 12:08:37 UTC 2006


On Thu, 20 Apr 2006, Tito wrote:

> On Thursday 20 April 2006 12:18, Robert P. J. Day wrote:
> > On Thu, 20 Apr 2006, Denis Vlasenko wrote:
>
> >   struct passwd* getpwuid(const char* name) ;
> >   char *bb_getpwuid(char *name, long uid, int bufsize)
> >
> > now you have people who might be familiar with the semantics of
> > getpwuid() looking at the semantics for bb_getpwuid() and
> > thinking, "what the hell?? ..."
>
> That's why the functions are extensively commented in source code.

you don't deal with badly-designed semantics by commenting them
extensively.  you deal with them by rewriting them so they don't
*need* extensive commenting.

as a real-life example, i'm willing to bet that there are people who,
even after years of using certain linux commands, still have to take a
second or two to recall how to use them properly.  for instance, "ln",
and i'm sure there are other examples.  and the reason some of these
commands always throw even long-time users is that their semantics are
sometimes just *horrible*, and having an easily-accessible man page
doesn't make that issue go away.

(most of you know *exactly* what i'm talking about.  you frequently
hear people say something like, "darn, i can never remember how to
call that function.  let me check the man page."  that's because that
function's semantics *suck*.)

what is so psychologically difficult about designing something cleanly
and meaningfully the first time?  or, if you realize you didn't do it
right the first time, *fixing* it?

> > if you choose to define a BB variation of a non-BB routine like
> > that, it makes sense to try to mimic the semantics.
>
> As much as possible, but remember that our goal is size reduction so
> sometimes a little variation of the semantics achieves a better
> flexibility of the function.

not to sound edgy or anything but i'm getting *really* tired of
hearing that lame excuse brought up again and again.  at some point,
there is no longer any value in screwing up code for the sake of
saving a few bytes.

you want to save bytes?  here, i have a suggestion on how to save
*lots* of bytes.  remove *all* error-checking from busybox.  bytes
saved.  are you OK with that suggestion?  no?  why not?  i just
saved you piles of bytes.  what's the problem?

> > if, however, you really do want/need to change the semantics
> > drastically, then give the routine a name that makes it clear it's
> > *different* and in no way associated with the original.  perhaps
> > something like "map_username_to_uid()" or something like that.
>
> Feel free to change the name to something more appropriate..... but
> this will cause more confusion to developers already used to this
> functions and semantics.....

you know, until recently, i had assumed that most of the busybox
developers were grown-ups who could psychologically handle the concept
of changing some routine semantics for the sake of a cleaner design.
i'm not so sure anymore.

rday



More information about the busybox mailing list