qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Michal Privoznik" <mprivozn@redhat.com>,
	qemu-devel@nongnu.org
Cc: imammedo@redhat.com, Cameron Esfahani <dirty@apple.com>,
	Eric Blake <eblake@redhat.com>
Subject: Re: [PATCH v2 1/4] osdep: Make qemu_madvise() to set errno in all cases
Date: Fri, 31 May 2024 11:08:00 +0200	[thread overview]
Message-ID: <370f6594-882d-455e-8b45-5d6cab7fcb85@redhat.com> (raw)
In-Reply-To: <577f65c3-23d3-44ce-8601-32c067912a8a@linaro.org>

On 31.05.24 10:12, Philippe Mathieu-Daudé wrote:
> On 31/5/24 10:01, David Hildenbrand wrote:
>> 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."
> 
> On Darwin, MADVISE(2):
> 
>      The posix_madvise() behaves same as madvise() except that it uses
>      values with POSIX_ prefix for the advice system call argument.
> 
>      The posix_madvise function is part of IEEE 1003.1-2001 and was first
>      implemented in Mac OS X 10.2.
> 
> Per IEEE 1003.1-2001
> (https://pubs.opengroup.org/onlinepubs/009695399/functions/posix_madvise.html):
> 
>     RETURN VALUE
> 
>       Upon successful completion, posix_madvise() shall return zero;
>       otherwise, an error number shall be returned to indicate the error.
> 
> Note the use of "shall" which is described in RFC2119 as:
> 
>      This word, or the adjective "RECOMMENDED", mean that there
>      may exist valid reasons in particular circumstances to ignore a
>      particular item, but the full implications must be understood and
>      carefully weighed before choosing a different course.

Agreed, so we have to be careful.

I do wonder if there would be the option for an automatic approach: for 
example, detect if the errno was/was not changed. Hm.

-- 
Cheers,

David / dhildenb



  reply	other threads:[~2024-05-31  9:09 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-31  7:28 [PATCH v2 0/4] backends/hostmem: Report more errors on failures Michal Privoznik
2024-05-31  7:28 ` [PATCH v2 1/4] osdep: Make qemu_madvise() to set errno in all cases Michal Privoznik
2024-05-31  7:57   ` Philippe Mathieu-Daudé
2024-05-31  8:01     ` David Hildenbrand
2024-05-31  8:12       ` Philippe Mathieu-Daudé
2024-05-31  9:08         ` David Hildenbrand [this message]
2024-05-31 11:10           ` Michal Prívozník
2024-05-31  7:28 ` [PATCH v2 2/4] osdep: Make qemu_madvise() return ENOSYS on unsupported OSes Michal Privoznik
2024-05-31  7:48   ` Philippe Mathieu-Daudé
2024-05-31  7:53   ` David Hildenbrand
2024-05-31  8:02     ` Philippe Mathieu-Daudé
2024-05-31  7:28 ` [PATCH v2 3/4] backends/hostmem: Report error on qemu_madvise() failures Michal Privoznik
2024-05-31  7:49   ` Philippe Mathieu-Daudé
2024-05-31  9:10   ` David Hildenbrand
2024-05-31  7:29 ` [PATCH v2 4/4] backends/hostmem: Report error when memory size is unaligned Michal Privoznik
2024-05-31  7:53   ` Philippe Mathieu-Daudé
2024-06-05  7:12   ` Mario Casquero

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=370f6594-882d-455e-8b45-5d6cab7fcb85@redhat.com \
    --to=david@redhat.com \
    --cc=dirty@apple.com \
    --cc=eblake@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=mprivozn@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).