lkml.org 
[lkml]   [2011]   [May]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 05/10] ptrace: restructure ptrace_getsiginfo()
Date
Flatten ptrace_getsiginfo() to prepare for more logic in the success
path. While at it, remove [un]likely() on child->last_siginfo check -
signal delivery and group stop traps can only be distinguished by NULL
siginfo and group stop isn't that unlikely.

This patch doesn't introduce any functional change.

Signed-off-by: Tejun Heo <tj@kernel.org>
---
kernel/ptrace.c | 21 ++++++++++++---------
1 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index 351db7c..42037a4 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -574,16 +574,19 @@ static int ptrace_setoptions(struct task_struct *child, unsigned long data)
static int ptrace_getsiginfo(struct task_struct *child, siginfo_t *info)
{
unsigned long flags;
- int error = -ESRCH;
+ int error;

- if (lock_task_sighand(child, &flags)) {
- error = -EINVAL;
- if (likely(child->last_siginfo != NULL)) {
- *info = *child->last_siginfo;
- error = 0;
- }
- unlock_task_sighand(child, &flags);
- }
+ if (!lock_task_sighand(child, &flags))
+ return -ESRCH;
+
+ error = -EINVAL;
+ if (!child->last_siginfo)
+ goto out_unlock;
+
+ error = 0;
+ *info = *child->last_siginfo;
+out_unlock:
+ unlock_task_sighand(child, &flags);
return error;
}

--
1.7.1


\
 
 \ /
  Last update: 2011-05-16 20:21    [W:0.280 / U:0.144 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site