On Thu, Feb 02, 2012 at 09:50:45PM -0700, Philip Guenther wrote:

>>> The current man page doesn't claim that errno is always set but one might
>>> reasonably assume that it is: certainly, it seems a horribly easy way of
>>> introducing bugs (at least for idiots such as myself).
[...]
[Christiano]
>> Although I like your intention, I think the problem is in the later part:
>>
>>  The readdir() and readdir_r() functions may also fail and set errno for
>>     any of the errors specified for the routine getdirentries(2).
>>
>> Maybe this could be clarified ?
>>
>> Lets see what others think.
> I'll propose a third option: I think the directory(3) manpage would be
> clearer if the DESCRIPTION section was unwoven to have separate DESCRIPTION
> and RETURN VALUES section.  Explicit wording that errno is not set when end
> of directory is reached and that programs that want to tell apart
> end-of-directory and errors must set errno to zero should be added.

I think this would make a lot of sense.

> I also think readdir() should set errno if it detects an invalid seekdir().
>  EINVAL seems correct.

This seems like a good idea overall, but I have one minor worry. Does any
other Unix do this? If not, it may introduce another subtle portability bug,
if a program thinks it can detect an invalid seekdir by checking whether
errno was set or not by readdir. This is purely hypothetical though.


Laurie
-- 
Personal                                             http://tratt.net/laurie/
The Converge programming language                      http://convergepl.org/
   https://github.com/ltratt              http://twitter.com/laurencetratt

Reply via email to