From: David Hildenbrand <david@redhat.com>
To: Michal Privoznik <mprivozn@redhat.com>, qemu-devel@nongnu.org
Cc: imammedo@redhat.com
Subject: Re: [PATCH 1/3] osdep: Make qemu_madvise() to set errno in all cases
Date: Tue, 28 May 2024 18:51:14 +0200 [thread overview]
Message-ID: <5e9a1ca9-b9b8-44f0-9e0c-b56ae0b2c0fc@redhat.com> (raw)
In-Reply-To: <4d8a74a512bf55f39c5d1be115b1c52b6a632e09.1716912651.git.mprivozn@redhat.com>
Am 28.05.24 um 18:15 schrieb Michal Privoznik:
> 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. This means, we must set errno ourselves. And while
> at it, make the function return a negative value on error, just
> like other error paths do.
>
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
> util/osdep.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/util/osdep.c b/util/osdep.c
> index e996c4744a..e42f4e8121 100644
> --- a/util/osdep.c
> +++ b/util/osdep.c
> @@ -57,7 +57,12 @@ int qemu_madvise(void *addr, size_t len, int advice)
> #if defined(CONFIG_MADVISE)
> return madvise(addr, len, advice);
> #elif defined(CONFIG_POSIX_MADVISE)
> - return posix_madvise(addr, len, advice);
> + int rc = posix_madvise(addr, len, advice);
> + if (rc) {
> + errno = rc;
> + return -1;
> + }
> + return 0;
> #else
> errno = EINVAL;
> return -1;
Interesting, seems to be correct
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Thanks,
David / dhildenb
next prev parent reply other threads:[~2024-05-28 16:52 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-28 16:15 [PATCH 0/3] backends/hostmem: Round up memory size for qemu_madvise() and mbind() Michal Privoznik
2024-05-28 16:15 ` [PATCH 1/3] osdep: Make qemu_madvise() to set errno in all cases Michal Privoznik
2024-05-28 16:51 ` David Hildenbrand [this message]
2024-05-28 16:15 ` [PATCH 2/3] backends/hostmem: Warn on qemu_madvise() failures Michal Privoznik
2024-05-28 16:15 ` [PATCH 3/3] backends/hostmem: Round up memory size for qemu_madvise() and mbind() Michal Privoznik
2024-05-28 16:47 ` David Hildenbrand
2024-05-29 6:48 ` Michal Prívozník
2024-05-29 12:30 ` David Hildenbrand
2024-05-28 17:22 ` Richard Henderson
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=5e9a1ca9-b9b8-44f0-9e0c-b56ae0b2c0fc@redhat.com \
--to=david@redhat.com \
--cc=imammedo@redhat.com \
--cc=mprivozn@redhat.com \
--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).