Skip to contentSkip to conversation

Replace memset with eth_zero_addr

PATCH Superseded Shraddha Barke 3 participants 8 messages Oct 5, 2015 Staging

lore
Share & tools
lore
#0 lore raw

v3 cover Replace memset with eth_zero_addr

These patches replace memset with eth_zero_addr. Change is made using Coccinelle script -

// <smpl>
@eth_zero_addr@
expression e;
@@

-memset(e,0x00,ETH_ALEN);
+eth_zero_addr(e);
// </smpl>

Changes in v3-
Added appropriate header file to the second patch.

Changes in v2-
Dropped second patch in series because it breaks the build

Shraddha Barke (2):
Staging: wilc1000: wilc_wfi_cfgoperations: Replace memset with
eth_zero_addr
Staging: wilc1000: host_interface: Replace memset with eth_zero_addr

 drivers/staging/wilc1000/host_interface.c         | 13 +++++++------
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c |  6 +++---
 2 files changed, 10 insertions(+), 9 deletions(-)
Signature · 1 line
2.1.4
#1 lore raw

PATCH v3 1/2 Staging: wilc1000: wilc_wfi_cfgoperations: Replace memset with eth_zero_addr

Use eth_zero_addr to assign the zero address to the given address array instead of memset when second argument is address of zero.

The Coccinelle patch used -

// <smpl>
@eth_zero_addr@
expression e;
@@

-memset(e,0x00,ETH_ALEN);
+eth_zero_addr(e);
// </smpl>

---
Changes in v3-
No change.

Changes in v2-
No change.

 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +3 -3
index 04838f1..7cf39b29 100644
@@ -562,7 +562,7 @@ static void CfgConnectResult(tenuConnDisconnEvent enuConnDisconnEvent,
 			 *  = SUCCESSFUL_STATUSCODE, while mac status is MAC_DISCONNECTED (which means something wrong happened) */
 			u16ConnectStatus = WLAN_STATUS_UNSPECIFIED_FAILURE;
 			linux_wlan_set_bssid(priv->dev, NullBssid);
-			memset(u8ConnectedSSID, 0, ETH_ALEN);
+			eth_zero_addr(u8ConnectedSSID);
 
 			/*Invalidate u8WLANChannel value on wlan0 disconnect*/
 			if (!pstrWFIDrv->u8P2PConnect)
@@ -619,9 +619,9 @@ static void CfgConnectResult(tenuConnDisconnEvent enuConnDisconnEvent,
 		u8P2Plocalrandom = 0x01;
 		u8P2Precvrandom = 0x00;
 		bWilc_ie = false;
-		memset(priv->au8AssociatedBss, 0, ETH_ALEN);
+		eth_zero_addr(priv->au8AssociatedBss);
 		linux_wlan_set_bssid(priv->dev, NullBssid);
-		memset(u8ConnectedSSID, 0, ETH_ALEN);
+		eth_zero_addr(u8ConnectedSSID);
 
 		/*Invalidate u8WLANChannel value on wlan0 disconnect*/
 		if (!pstrWFIDrv->u8P2PConnect)
Signature · 1 line
2.1.4
maintainer
#2 lore raw

Re: [Outreachy kernel] [PATCH v3 1/2] Staging: wilc1000: wilc_wfi_cfgoperations: Replace memset with eth_zero_addr

Quoted 2 lines · Shraddha Barke

Use eth_zero_addr to assign the zero address to the given address array instead of memset when second argument is address of zero.

How do you know that this is safe to do? You need to document the heck out of this and why you know this is ok. See other patches that do this for examples of what you need to do.

thanks,

greg k-h

#3 lore raw

Re: [Outreachy kernel] [PATCH v3 1/2] Staging: wilc1000: wilc_wfi_cfgoperations: Replace memset with eth_zero_addr

Quoted 7 lines · Greg KH
Quoted 2 lines · Shraddha Barke

Use eth_zero_addr to assign the zero address to the given address array instead of memset when second argument is address of zero.

How do you know that this is safe to do? You need to document the heck out of this and why you know this is ok. See other patches that do this for examples of what you need to do.

This one is just a memset, so I guess there are no constraints on is use?

julia

maintainer
#4 lore raw

Re: [Outreachy kernel] [PATCH v3 1/2] Staging: wilc1000: wilc_wfi_cfgoperations: Replace memset with eth_zero_addr

Quoted 11 lines · Julia Lawall
Quoted 7 lines · Greg KH
Quoted 2 lines · Shraddha Barke

Use eth_zero_addr to assign the zero address to the given address array instead of memset when second argument is address of zero.

How do you know that this is safe to do? You need to document the heck out of this and why you know this is ok. See other patches that do this for examples of what you need to do.

This one is just a memset, so I guess there are no constraints on is use?

I do not know, I thought the constraints were there for all eth_* function calls.

thanks,

greg k-h

#5 lore raw

Re: [Outreachy kernel] [PATCH v3 1/2] Staging: wilc1000: wilc_wfi_cfgoperations: Replace memset with eth_zero_addr

Quoted 7 lines · Greg KH
Quoted 6 lines · Julia Lawall
Quoted 4 lines · Greg KH
Quoted 2 lines · Shraddha Barke

Use eth_zero_addr to assign the zero address to the given address array instead of memset when second argument is address of zero.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

How do you know that this is safe to do? You need to document the heck out of this and why you know this is ok. See other patches that do this for examples of what you need to do.

This one is just a memset, so I guess there are no constraints on is use?

I do not know, I thought the constraints were there for all eth_* function calls.

The definition is just:

244 static inline void eth_zero_addr(u8 *addr)
245 {
246 memset(addr, 0x00, ETH_ALEN);
247 }

julia

maintainer
#6 lore raw

Re: [Outreachy kernel] [PATCH v3 1/2] Staging: wilc1000: wilc_wfi_cfgoperations: Replace memset with eth_zero_addr

Quoted 18 lines · Julia Lawall
Quoted 7 lines · Greg KH
Quoted 6 lines · Julia Lawall
Quoted 4 lines · Greg KH
Quoted 2 lines · Shraddha Barke

Use eth_zero_addr to assign the zero address to the given address array instead of memset when second argument is address of zero.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

How do you know that this is safe to do? You need to document the heck out of this and why you know this is ok. See other patches that do this for examples of what you need to do.

This one is just a memset, so I guess there are no constraints on is use?

I do not know, I thought the constraints were there for all eth_* function calls.

Quoted 6 lines

The definition is just:

244 static inline void eth_zero_addr(u8 *addr)
245 {
246 memset(addr, 0x00, ETH_ALEN);
247 }

Ah, didn't know that, nevermind then.

Shraddha, can you please resend this series?

thanks,

greg k-h

#7 lore raw

PATCH v3 2/2 Staging: wilc1000: host_interface: Replace memset with eth_zero_addr

In reply to Shraddha Barke

Use eth_zero_addr to assign the zero address to the given address array instead of memset when second argument is address of zero.

The Coccinelle patch used -

// <smpl>
@eth_zero_addr@
expression e;
@@

-memset(e,0x00,ETH_ALEN);
+eth_zero_addr(e);
// </smpl>

---
Changes in v3-
Added appropriate header file

Changes in v2-
Had dropped this patch since the change without header file broke the build.

 drivers/staging/wilc1000/host_interface.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/staging/wilc1000/host_interface.c +7 -6
index 39d72ac..1ad1526 100644
@@ -6,6 +6,7 @@
 #include "coreconfigurator.h"
 #include "wilc_wlan_if.h"
 #include "wilc_msgqueue.h"
+#include <linux/etherdevice.h>
 
 extern u8 connecting;
 
@@ -1950,7 +1951,7 @@ static s32 Handle_ConnectTimeout(tstrWILC_WFIDrv *drvHandler)
 		pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
 	}
 
-	memset(u8ConnectedSSID, 0, ETH_ALEN);
+	eth_zero_addr(u8ConnectedSSID);
 	/*Freeing flushed join request params on connect timeout*/
 	if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
 		kfree(gu8FlushedJoinReq);
@@ -2206,11 +2207,11 @@ static s32 Handle_RcvdGnrlAsyncInfo(tstrWILC_WFIDrv *drvHandler,
 			if ((u8MacStatus == MAC_CONNECTED) &&
 			    (strConnectInfo.u16ConnectStatus != SUCCESSFUL_STATUSCODE))	{
 				PRINT_ER("Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n");
-				memset(u8ConnectedSSID, 0, ETH_ALEN);
+				eth_zero_addr(u8ConnectedSSID);
 
 			} else if (u8MacStatus == MAC_DISCONNECTED)    {
 				PRINT_ER("Received MAC status is MAC_DISCONNECTED\n");
-				memset(u8ConnectedSSID, 0, ETH_ALEN);
+				eth_zero_addr(u8ConnectedSSID);
 			}
 
 			/* TODO: mostafa: correct BSSID should be retrieved from actual BSSID received from AP */
@@ -2329,7 +2330,7 @@ static s32 Handle_RcvdGnrlAsyncInfo(tstrWILC_WFIDrv *drvHandler,
 				PRINT_ER("Connect result callback function is NULL\n");
 			}
 
-			memset(pstrWFIDrv->au8AssociatedBSSID, 0, ETH_ALEN);
+			eth_zero_addr(pstrWFIDrv->au8AssociatedBSSID);
 
 
 			/* Deallocation */
@@ -2791,7 +2792,7 @@ static void Handle_Disconnect(tstrWILC_WFIDrv *drvHandler)
 	g_obtainingIP = false;
 	host_int_set_power_mgmt(pstrWFIDrv, 0, 0);
 
-	memset(u8ConnectedSSID, 0, ETH_ALEN);
+	eth_zero_addr(u8ConnectedSSID);
 
 	s32Error = send_config_pkt(SET_CFG, &strWID, 1, false,
 				   get_id_from_handler(pstrWFIDrv));
@@ -2833,7 +2834,7 @@ static void Handle_Disconnect(tstrWILC_WFIDrv *drvHandler)
 
 		pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
 
-		memset(pstrWFIDrv->au8AssociatedBSSID, 0, ETH_ALEN);
+		eth_zero_addr(pstrWFIDrv->au8AssociatedBSSID);
 
 
 		/* Deallocation */
Signature · 1 line
2.1.4