Skip to contentSkip to conversation

arch/xtensa/kernel/process.c: take size of pointed value, not pointer

PATCH In review Julia Lawall 1 participant 1 message Sep 16, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 4/4 arch/xtensa/kernel/process.c: take size of pointed value, not pointer

From: Julia Lawall <[email protected]>

Sizeof a pointer-typed expression returns the size of the pointer, not that of the pointed data.

The semantic patch that fixes this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression *e;
type T;
identifier f;
@@

f(...,(T)e,...,
-sizeof(e)
+sizeof(*e)
,...)
// </smpl>

---
 arch/xtensa/kernel/process.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/xtensa/kernel/process.c +1 -1
diff -u -p a/arch/xtensa/kernel/process.c b/arch/xtensa/kernel/process.c
@@ -277,7 +277,7 @@ void xtensa_elf_core_copy_regs (xtensa_g
 
 	/* Don't leak any random bits. */
 
-	memset(elfregs, 0, sizeof (elfregs));
+	memset(elfregs, 0, sizeof(*elfregs));
 
 	/* Note:  PS.EXCM is not set while user task is running; its
 	 * being set in regs->ps is for exception handling convenience.