Commit d7c5ed73 authored by André Almeida's avatar André Almeida Committed by Thomas Gleixner

futex: Remove needless goto's

As stated in the coding style documentation, "if there is no cleanup
needed then just return directly", instead of jumping to a label and
then returning.

Remove such goto's and replace with a return statement.  When there's a
ternary operator on the return value, replace it with the result of the
operation when it is logically possible to determine it by the control
flow.
Signed-off-by: default avatarAndré Almeida <andrealmeid@collabora.com>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/20200702202843.520764-3-andrealmeid@collabora.com
parent 9180bd46
...@@ -1607,13 +1607,13 @@ futex_wake(u32 __user *uaddr, unsigned int flags, int nr_wake, u32 bitset) ...@@ -1607,13 +1607,13 @@ futex_wake(u32 __user *uaddr, unsigned int flags, int nr_wake, u32 bitset)
ret = get_futex_key(uaddr, flags & FLAGS_SHARED, &key, FUTEX_READ); ret = get_futex_key(uaddr, flags & FLAGS_SHARED, &key, FUTEX_READ);
if (unlikely(ret != 0)) if (unlikely(ret != 0))
goto out; return ret;
hb = hash_futex(&key); hb = hash_futex(&key);
/* Make sure we really have tasks to wakeup */ /* Make sure we really have tasks to wakeup */
if (!hb_waiters_pending(hb)) if (!hb_waiters_pending(hb))
goto out; return ret;
spin_lock(&hb->lock); spin_lock(&hb->lock);
...@@ -1636,7 +1636,6 @@ futex_wake(u32 __user *uaddr, unsigned int flags, int nr_wake, u32 bitset) ...@@ -1636,7 +1636,6 @@ futex_wake(u32 __user *uaddr, unsigned int flags, int nr_wake, u32 bitset)
spin_unlock(&hb->lock); spin_unlock(&hb->lock);
wake_up_q(&wake_q); wake_up_q(&wake_q);
out:
return ret; return ret;
} }
...@@ -1703,10 +1702,10 @@ futex_wake_op(u32 __user *uaddr1, unsigned int flags, u32 __user *uaddr2, ...@@ -1703,10 +1702,10 @@ futex_wake_op(u32 __user *uaddr1, unsigned int flags, u32 __user *uaddr2,
retry: retry:
ret = get_futex_key(uaddr1, flags & FLAGS_SHARED, &key1, FUTEX_READ); ret = get_futex_key(uaddr1, flags & FLAGS_SHARED, &key1, FUTEX_READ);
if (unlikely(ret != 0)) if (unlikely(ret != 0))
goto out; return ret;
ret = get_futex_key(uaddr2, flags & FLAGS_SHARED, &key2, FUTEX_WRITE); ret = get_futex_key(uaddr2, flags & FLAGS_SHARED, &key2, FUTEX_WRITE);
if (unlikely(ret != 0)) if (unlikely(ret != 0))
goto out; return ret;
hb1 = hash_futex(&key1); hb1 = hash_futex(&key1);
hb2 = hash_futex(&key2); hb2 = hash_futex(&key2);
...@@ -1724,13 +1723,13 @@ futex_wake_op(u32 __user *uaddr1, unsigned int flags, u32 __user *uaddr2, ...@@ -1724,13 +1723,13 @@ futex_wake_op(u32 __user *uaddr1, unsigned int flags, u32 __user *uaddr2,
* an MMU, but we might get them from range checking * an MMU, but we might get them from range checking
*/ */
ret = op_ret; ret = op_ret;
goto out; return ret;
} }
if (op_ret == -EFAULT) { if (op_ret == -EFAULT) {
ret = fault_in_user_writeable(uaddr2); ret = fault_in_user_writeable(uaddr2);
if (ret) if (ret)
goto out; return ret;
} }
if (!(flags & FLAGS_SHARED)) { if (!(flags & FLAGS_SHARED)) {
...@@ -1773,7 +1772,6 @@ futex_wake_op(u32 __user *uaddr1, unsigned int flags, u32 __user *uaddr2, ...@@ -1773,7 +1772,6 @@ futex_wake_op(u32 __user *uaddr1, unsigned int flags, u32 __user *uaddr2,
out_unlock: out_unlock:
double_unlock_hb(hb1, hb2); double_unlock_hb(hb1, hb2);
wake_up_q(&wake_q); wake_up_q(&wake_q);
out:
return ret; return ret;
} }
...@@ -1980,20 +1978,18 @@ static int futex_requeue(u32 __user *uaddr1, unsigned int flags, ...@@ -1980,20 +1978,18 @@ static int futex_requeue(u32 __user *uaddr1, unsigned int flags,
retry: retry:
ret = get_futex_key(uaddr1, flags & FLAGS_SHARED, &key1, FUTEX_READ); ret = get_futex_key(uaddr1, flags & FLAGS_SHARED, &key1, FUTEX_READ);
if (unlikely(ret != 0)) if (unlikely(ret != 0))
goto out; return ret;
ret = get_futex_key(uaddr2, flags & FLAGS_SHARED, &key2, ret = get_futex_key(uaddr2, flags & FLAGS_SHARED, &key2,
requeue_pi ? FUTEX_WRITE : FUTEX_READ); requeue_pi ? FUTEX_WRITE : FUTEX_READ);
if (unlikely(ret != 0)) if (unlikely(ret != 0))
goto out; return ret;
/* /*
* The check above which compares uaddrs is not sufficient for * The check above which compares uaddrs is not sufficient for
* shared futexes. We need to compare the keys: * shared futexes. We need to compare the keys:
*/ */
if (requeue_pi && match_futex(&key1, &key2)) { if (requeue_pi && match_futex(&key1, &key2))
ret = -EINVAL; return -EINVAL;
goto out;
}
hb1 = hash_futex(&key1); hb1 = hash_futex(&key1);
hb2 = hash_futex(&key2); hb2 = hash_futex(&key2);
...@@ -2013,7 +2009,7 @@ static int futex_requeue(u32 __user *uaddr1, unsigned int flags, ...@@ -2013,7 +2009,7 @@ static int futex_requeue(u32 __user *uaddr1, unsigned int flags,
ret = get_user(curval, uaddr1); ret = get_user(curval, uaddr1);
if (ret) if (ret)
goto out; return ret;
if (!(flags & FLAGS_SHARED)) if (!(flags & FLAGS_SHARED))
goto retry_private; goto retry_private;
...@@ -2079,7 +2075,7 @@ static int futex_requeue(u32 __user *uaddr1, unsigned int flags, ...@@ -2079,7 +2075,7 @@ static int futex_requeue(u32 __user *uaddr1, unsigned int flags,
ret = fault_in_user_writeable(uaddr2); ret = fault_in_user_writeable(uaddr2);
if (!ret) if (!ret)
goto retry; goto retry;
goto out; return ret;
case -EBUSY: case -EBUSY:
case -EAGAIN: case -EAGAIN:
/* /*
...@@ -2198,8 +2194,6 @@ static int futex_requeue(u32 __user *uaddr1, unsigned int flags, ...@@ -2198,8 +2194,6 @@ static int futex_requeue(u32 __user *uaddr1, unsigned int flags,
double_unlock_hb(hb1, hb2); double_unlock_hb(hb1, hb2);
wake_up_q(&wake_q); wake_up_q(&wake_q);
hb_waiters_dec(hb2); hb_waiters_dec(hb2);
out:
return ret ? ret : task_count; return ret ? ret : task_count;
} }
...@@ -2545,7 +2539,7 @@ static int fixup_owner(u32 __user *uaddr, struct futex_q *q, int locked) ...@@ -2545,7 +2539,7 @@ static int fixup_owner(u32 __user *uaddr, struct futex_q *q, int locked)
*/ */
if (q->pi_state->owner != current) if (q->pi_state->owner != current)
ret = fixup_pi_state_owner(uaddr, q, current); ret = fixup_pi_state_owner(uaddr, q, current);
goto out; return ret ? ret : locked;
} }
/* /*
...@@ -2558,7 +2552,7 @@ static int fixup_owner(u32 __user *uaddr, struct futex_q *q, int locked) ...@@ -2558,7 +2552,7 @@ static int fixup_owner(u32 __user *uaddr, struct futex_q *q, int locked)
*/ */
if (q->pi_state->owner == current) { if (q->pi_state->owner == current) {
ret = fixup_pi_state_owner(uaddr, q, NULL); ret = fixup_pi_state_owner(uaddr, q, NULL);
goto out; return ret;
} }
/* /*
...@@ -2572,8 +2566,7 @@ static int fixup_owner(u32 __user *uaddr, struct futex_q *q, int locked) ...@@ -2572,8 +2566,7 @@ static int fixup_owner(u32 __user *uaddr, struct futex_q *q, int locked)
q->pi_state->owner); q->pi_state->owner);
} }
out: return ret;
return ret ? ret : locked;
} }
/** /**
...@@ -2670,7 +2663,7 @@ static int futex_wait_setup(u32 __user *uaddr, u32 val, unsigned int flags, ...@@ -2670,7 +2663,7 @@ static int futex_wait_setup(u32 __user *uaddr, u32 val, unsigned int flags,
ret = get_user(uval, uaddr); ret = get_user(uval, uaddr);
if (ret) if (ret)
goto out; return ret;
if (!(flags & FLAGS_SHARED)) if (!(flags & FLAGS_SHARED))
goto retry_private; goto retry_private;
...@@ -2683,7 +2676,6 @@ static int futex_wait_setup(u32 __user *uaddr, u32 val, unsigned int flags, ...@@ -2683,7 +2676,6 @@ static int futex_wait_setup(u32 __user *uaddr, u32 val, unsigned int flags,
ret = -EWOULDBLOCK; ret = -EWOULDBLOCK;
} }
out:
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment