Browse Source

staging: rtl8723bs: Replace memset with eth_zero_addr

Use eth_zero_addr to assign zero address to the given address array
instead of memset when the second argument in memset is address
of zero. Coccinelle was used to do the replacement and add the
header file linux/etherdevice.h if not already present.

The Coccinelle semantic patch that makes this change is as follows:
@header@
@@
#include <linux/etherdevice.h>

@r1@
expression e;
@@

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

@includeheader depends on r1 && !header@
@@
+ #include <linux/etherdevice.h>
#include <...>

Signed-off-by: Arushi Singhal <arushisinghal19971997@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Arushi Singhal 7 years ago
parent
commit
2dcce8ed66

+ 2 - 1
drivers/staging/rtl8723bs/core/rtw_mlme.c

@@ -14,6 +14,7 @@
  ******************************************************************************/
  ******************************************************************************/
 #define _RTW_MLME_C_
 #define _RTW_MLME_C_
 
 
+#include <linux/etherdevice.h>
 #include <drv_types.h>
 #include <drv_types.h>
 #include <rtw_debug.h>
 #include <rtw_debug.h>
 #include <linux/jiffies.h>
 #include <linux/jiffies.h>
@@ -2109,7 +2110,7 @@ int rtw_select_roaming_candidate(struct mlme_priv *mlme)
 		mlme->roam_network = candidate;
 		mlme->roam_network = candidate;
 
 
 		if (!memcmp(candidate->network.MacAddress, mlme->roam_tgt_addr, ETH_ALEN))
 		if (!memcmp(candidate->network.MacAddress, mlme->roam_tgt_addr, ETH_ALEN))
-			memset(mlme->roam_tgt_addr, 0, ETH_ALEN);
+			eth_zero_addr(mlme->roam_tgt_addr);
 	}
 	}
 
 
 	ret = _SUCCESS;
 	ret = _SUCCESS;

+ 2 - 1
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c

@@ -14,6 +14,7 @@
  ******************************************************************************/
  ******************************************************************************/
 #define  _IOCTL_CFG80211_C_
 #define  _IOCTL_CFG80211_C_
 
 
+#include <linux/etherdevice.h>
 #include <drv_types.h>
 #include <drv_types.h>
 #include <rtw_debug.h>
 #include <rtw_debug.h>
 #include <linux/jiffies.h>
 #include <linux/jiffies.h>
@@ -2391,7 +2392,7 @@ static int cfg80211_rtw_del_pmksa(struct wiphy *wiphy,
 	{
 	{
 		if (!memcmp(psecuritypriv->PMKIDList[index].Bssid, (u8 *)pmksa->bssid, ETH_ALEN))
 		if (!memcmp(psecuritypriv->PMKIDList[index].Bssid, (u8 *)pmksa->bssid, ETH_ALEN))
 		{ /*  BSSID is matched, the same AP => Remove this PMKID information and reset it. */
 		{ /*  BSSID is matched, the same AP => Remove this PMKID information and reset it. */
-			memset(psecuritypriv->PMKIDList[index].Bssid, 0x00, ETH_ALEN);
+			eth_zero_addr(psecuritypriv->PMKIDList[index].Bssid);
 			memset(psecuritypriv->PMKIDList[index].PMKID, 0x00, WLAN_PMKID_LEN);
 			memset(psecuritypriv->PMKIDList[index].PMKID, 0x00, WLAN_PMKID_LEN);
 			psecuritypriv->PMKIDList[index].bUsed = false;
 			psecuritypriv->PMKIDList[index].bUsed = false;
 			bMatched = true;
 			bMatched = true;

+ 5 - 4
drivers/staging/rtl8723bs/os_dep/ioctl_linux.c

@@ -14,6 +14,7 @@
  ******************************************************************************/
  ******************************************************************************/
 #define _IOCTL_LINUX_C_
 #define _IOCTL_LINUX_C_
 
 
+#include <linux/etherdevice.h>
 #include <drv_types.h>
 #include <drv_types.h>
 #include <rtw_debug.h>
 #include <rtw_debug.h>
 #include <rtw_mp.h>
 #include <rtw_mp.h>
@@ -124,7 +125,7 @@ void rtw_indicate_wx_disassoc_event(struct adapter *padapter)
 	memset(&wrqu, 0, sizeof(union iwreq_data));
 	memset(&wrqu, 0, sizeof(union iwreq_data));
 
 
 	wrqu.ap_addr.sa_family = ARPHRD_ETHER;
 	wrqu.ap_addr.sa_family = ARPHRD_ETHER;
-	memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN);
+	eth_zero_addr(wrqu.ap_addr.sa_data);
 }
 }
 
 
 /*
 /*
@@ -1080,7 +1081,7 @@ static int rtw_wx_set_pmkid(struct net_device *dev,
 		for (j = 0 ; j<NUM_PMKID_CACHE; j++) {
 		for (j = 0 ; j<NUM_PMKID_CACHE; j++) {
 			if (!memcmp(psecuritypriv->PMKIDList[j].Bssid, strIssueBssid, ETH_ALEN)) {
 			if (!memcmp(psecuritypriv->PMKIDList[j].Bssid, strIssueBssid, ETH_ALEN)) {
 				/*  BSSID is matched, the same AP => Remove this PMKID information and reset it. */
 				/*  BSSID is matched, the same AP => Remove this PMKID information and reset it. */
-                                memset(psecuritypriv->PMKIDList[ j ].Bssid, 0x00, ETH_ALEN);
+                                eth_zero_addr(psecuritypriv->PMKIDList[j].Bssid);
                                 psecuritypriv->PMKIDList[ j ].bUsed = false;
                                 psecuritypriv->PMKIDList[ j ].bUsed = false;
 				break;
 				break;
 			}
 			}
@@ -1294,7 +1295,7 @@ static int rtw_wx_get_wap(struct net_device *dev,
 
 
 	wrqu->ap_addr.sa_family = ARPHRD_ETHER;
 	wrqu->ap_addr.sa_family = ARPHRD_ETHER;
 
 
-	memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN);
+	eth_zero_addr(wrqu->ap_addr.sa_data);
 
 
 	RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_wap\n"));
 	RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_wap\n"));
 
 
@@ -1303,7 +1304,7 @@ static int rtw_wx_get_wap(struct net_device *dev,
 			((check_fwstate(pmlmepriv, WIFI_AP_STATE)) == true)) {
 			((check_fwstate(pmlmepriv, WIFI_AP_STATE)) == true)) {
 		memcpy(wrqu->ap_addr.sa_data, pcur_bss->MacAddress, ETH_ALEN);
 		memcpy(wrqu->ap_addr.sa_data, pcur_bss->MacAddress, ETH_ALEN);
 	} else {
 	} else {
-		memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN);
+		eth_zero_addr(wrqu->ap_addr.sa_data);
 	}
 	}
 
 
 	return 0;
 	return 0;