The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH 1/4] drivers/block/xen-blkback/blkback.c: take size of pointed value, not pointer
@ 2011-09-16  6:57 Julia Lawall
  2011-09-16  7:38 ` Jan Beulich
  0 siblings, 1 reply; 3+ messages in thread
From: Julia Lawall @ 2011-09-16  6:57 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk
  Cc: kernel-janitors, Ian Campbell, Jan Beulich, linux-kernel

From: Julia Lawall <julia@diku.dk>

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>

Signed-off-by: Julia Lawall <julia@diku.dk>

---
 drivers/block/xen-blkback/blkback.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff -u -p a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c
--- a/drivers/block/xen-blkback/blkback.c
+++ b/drivers/block/xen-blkback/blkback.c
@@ -790,7 +790,7 @@ static int __init xen_blkif_init(void)
 	if (rc)
 		goto failed_init;
 
-	memset(blkbk->pending_reqs, 0, sizeof(blkbk->pending_reqs));
+	memset(blkbk->pending_reqs, 0, sizeof(*blkbk->pending_reqs));
 
 	INIT_LIST_HEAD(&blkbk->pending_free);
 	spin_lock_init(&blkbk->pending_free_lock);


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-09-16  8:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-16  6:57 [PATCH 1/4] drivers/block/xen-blkback/blkback.c: take size of pointed value, not pointer Julia Lawall
2011-09-16  7:38 ` Jan Beulich
2011-09-16  8:08   ` Julia Lawall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox