summaryrefslogtreecommitdiffstats
path: root/arch/tile
diff options
context:
space:
mode:
authorChen Gang <gang.chen.5i5j@gmail.com>2014-11-12 03:11:31 +0100
committerChris Metcalf <cmetcalf@tilera.com>2014-11-12 20:27:10 +0100
commita5c1cb63ddf400cf58c7d8aecd045049f6818279 (patch)
treec1ef98848041983ce59a4d0ff1677e6c63242b18 /arch/tile
parenttile: Use the more common pr_warn instead of pr_warning (diff)
downloadlinux-a5c1cb63ddf400cf58c7d8aecd045049f6818279.tar.xz
linux-a5c1cb63ddf400cf58c7d8aecd045049f6818279.zip
arch: tile: kernel: kgdb.c: Use memcpy() instead of pointer copy one by one
Not only memcpy() is faster than pointer copy, but also let code more clearer and simple, which can avoid compiling warning (the original implementation copy registers by exceeding member array border). The related warning (with allmodconfig under tile): CC arch/tile/kernel/kgdb.o arch/tile/kernel/kgdb.c: In function 'sleeping_thread_to_gdb_regs': arch/tile/kernel/kgdb.c:140:31: warning: iteration 53u invokes undefined behavior [-Waggressive-loop-optimizations] *(ptr++) = thread_regs->regs[reg]; ^ arch/tile/kernel/kgdb.c:139:2: note: containing loop for (reg = 0; reg <= TREG_LAST_GPR; reg++) ^ Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com> Signed-off-by: Chris Metcalf <cmetcalf@ezchip.com>
Diffstat (limited to 'arch/tile')
-rw-r--r--arch/tile/kernel/kgdb.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/arch/tile/kernel/kgdb.c b/arch/tile/kernel/kgdb.c
index 4cd88381a83e..ff5335ae050d 100644
--- a/arch/tile/kernel/kgdb.c
+++ b/arch/tile/kernel/kgdb.c
@@ -125,9 +125,7 @@ int dbg_set_reg(int regno, void *mem, struct pt_regs *regs)
void
sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *task)
{
- int reg;
struct pt_regs *thread_regs;
- unsigned long *ptr = gdb_regs;
if (task == NULL)
return;
@@ -136,9 +134,7 @@ sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *task)
memset(gdb_regs, 0, NUMREGBYTES);
thread_regs = task_pt_regs(task);
- for (reg = 0; reg <= TREG_LAST_GPR; reg++)
- *(ptr++) = thread_regs->regs[reg];
-
+ memcpy(gdb_regs, thread_regs, TREG_LAST_GPR * sizeof(unsigned long));
gdb_regs[TILEGX_PC_REGNUM] = thread_regs->pc;
gdb_regs[TILEGX_FAULTNUM_REGNUM] = thread_regs->faultnum;
}