On Tue, Nov 18, 2008 at 3:52 PM, Peter Miller <[EMAIL PROTECTED]> wrote:

> Trying to explain the causes of obscure <errno.h> values is like a
> riddle-based mystery tour of Asymmetric Api Land.  "Yes, that error
> happened; yes, the system knows why; no, the system will not tell you
> your crime.  Guilty!  Ten years imprisonment.  Next!"

Speaking of which: C programmers learn at primary school that you
should only observe errno, not assign to it. If a function returns an
error (typically null or -1) then you look at errno to see what's
wrong.

Almost.  For a couple of APIs, including readdir, you *must* assign 0
to errno before calling the function, otherwise you cannot tell
whether the function succeeded or failed, as NULL is used for both
end-of-file (with errno unchanged, not set to 0) and error (with errno
set).  If you don't explicitly set it, it will have whatever value it
previously contained.

I pity the fool who tries to persuade Ulrich to change this
(standard-compliant) behaviour.

<https://bugs.edge.launchpad.net/bugs/279381>

-- 
Martin <http://launchpad.net/~mbp/>
_______________________________________________
coders mailing list
coders@slug.org.au
http://lists.slug.org.au/listinfo/coders

Reply via email to