aboutsummaryrefslogtreecommitdiff
path: root/linux-user/mmap.c
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2023-07-07 21:40:54 +0100
committerRichard Henderson <richard.henderson@linaro.org>2023-07-15 08:02:33 +0100
commite230ec090b61ea7642854197c143010d2c89bb24 (patch)
treebdeb020af5b5f8e017e8b7f61eb38b3c6129c2ab /linux-user/mmap.c
parentecb796db038ad43707d344ce5da55b7f39c3e59f (diff)
downloadqemu-e230ec090b61ea7642854197c143010d2c89bb24.zip
qemu-e230ec090b61ea7642854197c143010d2c89bb24.tar.gz
qemu-e230ec090b61ea7642854197c143010d2c89bb24.tar.bz2
linux-user: Simplify target_madvise
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> Message-Id: <20230707204054.8792-27-richard.henderson@linaro.org>
Diffstat (limited to 'linux-user/mmap.c')
-rw-r--r--linux-user/mmap.c19
1 files changed, 4 insertions, 15 deletions
diff --git a/linux-user/mmap.c b/linux-user/mmap.c
index 49cfa87..44b53bd 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;
}