Skip to contentSkip to conversation

drivers/block: drop unnecesary memset

PATCH In review Julia Lawall 2 participants 2 messages Dec 19, 2009 – Jan 4, 2010

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

PATCH 1/2 drivers/block: 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/block/cciss.c |    1 -
 1 file changed, 1 deletion(-)
drivers/block/cciss.c +0 -1
diff -u -p a/drivers/block/cciss.c b/drivers/block/cciss.c
@@ -4379,7 +4379,6 @@ static void cciss_shutdown(struct pci_de
 		return;
 	}
 	/* write all data in the battery backed cache to disk */
-	memset(flush_buf, 0, 4);
 	return_code = sendcmd_withirq(CCISS_CACHE_FLUSH, h->ctlr, flush_buf,
 		4, 0, CTLR_LUNID, TYPE_CMD);
 	kfree(flush_buf);
Acked-by on v1 1/2
#1 lore raw
Quoted 22 lines

-----Original Message-----
From: Julia Lawall [mailto:[email protected]]
Sent: Saturday, December 19, 2009 1:30 AM
To: Miller, Mike (OS Dev); ISS StorageDev; [email protected]; [email protected]
Subject: [PATCH 1/2] drivers/block: 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;
@@

Quoted 6 lines

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

Quoted 18 lines
---
 drivers/block/cciss.c |    1 -
 1 file changed, 1 deletion(-)

diff -u -p a/drivers/block/cciss.c b/drivers/block/cciss.c

drivers/block/cciss.c +0 -1
@@ -4379,7 +4379,6 @@ static void cciss_shutdown(struct pci_de
 		return;
 	}
 	/* write all data in the battery backed cache to disk */
-	memset(flush_buf, 0, 4);
 	return_code = sendcmd_withirq(CCISS_CACHE_FLUSH, 
 h->ctlr, flush_buf,
 		4, 0, CTLR_LUNID, TYPE_CMD);

kfree(flush_buf);