Skip to contentSkip to conversation

replace memset(x,0,ETH_ALEN) by eth_zero_addr(x)

PATCH New Aya Mahfouz 1 participant 5 messages Mar 3, 2015 Staging

lore
Share & tools
lore
#0 lore raw

v2 cover replace memset(x,0,ETH_ALEN) by eth_zero_addr(x)

Replaces all occurences of memset(x,0,ETH_ALEN) by eth_zero_addr(x). In general,there are two inline functions that wrap memset. One is eth_zero_addr when the assigned address is zero and the second is eth_broadcast_addr when assigning a broadcast address to a variable. Coccinelle was employed for the automation of the process and adding the header linux/etherdevice.h if not added by default.

The set is resent because for some odd reason the first rule of the coccinelle script is emptied by git when generating the patch.

Aya Mahfouz (4):
staging: rtl8192e: replace memset(x,0,ETH_ALEN) by eth_zero_addr(x)
staging: rtl8192e: replace memset(x,0,ETH_ALEN) by eth_zero_addr(x)
staging: rtl8192u: replace memset(x,0,ETH_ALEN) by eth_zero_addr(x)
staging: rtl8192u: ieee80211: replace memset(x,0,ETH_ALEN) by
eth_zero_addr(x)

 drivers/staging/rtl8192e/rtllib_softmac.c                 | 2 +-
 drivers/staging/rtl8192e/rtllib_softmac_wx.c              | 2 +-
 drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c    | 2 +-
 drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

---

Signature · 6 lines
1.9.3


-- 
Kind Regards,
Aya Saif El-yazal Mahfouz
#1 lore raw

PATCH v2 1/4 staging: rtl8192e: replace memset(x,0,ETH_ALEN) by eth_zero_addr(x)

eth_zero_addr() is a wrapper function for memset if 0 is going to be assigned to a mac address. The replacement was done by the following coccinelle script:

@header@
@@

#include <linux/etherdevice.h>

@eth_zero_addr@
expression e;
@@

-memset(e,0,ETH_ALEN);
+eth_zero_addr(e);

@eth_broadcast_addr@
identifier e;
@@

-memset(e,\(0xff\|0xFF\|255\),ETH_ALEN);
+eth_broadcast_addr(e);

@linux_header depends on !header && (eth_zero_addr || eth_broadcast_addr) @ @@

+ #include <linux/etherdevice.h>
+

@special_header depends on !header && !linux_header && (eth_zero_addr || eth_broadcast_addr) @ @@

+
+ #include <linux/etherdevice.h>
+

@custom_header depends on !header && !linux_header && !special_header && (eth_zero_addr || eth_broadcast_addr) @ @@

+
+ #include <linux/etherdevice.h>

---
v2: made sure that the first rule in the script remains intact.

 drivers/staging/rtl8192e/rtllib_softmac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8192e/rtllib_softmac.c +1 -1
index d992a75..16aef7c 100644
@@ -3751,7 +3751,7 @@ void notify_wx_assoc_event(struct rtllib_device *ieee)
 
 		printk(KERN_INFO "%s(): Tell user space disconnected\n",
 		       __func__);
-		memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN);
+		eth_zero_addr(wrqu.ap_addr.sa_data);
 	}
 	wireless_send_event(ieee->dev, SIOCGIWAP, &wrqu, NULL);
 }
Signature · 6 lines
1.9.3


-- 
Kind Regards,
Aya Saif El-yazal Mahfouz
#2 lore raw

PATCH v2 2/4 staging: rtl8192e: replace memset(x,0,ETH_ALEN) by eth_zero_addr(x)

In reply to Aya Mahfouz

eth_zero_addr() is a wrapper function for memset if 0 is going to be assigned to a mac address. The replacement was done by the following coccinelle script:

@header@
@@

#include <linux/etherdevice.h>

@eth_zero_addr@
expression e;
@@

-memset(e,0,ETH_ALEN);
+eth_zero_addr(e);

@eth_broadcast_addr@
identifier e;
@@

-memset(e,\(0xff\|0xFF\|255\),ETH_ALEN);
+eth_broadcast_addr(e);

@linux_header depends on !header && (eth_zero_addr || eth_broadcast_addr) @ @@

+ #include <linux/etherdevice.h>
+

@special_header depends on !header && !linux_header && (eth_zero_addr || eth_broadcast_addr) @ @@

+
+ #include <linux/etherdevice.h>
+

@custom_header depends on !header && !linux_header && !special_header && (eth_zero_addr || eth_broadcast_addr) @ @@

+
+ #include <linux/etherdevice.h>

---
 drivers/staging/rtl8192e/rtllib_softmac_wx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8192e/rtllib_softmac_wx.c +1 -1
index 835f3d7..283ba8b 100644
@@ -120,7 +120,7 @@ int rtllib_wx_get_wap(struct rtllib_device *ieee,
 		ieee->state != RTLLIB_LINKED_SCANNING &&
 		ieee->wap_set == 0)
 
-		memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN);
+		eth_zero_addr(wrqu->ap_addr.sa_data);
 	else
 		memcpy(wrqu->ap_addr.sa_data,
 		       ieee->current_network.bssid, ETH_ALEN);
Signature · 6 lines
1.9.3


-- 
Kind Regards,
Aya Saif El-yazal Mahfouz
#3 lore raw

PATCH v2 3/4 staging: rtl8192u: replace memset(x,0,ETH_ALEN) by eth_zero_addr(x)

In reply to Aya Mahfouz

eth_zero_addr() is a wrapper function for memset if 0 is going to be assigned to a mac address. The replacement was done by the following coccinelle script:

@header@
@@

#include <linux/etherdevice.h>

@eth_zero_addr@
expression e;
@@

-memset(e,0,ETH_ALEN);
+eth_zero_addr(e);

@eth_broadcast_addr@
identifier e;
@@

-memset(e,\(0xff\|0xFF\|255\),ETH_ALEN);
+eth_broadcast_addr(e);

@linux_header depends on !header && (eth_zero_addr || eth_broadcast_addr) @ @@

+ #include <linux/etherdevice.h>
+

@special_header depends on !header && !linux_header && (eth_zero_addr || eth_broadcast_addr) @ @@

+
+ #include <linux/etherdevice.h>
+

@custom_header depends on !header && !linux_header && !special_header && (eth_zero_addr || eth_broadcast_addr) @ @@

+
+ #include <linux/etherdevice.h>

---
v2: made sure that the first rule in the script remains intact.

 drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +1 -1
index 3a54071..3527edc 100644
@@ -3208,7 +3208,7 @@ void notify_wx_assoc_event(struct ieee80211_device *ieee)
 	if (ieee->state == IEEE80211_LINKED)
 		memcpy(wrqu.ap_addr.sa_data, ieee->current_network.bssid, ETH_ALEN);
 	else
-		memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN);
+		eth_zero_addr(wrqu.ap_addr.sa_data);
 	wireless_send_event(ieee->dev, SIOCGIWAP, &wrqu, NULL);
 }
 EXPORT_SYMBOL(notify_wx_assoc_event);
Signature · 6 lines
1.9.3


-- 
Kind Regards,
Aya Saif El-yazal Mahfouz
#4 lore raw

PATCH v2 4/4 staging: rtl8192u: ieee80211: replace memset(x,0,ETH_ALEN) by eth_zero_addr(x)

In reply to Aya Mahfouz

eth_zero_addr() is a wrapper function for memset if 0 is going to be assigned to a mac address. The replacement was done by the following coccinelle script:

@header@
@@

#include <linux/etherdevice.h>

@eth_zero_addr@
expression e;
@@

-memset(e,0,ETH_ALEN);
+eth_zero_addr(e);

@eth_broadcast_addr@
identifier e;
@@

-memset(e,\(0xff\|0xFF\|255\),ETH_ALEN);
+eth_broadcast_addr(e);

@linux_header depends on !header && (eth_zero_addr || eth_broadcast_addr) @ @@

+ #include <linux/etherdevice.h>
+

@special_header depends on !header && !linux_header && (eth_zero_addr || eth_broadcast_addr) @ @@

+
+ #include <linux/etherdevice.h>
+

@custom_header depends on !header && !linux_header && !special_header && (eth_zero_addr || eth_broadcast_addr) @ @@

+
+ #include <linux/etherdevice.h>

---
v2: made sure that the first rule in the script remains intact.

 drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c +1 -1
index 644368d..dcfa5ab 100644
@@ -121,7 +121,7 @@ int ieee80211_wx_get_wap(struct ieee80211_device *ieee,
 		ieee->state != IEEE80211_LINKED_SCANNING &&
 		ieee->wap_set == 0)
 
-		memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN);
+		eth_zero_addr(wrqu->ap_addr.sa_data);
 	else
 		memcpy(wrqu->ap_addr.sa_data,
 		       ieee->current_network.bssid, ETH_ALEN);
Signature · 6 lines
1.9.3


-- 
Kind Regards,
Aya Saif El-yazal Mahfouz