[Toybox] Issues - deprecated bzero and xread
Rob Landley
rob at landley.net
Sun Dec 25 20:28:06 PST 2011
> Hi I get warnings / errors with non glibc libcs, specifically with
> musl libc in main.c:84, lib/args.c:160, lib.c:94 and toys/toysh.c:294
> all due to use of bzero.
Which is 4 bytes smaller than memset(x, 0, len) on 32 bit platforms (and
8 on 64 bit platforms) due to needing one less argument. memset with
zero is the common case.
I can wrap it myself in libbb and stick glue in lib/portability.h to
figure out when to need to do it. But basically, deprecating it was
stupid, and if they take it out of libc I'll put it back in lib/lib.c.
> Also xread in lib.* should be ssize_t?
Yeah, that's a bug. It needs a local signed variable.
As for the arguments: it can't read a negative amount, and doesn't ever
return a negative value, so the non-signed size_t is fine. (It's
intentional, note that readall() and writeall() return ssize_t.)
But since _read_ has different semantics than xread(), we need a
differnet variable for its return value. Good catch, thanks.
In theory main() should be setting up the SA_RESTART stuff described in
sigaction so we're not constantly checking for EAGAIN. In practice
that's a todo item...
Rob
1324873686.0
More information about the Toybox
mailing list