[OPW,kernel,06/10] staging: rtl8192e: Replace memcpy with struct assignement
diff mbox

Message ID 29256a009bd9646ea9563ef6343b5493d7566fcc.1412524266.git.tapaswenipathak@gmail.com
State New, archived
Headers show

Commit Message

Tapasweni Pathak Oct. 5, 2014, 4:04 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/rtl8192e/rtllib_rx.c |    9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

Patch
diff mbox

diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c
index 1c2014f..9626b2d 100644
--- a/drivers/staging/rtl8192e/rtllib_rx.c
+++ b/drivers/staging/rtl8192e/rtllib_rx.c
@@ -2370,7 +2370,7 @@  static inline int is_same_network(struct rtllib_network *src,
 static inline void update_ibss_network(struct rtllib_network *dst,
 				  struct rtllib_network *src)
 {
-	memcpy(&dst->stats, &src->stats, sizeof(struct rtllib_rx_stats));
+	dst->stats = src->stats;
 	dst->last_scanned = jiffies;
 }
 
@@ -2381,7 +2381,7 @@  static inline void update_network(struct rtllib_network *dst,
 	int qos_active;
 	u8 old_param;
 
-	memcpy(&dst->stats, &src->stats, sizeof(struct rtllib_rx_stats));
+	dst->stats = src->stats;
 	dst->capability = src->capability;
 	memcpy(dst->rates, src->rates, src->rates_len);
 	dst->rates_len = src->rates_len;
@@ -2412,7 +2412,7 @@  static inline void update_network(struct rtllib_network *dst,
 	dst->dtim_period = src->dtim_period;
 	dst->dtim_data = src->dtim_data;
 	dst->last_dtim_sta_time = src->last_dtim_sta_time;
-	memcpy(&dst->tim, &src->tim, sizeof(struct rtllib_tim_parameters));
+	dst->tim = src->tim;
 
 	dst->bssht.bdSupportHT = src->bssht.bdSupportHT;
 	dst->bssht.bdRT2RTAggregation = src->bssht.bdRT2RTAggregation;
@@ -2445,8 +2445,7 @@  static inline void update_network(struct rtllib_network *dst,
 	old_param = dst->qos_data.param_count;
 	dst->qos_data.supported = src->qos_data.supported;
 	if (dst->flags & NETWORK_HAS_QOS_PARAMETERS)
-		memcpy(&dst->qos_data, &src->qos_data,
-		       sizeof(struct rtllib_qos_data));
+		dst->qos_data = src->qos_data;
 	if (dst->qos_data.supported == 1) {
 		if (dst->ssid_len)
 			RTLLIB_DEBUG_QOS