implenting BB variations of standard system calls

Natanael Copa natanael.copa at gmail.com
Thu Apr 20 15:30:28 UTC 2006


On Thu, 20 Apr 2006 09:50:02 -0400 (EDT)
"Robert P. J. Day" <rpjday at mindspring.com> wrote:

> besides, while i appreciate the philosophy that busybox is obsessed
> with bytes, these days, given that memory is getting cheaper and flash
> and RAM chips are getting larger (and this trend is only going to
> continue), it only makes sense that it's not *quite* as important to
> save 10 or 20 bytes as it used to be.

I don't think anybody say you are wrong in having a clean design, proper names for functions and variables etc. Seems like there are no motivation for it. (understandable....)

Just a little suggestion that I think could help you move forward: "find a few af those 10-20 bytes savers, "fix" them by use a properly named wrapper func, while you are there you also reformat some of the relevant stuff, rename one or two funcs to a name that you find much better and then you send patch and say:

"please look at this patch. it saves 10 bytes by bla bla. ... and while i were there i cleaned up a little so it follows the official busybox coding standards"

The developers might react: "so this saves 10 bytes? cool!!! I'll check it in"

You get your clean code, they get their smaller code and everybody is happy.

> fair enough.  i'll give this more thought and see if i can come up
> with some kind of coherent suggestion.  as a single example, i would
> suggest adding two new routines of the following form:
> 
>   map_username_to_uid()
>   map_uid_to_username()
> 
> both of which consult the local /etc files to get that information.
> note that the standard lib already provides getpwuid() if what you
> want is the "struct passwd *" object -- that's perfectly reasonable.
> 
> however, if you want something more direct to calculate the mapping of
> UID <-> username, then those two routines would represent simple
> "wrapper" routines, and their semantics would be obvious.  that's the
> sort of thing i would propose.

I think this is a good idea. There is already an bb_getpwuid doing this so you might replace it in numerous places. If you do it and replace the getpwuid/getpwnam's in the code with your wrapper, you will probably alos reduce the code.

Please post a patch and propse it in a psycoligical correct way so it gets commited.

I could have use for one of those right now, actually, for my upcomming tar patch. So be quick ;-)

> p.s.  i've mentioned this earlier as well, but i've noticed that
> there are numerous, possibly useful routines that aren't universally
> available because they've been defined as "static" inside a single
> source file.

I agree. There could probably be an general itoa func that could replace 5 other itoa's + a number of snprintf(..."%d")'s. I think it would reduce the code.

There are lots of those. Just take one, fix it, send a patch, move on to next. Thats probably better than just complaining about how bad things are.

-- 
Natanael Copa



More information about the busybox mailing list