[musl] Re: Tweaking the program name for <err.h> functions
NRK
nrk at disroot.org
Sun Mar 10 06:01:14 UTC 2024
> What do you offer to use instead? snprintf(3) + perror(3) + exit(3)?
No need to have an intermediate buffer with snprintf when you can just
use vfprintf directly.
> I suggest you remove err.h from libc, and let a standalone library to
> implement them separately, allowing to configure them.
These are not mutually exclusive. You can have err.h in libc while also
having them as separate library.
And besides, these are not good interfaces anyways. Aside from what Rich
already said, you'll realize this soon when you need to use various
posix_* or pthread_* functions which don't set the errno and instead
return an error code.
Also, I don't think your fear of "NIH bug" is well grounded. This is not
some highly complicated error-prone code, it's just simple logging
facility.
I am aware that there exists certain programming cultures [*] where
having to write code instead of "import leftpad" is seen as taboo of the
highest order. But in this case you don't even *have to* write anything
when you can just copy err.c from musl and customize it.
(* Counterculture to this also exists, such as Go's "A little copying
is better than a little dependency" proverb for example.)
- NRK
More information about the libbsd
mailing list