Christian Brauner <[email protected]> writes:

> Let's return early when lock_task_sighand() fails and move send_signal()
> and unlock_task_sighand() out of the if block.

Introducing multiple exits into a function.  Ick.
You do know that is what Dijkstra was arguing against in his paper
"Goto Considered Harmful"

That introduces mutiple exits and makes the function harder to analyze.
It is especially a pain as I have something in my queue that will
shuffle things around and remove the possibility of lock_task_sighand
failing.

Eric

> Signed-off-by: Christian Brauner <[email protected]>
> ---
> v0->v1:
> * patch unchanged
> ---
>  kernel/signal.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/kernel/signal.c b/kernel/signal.c
> index baae137455eb..a628b56415e6 100644
> --- a/kernel/signal.c
> +++ b/kernel/signal.c
> @@ -1167,16 +1167,16 @@ specific_send_sig_info(int sig, struct siginfo *info, 
> struct task_struct *t)
>  }
>  
>  int do_send_sig_info(int sig, struct siginfo *info, struct task_struct *p,
> -                     bool group)
> +                  bool group)
>  {
>       unsigned long flags;
>       int ret = -ESRCH;
>  
> -     if (lock_task_sighand(p, &flags)) {
> -             ret = send_signal(sig, info, p, group);
> -             unlock_task_sighand(p, &flags);
> -     }
> +     if (!lock_task_sighand(p, &flags))
> +             return ret;
>  
> +     ret = send_signal(sig, info, p, group);
> +     unlock_task_sighand(p, &flags);
>       return ret;
>  }

Reply via email to