[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 24/24] linux-user: Simplify target_madvise
From: |
Richard Henderson |
Subject: |
[PATCH 24/24] linux-user: Simplify target_madvise |
Date: |
Fri, 30 Jun 2023 15:21:59 +0200 |
The trivial length 0 check can be moved up, simplifying some
of the other cases. The end < start test is handled by
guest_range_valid_untagged.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
linux-user/mmap.c | 19 ++++---------------
1 file changed, 4 insertions(+), 15 deletions(-)
diff --git a/linux-user/mmap.c b/linux-user/mmap.c
index a2bef1ebe6..48b83ca8bf 100644
--- a/linux-user/mmap.c
+++ b/linux-user/mmap.c
@@ -900,28 +900,17 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong
old_size,
abi_long target_madvise(abi_ulong start, abi_ulong len_in, int advice)
{
- abi_ulong len, end;
+ abi_ulong len;
int ret = 0;
if (start & ~TARGET_PAGE_MASK) {
return -TARGET_EINVAL;
}
- len = TARGET_PAGE_ALIGN(len_in);
-
- if (len_in && !len) {
- return -TARGET_EINVAL;
- }
-
- end = start + len;
- if (end < start) {
- return -TARGET_EINVAL;
- }
-
- if (end == start) {
+ if (len_in == 0) {
return 0;
}
-
- if (!guest_range_valid_untagged(start, len)) {
+ len = TARGET_PAGE_ALIGN(len_in);
+ if (len == 0 || !guest_range_valid_untagged(start, len)) {
return -TARGET_EINVAL;
}
--
2.34.1
- [PATCH 13/24] linux-user: Rewrite mmap_frag, (continued)
- [PATCH 13/24] linux-user: Rewrite mmap_frag, Richard Henderson, 2023/06/30
- [PATCH 18/24] linux-user: Rewrite mmap_reserve, Richard Henderson, 2023/06/30
- [PATCH 15/24] bsd-user: Use page_find_range_empty for mmap_find_vma_reserved, Richard Henderson, 2023/06/30
- [PATCH 16/24] linux-user: Use page_find_range_empty for mmap_find_vma_reserved, Richard Henderson, 2023/06/30
- [PATCH 17/24] linux-user: Use 'last' instead of 'end' in target_mmap, Richard Henderson, 2023/06/30
- [PATCH 20/24] linux-user: Simplify target_munmap, Richard Henderson, 2023/06/30
- [PATCH 21/24] accel/tcg: Accept more page flags in page_check_range, Richard Henderson, 2023/06/30
- [PATCH 19/24] linux-user: Rename mmap_reserve to mmap_reserve_or_unmap, Richard Henderson, 2023/06/30
- [PATCH 22/24] accel/tcg: Return bool from page_check_range, Richard Henderson, 2023/06/30
- [PATCH 23/24] linux-user: Remove can_passthrough_madvise, Richard Henderson, 2023/06/30
- [PATCH 24/24] linux-user: Simplify target_madvise,
Richard Henderson <=