On 2025-02-12 Martin Storsjö wrote:
> On Thu, 16 Jan 2025, Lasse Collin wrote:
> 
> > The dirent functions are defined in POSIX, and POSIX clearly
> > specifies that no POSIX function shall set errno to zero.  
> 
> Hmm, I haven't dug very deep for references around this, but a quick 
> google gave me this:
> 
> https://softwareengineering.stackexchange.com/a/209731/314542

A function that succeeds is allowed to change errno, but it's not
allowed to set errno to 0 unless it already was 0. That is, a function
might change errno but restore the original value before it returns,
and this restoring can set errno to 0.

See "2.3 Error numbers" paragraph 2:

https://pubs.opengroup.org/onlinepubs/9799919799/functions/V2_chap02.html#tag_16_03

> > POSIX no longer claims its libraries will not alter the value in
> > case of success, and the new Linux man page for errno.h reflects
> > this: 
> > > [...]  a function that succeeds is allowed to change errno.  
> 
> That said, I guess it's good practice to not reset errno in these 
> functions.
> 
> I think this change looks fine to me.

Thanks. At this point, my original patch series should be put on hold
even if the patches 1-4 are OK. I will send a different dirent draft
version probably this week, so avoiding churn in the dirent files is
good *if* the new code is accepted. I hope Pali has time to look at it
before it's seriously proposed to the mingw-w64 maintainers. His
startup code and argv[] updates have a priority over dirent.

-- 
Lasse Collin


_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to