bb_*printf functions: are they useful?

Denis Vlasenko vda.linux at googlemail.com
Tue Sep 19 16:53:18 UTC 2006


Hi Rich, busyboxers,

Do we really need libbb/printf.c?

I am not sure about it, but I think the rationale for this
stuff is to catch rare cases when we get errors writing to
stdout/stderr, and handle them properly. printf() sometimes
does not indicate the error condition.

Any applet which primary function is to process stream data
(sed, awk, dd, cut...) is probably already explicitly checks
for that and exit with nonzero. Then most likely do not use
(or "should not use"?) printf-like functions for output,
at the very least because it is a bit slow to push
megabytes thru stdio.

printf functions, I think, are commonly used by applets
for error messages to stderr and by applets which produce
human-readable output (IOW: not typically consumed by pipe).
Things like hdparm, fsck, ipcs.

What we are trying to achieve by using special versions
of printf in e.g. ipcs.c?

How it was supposed to work, anyway? Like this?

applet_main()
{
        ....
        return ferror(stdout);
}

We don't do that now.

IOW: I grepped thru the tree. I think bb_*printf is
almost never used for stream processing. Can I remove it?
--
vda



More information about the busybox mailing list