[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 18/42] osdep: Make qemu_madvise() to set errno in all cases
From: |
Paolo Bonzini |
Subject: |
[PULL 18/42] osdep: Make qemu_madvise() to set errno in all cases |
Date: |
Sat, 8 Jun 2024 10:33:51 +0200 |
From: Michal Privoznik <mprivozn@redhat.com>
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>
Reviewed-by: David Hildenbrand <david@redhat.com>
Message-ID:
<af17113e7c1f2cc909ffd36d23f5a411b63b8764.1717584048.git.mprivozn@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
util/osdep.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/util/osdep.c b/util/osdep.c
index e996c4744af..e42f4e8121d 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;
--
2.45.1
- [PULL 06/42] target/i386: disable/enable breakpoints on vmentry/vmexit, (continued)
- [PULL 06/42] target/i386: disable/enable breakpoints on vmentry/vmexit, Paolo Bonzini, 2024/06/08
- [PULL 09/42] target/i386: fix TF/RF handling for HLT, Paolo Bonzini, 2024/06/08
- [PULL 11/42] target/i386: document use of DISAS_NORETURN, Paolo Bonzini, 2024/06/08
- [PULL 10/42] target/i386: document incorrect semantics of watchpoint following MOV/POP SS, Paolo Bonzini, 2024/06/08
- [PULL 12/42] target/i386: use local X86DecodedOp in gen_POP(), Paolo Bonzini, 2024/06/08
- [PULL 13/42] target/i386: use gen_writeback() within gen_POP(), Paolo Bonzini, 2024/06/08
- [PULL 14/42] target/i386: fix SP when taking a memory fault during POP, Paolo Bonzini, 2024/06/08
- [PULL 15/42] target/i386: fix size of EBP writeback in gen_enter(), Paolo Bonzini, 2024/06/08
- [PULL 16/42] machine: default -M mem-merge to off is QEMU_MADV_MERGEABLE is not available, Paolo Bonzini, 2024/06/08
- [PULL 17/42] meson: Don't even detect posix_madvise() on Darwin, Paolo Bonzini, 2024/06/08
- [PULL 18/42] osdep: Make qemu_madvise() to set errno in all cases,
Paolo Bonzini <=
- [PULL 20/42] backends/hostmem: Report error when memory size is unaligned, Paolo Bonzini, 2024/06/08
- [PULL 21/42] machine, hostmem: improve error messages for unsupported features, Paolo Bonzini, 2024/06/08
- [PULL 22/42] hostmem: simplify the code for merge and dump properties, Paolo Bonzini, 2024/06/08
- [PULL 19/42] osdep: Make qemu_madvise() return ENOSYS on unsupported OSes, Paolo Bonzini, 2024/06/08
- [PULL 23/42] scsi-disk: Don't silently truncate serial number, Paolo Bonzini, 2024/06/08
- [PULL 24/42] stubs/meson: Fix qemuutil build when --disable-system, Paolo Bonzini, 2024/06/08
- [PULL 25/42] i386/hvf: Adds support for INVTSC cpuid bit, Paolo Bonzini, 2024/06/08
- [PULL 27/42] hvf: Consistent types for vCPU handles, Paolo Bonzini, 2024/06/08
- [PULL 26/42] i386/hvf: Fixes some compilation warnings, Paolo Bonzini, 2024/06/08
- [PULL 28/42] i386/hvf: Fixes dirty memory tracking by page granularity RX->RWX change, Paolo Bonzini, 2024/06/08