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>
This commit is contained in:
parent
ecb796db03
commit
e230ec090b
@ -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_long target_madvise(abi_ulong start, abi_ulong len_in, int advice)
|
||||||
{
|
{
|
||||||
abi_ulong len, end;
|
abi_ulong len;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (start & ~TARGET_PAGE_MASK) {
|
if (start & ~TARGET_PAGE_MASK) {
|
||||||
return -TARGET_EINVAL;
|
return -TARGET_EINVAL;
|
||||||
}
|
}
|
||||||
len = TARGET_PAGE_ALIGN(len_in);
|
if (len_in == 0) {
|
||||||
|
|
||||||
if (len_in && !len) {
|
|
||||||
return -TARGET_EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
end = start + len;
|
|
||||||
if (end < start) {
|
|
||||||
return -TARGET_EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (end == start) {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
len = TARGET_PAGE_ALIGN(len_in);
|
||||||
if (!guest_range_valid_untagged(start, len)) {
|
if (len == 0 || !guest_range_valid_untagged(start, len)) {
|
||||||
return -TARGET_EINVAL;
|
return -TARGET_EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user