Commit c5363d03 authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by Linus Torvalds

signals: clean dequeue_signal from excess checks and assignments

The signr variable may be declared without initialization - it is set ro the
return value from __dequeue_signal() right at the function beginning.

Besides, after recalc_sigpending() two checks for signr to be not 0 may be
merged into one.  Both if-s become easier to read.

Thanks to Oleg for pointing out mistakes in the first version of this patch.
Signed-off-by: default avatarPavel Emelyanov <xemul@openvz.org>
Cc: Oleg Nesterov <oleg@tv-sign.ru>
Cc: Roland McGrath <roland@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 93585eea
...@@ -377,7 +377,7 @@ static int __dequeue_signal(struct sigpending *pending, sigset_t *mask, ...@@ -377,7 +377,7 @@ static int __dequeue_signal(struct sigpending *pending, sigset_t *mask,
*/ */
int dequeue_signal(struct task_struct *tsk, sigset_t *mask, siginfo_t *info) int dequeue_signal(struct task_struct *tsk, sigset_t *mask, siginfo_t *info)
{ {
int signr = 0; int signr;
/* We only dequeue private signals from ourselves, we don't let /* We only dequeue private signals from ourselves, we don't let
* signalfd steal them * signalfd steal them
...@@ -410,8 +410,12 @@ int dequeue_signal(struct task_struct *tsk, sigset_t *mask, siginfo_t *info) ...@@ -410,8 +410,12 @@ int dequeue_signal(struct task_struct *tsk, sigset_t *mask, siginfo_t *info)
} }
} }
} }
recalc_sigpending(); recalc_sigpending();
if (signr && unlikely(sig_kernel_stop(signr))) { if (!signr)
return 0;
if (unlikely(sig_kernel_stop(signr))) {
/* /*
* Set a marker that we have dequeued a stop signal. Our * Set a marker that we have dequeued a stop signal. Our
* caller might release the siglock and then the pending * caller might release the siglock and then the pending
...@@ -427,9 +431,7 @@ int dequeue_signal(struct task_struct *tsk, sigset_t *mask, siginfo_t *info) ...@@ -427,9 +431,7 @@ int dequeue_signal(struct task_struct *tsk, sigset_t *mask, siginfo_t *info)
if (!(tsk->signal->flags & SIGNAL_GROUP_EXIT)) if (!(tsk->signal->flags & SIGNAL_GROUP_EXIT))
tsk->signal->flags |= SIGNAL_STOP_DEQUEUED; tsk->signal->flags |= SIGNAL_STOP_DEQUEUED;
} }
if (signr && if ((info->si_code & __SI_MASK) == __SI_TIMER && info->si_sys_private) {
((info->si_code & __SI_MASK) == __SI_TIMER) &&
info->si_sys_private) {
/* /*
* Release the siglock to ensure proper locking order * Release the siglock to ensure proper locking order
* of timer locks outside of siglocks. Note, we leave * of timer locks outside of siglocks. Note, we leave
......
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