Commit 61e305c7 authored by Oleg Nesterov's avatar Oleg Nesterov Committed by Linus Torvalds

ptrace/x86: cleanup ptrace_set_debugreg()

ptrace_set_debugreg() is trivial but looks horrible.  Kill the unnecessary
goto's and return's to cleanup the code.

This matches ptrace_get_debugreg() which also needs the trivial whitespace
cleanups.
Signed-off-by: default avatarOleg Nesterov <oleg@redhat.com>
Acked-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: Michael Neuling <mikey@neuling.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Prasad <prasad@linux.vnet.ibm.com>
Cc: Russell King <linux@arm.linux.org.uk>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent b87a95ad
...@@ -703,7 +703,7 @@ static int ptrace_write_dr7(struct task_struct *tsk, unsigned long data) ...@@ -703,7 +703,7 @@ static int ptrace_write_dr7(struct task_struct *tsk, unsigned long data)
*/ */
static unsigned long ptrace_get_debugreg(struct task_struct *tsk, int n) static unsigned long ptrace_get_debugreg(struct task_struct *tsk, int n)
{ {
struct thread_struct *thread = &(tsk->thread); struct thread_struct *thread = &tsk->thread;
unsigned long val = 0; unsigned long val = 0;
if (n < HBP_NUM) { if (n < HBP_NUM) {
...@@ -713,7 +713,7 @@ static unsigned long ptrace_get_debugreg(struct task_struct *tsk, int n) ...@@ -713,7 +713,7 @@ static unsigned long ptrace_get_debugreg(struct task_struct *tsk, int n)
val = bp->hw.info.address; val = bp->hw.info.address;
} else if (n == 6) { } else if (n == 6) {
val = thread->debugreg6; val = thread->debugreg6;
} else if (n == 7) { } else if (n == 7) {
val = thread->ptrace_dr7; val = thread->ptrace_dr7;
} }
return val; return val;
...@@ -761,30 +761,20 @@ static int ptrace_set_breakpoint_addr(struct task_struct *tsk, int nr, ...@@ -761,30 +761,20 @@ static int ptrace_set_breakpoint_addr(struct task_struct *tsk, int nr,
static int ptrace_set_debugreg(struct task_struct *tsk, int n, static int ptrace_set_debugreg(struct task_struct *tsk, int n,
unsigned long val) unsigned long val)
{ {
struct thread_struct *thread = &(tsk->thread); struct thread_struct *thread = &tsk->thread;
int rc = 0;
/* There are no DR4 or DR5 registers */ /* There are no DR4 or DR5 registers */
if (n == 4 || n == 5) int rc = -EIO;
return -EIO;
if (n == 6) {
thread->debugreg6 = val;
goto ret_path;
}
if (n < HBP_NUM) { if (n < HBP_NUM) {
rc = ptrace_set_breakpoint_addr(tsk, n, val); rc = ptrace_set_breakpoint_addr(tsk, n, val);
if (rc) } else if (n == 6) {
return rc; thread->debugreg6 = val;
} rc = 0;
/* All that's left is DR7 */ } else if (n == 7) {
if (n == 7) {
rc = ptrace_write_dr7(tsk, val); rc = ptrace_write_dr7(tsk, val);
if (!rc) if (!rc)
thread->ptrace_dr7 = val; thread->ptrace_dr7 = val;
} }
ret_path:
return rc; return rc;
} }
......
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