Ted Unangst <t...@tedunangst.com> wrote:
 |On Tue, Jan 14, 2014 at 15:08, Steffen  Nurpmeso wrote:
 |> Description:
 |> The *c() family, which exists in FreeBSD and derivatives, is
 |> helpful whenever something has to be done in the error case
 |> (like necessary cleanup), while still being able to inform the
 |> user about the original error that caused the problem.
 |
 |The motivation for this isn't clear.
 |
 | if (failure()) {
 |  saved_errno = errno;
 |  cleanup();
 |  errc(1, saved_errno, "fail");
 |}
 |
 |vs
 |
 | if (failure()) {
 |  saved_errno = errno;
 |  cleanup();
 |  errno = saved_errno;
 |  err(1, "fail");
 |}
 |
 |That's it, right? ok, I see the point, so maybe I should have said the
 |motivation isn't compelling. It doesn't save that much work and leads
 |to API explosion.
 |
 |If it could magically eliminate the need to save errno entirely,
 |that'd be aswesome, but just knowing you need to save errno is
 |literally 90% of the problem and this doesn't solve that.

Ok, but under the surface errno is more than just assignment to
simple storage.  It may not be that terrible with TLS, or on
platforms where accessing thread_self() is simply looking at
a register and TSD errno is treated special, but personally the
latter makes me sick :).

API explosion is also a valid point, but if i would implement that
for real there would be one (non-inline) implementation for them
all, or two if there is a real need to go with __dead.
I think it is worth adding this interface, given how frequently
this family is used:

  $ git grep -E '(err|warn)\(' origin/master|wc -l
    19583

all in all, including perl(1) stuff.  A family that is used so
often can well tolerate a few more options, i think.
Just my one cent.

--steffen

Reply via email to