Matthias Andree: > Am 22.04.2015 um 03:23 schrieb Wietse Venema: > > Viktor Dukhovni: > >> On Wed, Apr 22, 2015 at 01:50:31AM +0200, Matthias Andree wrote: > >> > >>> I would like to chime in here. I believe there is a misunderstanding of > >>> the API, IEEE Std 1003.1, 2013 Edition aka. The Open Group Base > >>> Specifications Issue 7 for readdir() explicitly state that on > >>> end-of-directory, errno is not changed, and applications that need to > >>> check for errors, should zero it beforehand. > >> > >> I also did not expect readdir() to preemptively clear errno. > > > > Well I would just mention here that Postfix pre-dates IEEE Std X. > > Out of interest, I dug through historic standards, and similar > specifications on readdir()/errno have been in have already been in the > 1994 X/Open CAE System Interfaces and Headers Issue 4, Version 2. > > Also, this is newly written trivial code that is portable to systems > older than one should operate on the Internet, and even if my code were > based on older specifications, I personally would be loathe to argue > that the OS were misbehaving if the perceived "misbehaviour" has instead > been the norm for more than two decades, and is consistent with how > systems that I've had my hands on generally behave(d). > > Your code and prose, your decision. I do not crave to continue this > discussion, the size of this reasoning exceeds the length of the comment > by far.
It was certainly new to me that readdir() requires the caller to reset errno before the readdir() call, if they need to distinguish between "no more information" and "error". I don't recall seeing that requirement when I implemented this part of Postfix. I could present evidence from actual readdir() implementations (the FreeBSD manpages site covers many OSes including Linux, Sun, Apple, etc. going back in time) but you will have to excuse me for not having the time. Wietse