* [PATCH 6/6] arch_ptrace() cleanup
@ 2008-02-11 21:44 Petr Tesarik
2008-02-12 4:29 ` Christoph Hellwig
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Petr Tesarik @ 2008-02-11 21:44 UTC (permalink / raw)
To: linux-ia64
Remove duplicate code and clean up goto's.
Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
CC: Tony Luck <tony.luck@intel.com>
CC: Christoph Hellwig <hch@infradead.org>
diff --git a/arch/ia64/kernel/ptrace.c b/arch/ia64/kernel/ptrace.c
index f10c8b4..2477de8 100644
--- a/arch/ia64/kernel/ptrace.c
+++ b/arch/ia64/kernel/ptrace.c
@@ -1491,37 +1491,22 @@ user_disable_single_step (struct task_st
void
ptrace_disable (struct task_struct *child)
{
- struct ia64_psr *child_psr = ia64_psr(task_pt_regs(child));
-
- /* make sure the single step/taken-branch trap bits are not set: */
- clear_tsk_thread_flag(child, TIF_SINGLESTEP);
- child_psr->ss = 0;
- child_psr->tb = 0;
+ user_disable_single_step(child);
}
long
arch_ptrace (struct task_struct *child, long request, long addr, long data)
{
- struct pt_regs *pt;
- struct switch_stack *sw;
- long ret;
-
- pt = task_pt_regs(child);
- sw = (struct switch_stack *) (child->thread.ksp + 16);
-
switch (request) {
case PTRACE_PEEKTEXT:
case PTRACE_PEEKDATA:
/* read word at location addr */
if (access_process_vm(child, addr, &data, sizeof(data), 0)
- != sizeof(data)) {
- ret = -EIO;
- goto out_tsk;
- }
- ret = data;
- /* ensure "ret" is not mistaken as an error code */
+ != sizeof(data))
+ return -EIO;
+ /* ensure return value is not mistaken for error code */
force_successful_syscall_return();
- goto out_tsk;
+ return data;
/* PTRACE_POKETEXT and PTRACE_POKEDATA is handled
* by the generic ptrace_request().
@@ -1529,50 +1514,37 @@ arch_ptrace (struct task_struct *child,
case PTRACE_PEEKUSR:
/* read the word at addr in the USER area */
- if (access_uarea(child, addr, &data, 0) < 0) {
- ret = -EIO;
- goto out_tsk;
- }
- ret = data;
- /* ensure "ret" is not mistaken as an error code */
+ if (access_uarea(child, addr, &data, 0) < 0)
+ return -EIO;
+ /* ensure return value is not mistaken for error code */
force_successful_syscall_return();
- goto out_tsk;
+ return data;
case PTRACE_POKEUSR:
/* write the word at addr in the USER area */
- if (access_uarea(child, addr, &data, 1) < 0) {
- ret = -EIO;
- goto out_tsk;
- }
- ret = 0;
- goto out_tsk;
+ if (access_uarea(child, addr, &data, 1) < 0)
+ return -EIO;
+ return 0;
case PTRACE_OLD_GETSIGINFO:
/* for backwards-compatibility */
- ret = ptrace_request(child, PTRACE_GETSIGINFO, addr, data);
- goto out_tsk;
+ return ptrace_request(child, PTRACE_GETSIGINFO, addr, data);
case PTRACE_OLD_SETSIGINFO:
/* for backwards-compatibility */
- ret = ptrace_request(child, PTRACE_SETSIGINFO, addr, data);
- goto out_tsk;
+ return ptrace_request(child, PTRACE_SETSIGINFO, addr, data);
case PTRACE_GETREGS:
- ret = ptrace_getregs(child,
- (struct pt_all_user_regs __user *) data);
- goto out_tsk;
+ return ptrace_getregs(child,
+ (struct pt_all_user_regs __user *) data);
case PTRACE_SETREGS:
- ret = ptrace_setregs(child,
- (struct pt_all_user_regs __user *) data);
- goto out_tsk;
+ return ptrace_setregs(child,
+ (struct pt_all_user_regs __user *) data);
default:
- ret = ptrace_request(child, request, addr, data);
- goto out_tsk;
+ return ptrace_request(child, request, addr, data);
}
- out_tsk:
- return ret;
}
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH 6/6] arch_ptrace() cleanup
2008-02-11 21:44 [PATCH 6/6] arch_ptrace() cleanup Petr Tesarik
@ 2008-02-12 4:29 ` Christoph Hellwig
2008-02-26 11:03 ` Petr Tesarik
2008-02-26 17:09 ` Christoph Hellwig
2 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2008-02-12 4:29 UTC (permalink / raw)
To: linux-ia64
All these patches looks really great to me from the ptrace perspective.
While you're at cleaning up arch_ptrace it might be worth to convert
this odd indentation
> switch (request) {
> case PTRACE_PEEKTEXT:
> case PTRACE_PEEKDATA:
into the normal
switch (request) {
case PTRACE_PEEKTEXT:
case PTRACE_PEEKDATA:
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH 6/6] arch_ptrace() cleanup
2008-02-11 21:44 [PATCH 6/6] arch_ptrace() cleanup Petr Tesarik
2008-02-12 4:29 ` Christoph Hellwig
@ 2008-02-26 11:03 ` Petr Tesarik
2008-02-26 17:09 ` Christoph Hellwig
2 siblings, 0 replies; 4+ messages in thread
From: Petr Tesarik @ 2008-02-26 11:03 UTC (permalink / raw)
To: linux-ia64
On Mon, 2008-02-11 at 23:29 -0500, Christoph Hellwig wrote:
> All these patches looks really great to me from the ptrace perspective.
>
> While you're at cleaning up arch_ptrace it might be worth to convert
> this odd indentation
>
> > switch (request) {
> > case PTRACE_PEEKTEXT:
> > case PTRACE_PEEKDATA:
>
> into the normal
>
> switch (request) {
> case PTRACE_PEEKTEXT:
> case PTRACE_PEEKDATA:
Well, if this was the only objection to the whole patch series, it's a
pleasure to post a patch with the correct switch statement indentation.
When do you plan to add this series to git?
arch_ptrace() cleanup
Remove duplicate code, clean up goto's and indentation.
Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
CC: Tony Luck <tony.luck@intel.com>
CC: Christoph Hellwig <hch@infradead.org>
diff --git a/arch/ia64/kernel/ptrace.c b/arch/ia64/kernel/ptrace.c
index f10c8b4..7e0d7dc 100644
--- a/arch/ia64/kernel/ptrace.c
+++ b/arch/ia64/kernel/ptrace.c
@@ -1491,88 +1491,60 @@ user_disable_single_step (struct task_st
void
ptrace_disable (struct task_struct *child)
{
- struct ia64_psr *child_psr = ia64_psr(task_pt_regs(child));
-
- /* make sure the single step/taken-branch trap bits are not set: */
- clear_tsk_thread_flag(child, TIF_SINGLESTEP);
- child_psr->ss = 0;
- child_psr->tb = 0;
+ user_disable_single_step(child);
}
long
arch_ptrace (struct task_struct *child, long request, long addr, long data)
{
- struct pt_regs *pt;
- struct switch_stack *sw;
- long ret;
-
- pt = task_pt_regs(child);
- sw = (struct switch_stack *) (child->thread.ksp + 16);
-
switch (request) {
- case PTRACE_PEEKTEXT:
- case PTRACE_PEEKDATA:
+ case PTRACE_PEEKTEXT:
+ case PTRACE_PEEKDATA:
/* read word at location addr */
if (access_process_vm(child, addr, &data, sizeof(data), 0)
- != sizeof(data)) {
- ret = -EIO;
- goto out_tsk;
- }
- ret = data;
- /* ensure "ret" is not mistaken as an error code */
+ != sizeof(data))
+ return -EIO;
+ /* ensure return value is not mistaken for error code */
force_successful_syscall_return();
- goto out_tsk;
+ return data;
/* PTRACE_POKETEXT and PTRACE_POKEDATA is handled
* by the generic ptrace_request().
*/
- case PTRACE_PEEKUSR:
+ case PTRACE_PEEKUSR:
/* read the word at addr in the USER area */
- if (access_uarea(child, addr, &data, 0) < 0) {
- ret = -EIO;
- goto out_tsk;
- }
- ret = data;
- /* ensure "ret" is not mistaken as an error code */
+ if (access_uarea(child, addr, &data, 0) < 0)
+ return -EIO;
+ /* ensure return value is not mistaken for error code */
force_successful_syscall_return();
- goto out_tsk;
+ return data;
- case PTRACE_POKEUSR:
+ case PTRACE_POKEUSR:
/* write the word at addr in the USER area */
- if (access_uarea(child, addr, &data, 1) < 0) {
- ret = -EIO;
- goto out_tsk;
- }
- ret = 0;
- goto out_tsk;
+ if (access_uarea(child, addr, &data, 1) < 0)
+ return -EIO;
+ return 0;
- case PTRACE_OLD_GETSIGINFO:
+ case PTRACE_OLD_GETSIGINFO:
/* for backwards-compatibility */
- ret = ptrace_request(child, PTRACE_GETSIGINFO, addr, data);
- goto out_tsk;
+ return ptrace_request(child, PTRACE_GETSIGINFO, addr, data);
- case PTRACE_OLD_SETSIGINFO:
+ case PTRACE_OLD_SETSIGINFO:
/* for backwards-compatibility */
- ret = ptrace_request(child, PTRACE_SETSIGINFO, addr, data);
- goto out_tsk;
-
- case PTRACE_GETREGS:
- ret = ptrace_getregs(child,
- (struct pt_all_user_regs __user *) data);
- goto out_tsk;
-
- case PTRACE_SETREGS:
- ret = ptrace_setregs(child,
- (struct pt_all_user_regs __user *) data);
- goto out_tsk;
-
- default:
- ret = ptrace_request(child, request, addr, data);
- goto out_tsk;
+ return ptrace_request(child, PTRACE_SETSIGINFO, addr, data);
+
+ case PTRACE_GETREGS:
+ return ptrace_getregs(child,
+ (struct pt_all_user_regs __user *) data);
+
+ case PTRACE_SETREGS:
+ return ptrace_setregs(child,
+ (struct pt_all_user_regs __user *) data);
+
+ default:
+ return ptrace_request(child, request, addr, data);
}
- out_tsk:
- return ret;
}
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH 6/6] arch_ptrace() cleanup
2008-02-11 21:44 [PATCH 6/6] arch_ptrace() cleanup Petr Tesarik
2008-02-12 4:29 ` Christoph Hellwig
2008-02-26 11:03 ` Petr Tesarik
@ 2008-02-26 17:09 ` Christoph Hellwig
2 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2008-02-26 17:09 UTC (permalink / raw)
To: linux-ia64
On Tue, Feb 26, 2008 at 12:03:28PM +0100, Petr Tesarik wrote:
> Well, if this was the only objection to the whole patch series, it's a
> pleasure to post a patch with the correct switch statement indentation.
This wasn't even an objection, just an additional suggestion.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-02-26 17:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-11 21:44 [PATCH 6/6] arch_ptrace() cleanup Petr Tesarik
2008-02-12 4:29 ` Christoph Hellwig
2008-02-26 11:03 ` Petr Tesarik
2008-02-26 17:09 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox