On Tue, 03 Oct 2023 16:09:12 -0700, enh wrote:

> looks like OpenBSD is missing this patch from FreeBSD? llvm libc++ hit
> this (a test worked on other OSes, including FreeBSD-based macOS) but
> failed on OpenBSD-based Android.
> https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=127335 was the
> original FreeBSD bug report. POSIX seems to explicitly require this
> behavior (https://pubs.opengroup.org/onlinepubs/9699919799/functions/fwrite.h
> tml:
> "The fwrite() function shall return the number of elements
> successfully written, which may be less than nitems if a write error
> is encountered. If size or nitems is 0, fwrite() shall return 0 and
> the state of the stream remains unchanged. Otherwise, if a write error
> occurs, the error indicator for the stream shall be set, and errno
> shall be set to indicate the error.").

Yes, this should be fixed.  One difference is that in FreeBSD,
__swsetup() sets errno whereas in OpenBSD we set errno in the caller
when cantwrite() is true.  I think it makes sense to set both errno
and the __SERR flag in the same place.  We just need to decide which
place that is :-)

 - todd

Reply via email to