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

Message ID e292abc0cde194f947fc4afc943c52b4d736c1ef.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/rtl8192u/ieee80211/ieee80211_rx.c |    7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

--
1.7.9.5

Patch
diff mbox

diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
index 73de9e9..6424206 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
@@ -2292,7 +2292,7 @@  static inline void update_network(struct ieee80211_network *dst,
 	int qos_active;
 	u8 old_param;

-	memcpy(&dst->stats, &src->stats, sizeof(struct ieee80211_rx_stats));
+	dst->stats = src->stats;
 	dst->capability = src->capability;
 	memcpy(dst->rates, src->rates, src->rates_len);
 	dst->rates_len = src->rates_len;
@@ -2320,7 +2320,7 @@  static inline void update_network(struct ieee80211_network *dst,
 	dst->dtim_data = src->dtim_data;
 	dst->last_dtim_sta_time[0] = src->last_dtim_sta_time[0];
 	dst->last_dtim_sta_time[1] = src->last_dtim_sta_time[1];
-	memcpy(&dst->tim, &src->tim, sizeof(struct ieee80211_tim_parameters));
+	dst->tim = src->tim;

 	dst->bssht.bdSupportHT = src->bssht.bdSupportHT;
 	dst->bssht.bdRT2RTAggregation = src->bssht.bdRT2RTAggregation;
@@ -2347,8 +2347,7 @@  static inline void update_network(struct ieee80211_network *dst,
 	//old_param = dst->qos_data.old_param_count;
 	old_param = dst->qos_data.param_count;
 	if(dst->flags & NETWORK_HAS_QOS_MASK)
-		memcpy(&dst->qos_data, &src->qos_data,
-			sizeof(struct ieee80211_qos_data));
+		dst->qos_data = src->qos_data;
 	else {
 		dst->qos_data.supported = src->qos_data.supported;
 		dst->qos_data.param_count = src->qos_data.param_count;