Skip to contentSkip to conversation

drivers/dma: drop unnecesary memset

PATCH In review Julia Lawall 2 participants 2 messages Dec 19, 2009 – Dec 23, 2009

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

PATCH 2/2 drivers/dma: drop unnecesary memset

From: Julia Lawall <[email protected]>

memset of 0 is not needed after kzalloc

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

// <smpl>
@@
expression x;
statement S;
@@

x = kzalloc(...);
if (x = NULL) S
... when != x
-memset(x,0,...);// </smpl>

---
 drivers/dma/dw_dmac.c |    2 --
 1 file changed, 2 deletions(-)
drivers/dma/dw_dmac.c +0 -2
diff -u -p a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
@@ -1270,8 +1270,6 @@ static int __init dw_probe(struct platfo
 		goto err_kfree;
 	}
 
-	memset(dw, 0, sizeof *dw);
-
 	dw->regs = ioremap(io->start, DW_REGLEN);
 	if (!dw->regs) {
 		err = -ENOMEM;
Acked-by on v1 2/2
#1 lore raw
Quoted 28 lines · Julia Lawall

From: Julia Lawall <[email protected]>

memset of 0 is not needed after kzalloc

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

// <smpl>
@@
expression x;
statement S;
@@

x = kzalloc(...);
if (x = NULL) S
... when != x
-memset(x,0,...);// </smpl>

---
 drivers/dma/dw_dmac.c |    2 --
 1 file changed, 2 deletions(-)

diff -u -p a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c

drivers/dma/dw_dmac.c static int __init dw_probe(struct platfo · line 1275

Quoted 8 lines
drivers/dma/dw_dmac.c +0 -2
@@ -1270,8 +1270,6 @@ static int __init dw_probe(struct platfo
 		goto err_kfree;
 	}
 
-	memset(dw, 0, sizeof *dw);
-
 	dw->regs = ioremap(io->start, DW_REGLEN);
 	if (!dw->regs) {
 		err = -ENOMEM;