[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH] linux-user: Simplify boundary checks on g_posix_tim
From: |
Alexander Graf |
Subject: |
[Qemu-devel] [PATCH] linux-user: Simplify boundary checks on g_posix_timers range |
Date: |
Fri, 22 Aug 2014 13:19:26 +0200 |
We check whether the passed in counter value is negative on all calls
that involve g_posix_timers. However, we AND the value down to 16 bits
right before the check, so they can never be negative.
Simplify all the checks and remove the useless negativity check.
Signed-off-by: Alexander Graf <address@hidden>
---
linux-user/syscall.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index f6c887f..bb68dd4 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -9509,7 +9509,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
/* args: timer_t timerid, int flags, const struct itimerspec
*new_value,
* struct itimerspec * old_value */
arg1 &= 0xffff;
- if (arg3 == 0 || arg1 < 0 || arg1 >= ARRAY_SIZE(g_posix_timers)) {
+ if (arg3 == 0 || arg1 >= ARRAY_SIZE(g_posix_timers)) {
ret = -TARGET_EINVAL;
} else {
timer_t htimer = g_posix_timers[arg1];
@@ -9531,7 +9531,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
arg1 &= 0xffff;
if (!arg2) {
return -TARGET_EFAULT;
- } else if (arg1 < 0 || arg1 >= ARRAY_SIZE(g_posix_timers)) {
+ } else if (arg1 >= ARRAY_SIZE(g_posix_timers)) {
ret = -TARGET_EINVAL;
} else {
timer_t htimer = g_posix_timers[arg1];
@@ -9551,7 +9551,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
{
/* args: timer_t timerid */
arg1 &= 0xffff;
- if (arg1 < 0 || arg1 >= ARRAY_SIZE(g_posix_timers)) {
+ if (arg1 >= ARRAY_SIZE(g_posix_timers)) {
ret = -TARGET_EINVAL;
} else {
timer_t htimer = g_posix_timers[arg1];
@@ -9566,7 +9566,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
{
/* args: timer_t timerid */
arg1 &= 0xffff;
- if (arg1 < 0 || arg1 >= ARRAY_SIZE(g_posix_timers)) {
+ if (arg1 >= ARRAY_SIZE(g_posix_timers)) {
ret = -TARGET_EINVAL;
} else {
timer_t htimer = g_posix_timers[arg1];
--
1.7.12.4
- [Qemu-devel] [PATCH] linux-user: Simplify boundary checks on g_posix_timers range,
Alexander Graf <=