netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/5] drivers/net: drop redundant memset
@ 2010-03-09 21:14 Julia Lawall
  0 siblings, 0 replies; 2+ messages in thread
From: Julia Lawall @ 2010-03-09 21:14 UTC (permalink / raw)
  To: Ramkrishna Vepa, Rastapur Santosh, Sivakumar Subramani,
	Sreenivasa Honnur <sreenivasa.honnur

From: Julia Lawall <julia@diku.dk>

The region set by the call to memset is immediately overwritten by the
subsequent call to memcpy.

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

// <smpl>
@@
expression e1,e2,e3,e4;
@@

- memset(e1,e2,e3);
  memcpy(e1,e4,e3);
// </smpl>

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

---
 drivers/net/s2io.c                  |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index df70657..2eb7f8a 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -5819,10 +5819,8 @@ static void s2io_vpd_read(struct s2io_nic *nic)
 		}
 	}
 
-	if ((!fail) && (vpd_data[1] < VPD_STRING_LEN)) {
-		memset(nic->product_name, 0, vpd_data[1]);
+	if ((!fail) && (vpd_data[1] < VPD_STRING_LEN))
 		memcpy(nic->product_name, &vpd_data[3], vpd_data[1]);
-	}
 	kfree(vpd_data);
 	swstats->mem_freed += 256;
 }

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

* Re: [PATCH 2/5] drivers/net: drop redundant memset
       [not found] <Pine.LNX.4.64.1003092213500.4974@ask.diku.dk>
@ 2010-03-15 22:47 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2010-03-15 22:47 UTC (permalink / raw)
  To: julia
  Cc: ram.vepa, santosh.rastapur, sivakumar.subramani,
	sreenivasa.honnur, anil.murthy, netdev, linux-kernel,
	kernel-janitors

From: Julia Lawall <julia@diku.dk>
Date: Tue, 9 Mar 2010 22:14:11 +0100 (CET)

> From: Julia Lawall <julia@diku.dk>
> 
> The region set by the call to memset is immediately overwritten by the
> subsequent call to memcpy.
> 
> The semantic patch that makes this change is as follows:
> (http://coccinelle.lip6.fr/)
> 
> // <smpl>
> @@
> expression e1,e2,e3,e4;
> @@
> 
> - memset(e1,e2,e3);
>   memcpy(e1,e4,e3);
> // </smpl>
> 
> Signed-off-by: Julia Lawall <julia@diku.dk>

Applied, thanks!

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

end of thread, other threads:[~2010-03-15 22:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <Pine.LNX.4.64.1003092213500.4974@ask.diku.dk>
2010-03-15 22:47 ` [PATCH 2/5] drivers/net: drop redundant memset David Miller
2010-03-09 21:14 Julia Lawall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).