On 31.05.24 09:57, Philippe Mathieu-Daudé wrote:
Hi Michal,

On 31/5/24 09:28, Michal Privoznik wrote:
The unspoken premise of qemu_madvise() is that errno is set on
error. And it is mostly the case except for posix_madvise() which
is documented to return either zero (on success) or a positive
error number.

Watch out, Linux:

    RETURN VALUE

       On success, posix_madvise() returns 0.  On failure,
       it returns a positive error number.

but on Darwin:

    RETURN VALUES

       Upon successful completion, a value of 0 is returned.
       Otherwise, a value of -1 is returned and errno is set
       to indicate the error.

(Haven't checked other POSIX OSes).


... but it's supposed to follow the "posix standard" :D Maybe an issue in the docs?

FreeBSD seems to follow the standard: "The posix_madvise() interface is identical, except it returns an error number on error and does not modify errno, and is provided for standards conformance."

Same with OpenBSD: "The posix_madvise() interface has the same effect, but returns the error value instead of only setting errno."

--
Cheers,

David / dhildenb


Reply via email to