diff mbox

[OPW,kernel,01/10] staging: bcm: Replace memcpy with struct assignment

Message ID 5f8866fa63babf7683f526e86ffa32949a2889e3.1412524266.git.tapaswenipathak@gmail.com
State New, archived
Headers show

Commit Message

Tapasweni Pathak Oct. 5, 2014, 4:02 p.m. UTC
This patch replaces this kind of memcpy() uses as it is
error prone. It is replaced with a struct assignment as it is
typesafe and much easier to read.

This is done by Coccinelle. Coccinelle script used:
// <smpl>
@@
identifier struct_name;
struct struct_name to;
struct struct_name from;
expression E;
@@
-memcpy(&(to), &(from), E);
+to = from;
// </smpl>

Signed-off-by: Tapasweni Pathak <tapaswenipathak@gmail.com>
---
 drivers/staging/bcm/LeakyBucket.c |    3 +--
 drivers/staging/bcm/hostmibs.c    |    4 +---
 2 files changed, 2 insertions(+), 5 deletions(-)

--
1.7.9.5
diff mbox

Patch

diff --git a/drivers/staging/bcm/LeakyBucket.c b/drivers/staging/bcm/LeakyBucket.c
index d6b55f9..8871723 100644
--- a/drivers/staging/bcm/LeakyBucket.c
+++ b/drivers/staging/bcm/LeakyBucket.c
@@ -39,8 +39,7 @@  static VOID UpdateTokenCount(register struct bcm_mini_adapter *Adapter)
 				curr_pi->uiCurrentTokenCount += (ULONG)
 					((curr_pi->uiMaxAllowedRate) *
 					((ULONG)((liCurrentTime)))/1000);
-				memcpy(&curr_pi->stLastUpdateTokenAt, &tv,
-				       sizeof(struct timeval));
+				curr_pi->stLastUpdateTokenAt = tv;
 				curr_pi->liLastUpdateTokenAt = liCurrentTime;
 				if (curr_pi->uiCurrentTokenCount >=
 				    curr_pi->uiMaxBucketSize) {
diff --git a/drivers/staging/bcm/hostmibs.c b/drivers/staging/bcm/hostmibs.c
index f9b08a5..194ef60 100644
--- a/drivers/staging/bcm/hostmibs.c
+++ b/drivers/staging/bcm/hostmibs.c
@@ -104,9 +104,7 @@  INT ProcessGetHostMibs(struct bcm_mini_adapter *Adapter,
 VOID GetDroppedAppCntrlPktMibs(struct bcm_host_stats_mibs *pstHostMibs,
 			       struct bcm_tarang_data *pTarang)
 {
-	memcpy(&(pstHostMibs->stDroppedAppCntrlMsgs),
-	       &(pTarang->stDroppedAppCntrlMsgs),
-	       sizeof(struct bcm_mibs_dropped_cntrl_msg));
+	pstHostMibs->stDroppedAppCntrlMsgs = pTarang->stDroppedAppCntrlMsgs;
 }

 VOID CopyMIBSExtendedSFParameters(struct bcm_mini_adapter *Adapter,