From 30b48e2dbe7f4d78fb8f7abbef9851ec36a93dff Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Fri, 16 Sep 2016 19:54:37 +0530 Subject: [PATCH] Staging: ks7010: 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. Script: @header@ @@ #include @r1@ expression e; @@ -memset(e,0,ETH_ALEN); +eth_zero_addr(e); @includeheader depends on r1 && !header@ @@ + #include #include <...> Signed-off-by: Bhumika Goyal Acked-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_hostif.c | 7 ++++--- drivers/staging/ks7010/ks_wlan_net.c | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c index e3cc8ce26344..deb82ab6e4a3 100644 --- a/drivers/staging/ks7010/ks_hostif.c +++ b/drivers/staging/ks7010/ks_hostif.c @@ -14,6 +14,7 @@ #include "eap_packet.h" #include "michael_mic.h" +#include #include #include @@ -780,7 +781,7 @@ void hostif_start_confirm(struct ks_wlan_private *priv) wrqu.data.flags = 0; wrqu.ap_addr.sa_family = ARPHRD_ETHER; if ((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS) { - memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); + eth_zero_addr(wrqu.ap_addr.sa_data); DPRINTK(3, "IWEVENT: disconnect\n"); wireless_send_event(priv->net_dev, SIOCGIWAP, &wrqu, NULL); } @@ -838,7 +839,7 @@ void hostif_connect_indication(struct ks_wlan_private *priv) wrqu0.ap_addr.sa_family = ARPHRD_ETHER; if ((priv->connect_status & CONNECT_STATUS_MASK) == DISCONNECT_STATUS && (old_status & CONNECT_STATUS_MASK) == CONNECT_STATUS) { - memset(wrqu0.ap_addr.sa_data, '\0', ETH_ALEN); + eth_zero_addr(wrqu0.ap_addr.sa_data); DPRINTK(3, "IWEVENT: disconnect\n"); DPRINTK(3, "disconnect :: scan_ind_count=%d\n", priv->scan_ind_count); @@ -910,7 +911,7 @@ void hostif_stop_confirm(struct ks_wlan_private *priv) if ((priv->connect_status & CONNECT_STATUS_MASK) == DISCONNECT_STATUS && (old_status & CONNECT_STATUS_MASK) == CONNECT_STATUS) { - memset(wrqu0.ap_addr.sa_data, '\0', ETH_ALEN); + eth_zero_addr(wrqu0.ap_addr.sa_data); DPRINTK(3, "IWEVENT: disconnect\n"); printk("IWEVENT: disconnect\n"); DPRINTK(3, "disconnect :: scan_ind_count=%d\n", diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index c17c45d66a3f..70cc9bee96c1 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -401,7 +401,7 @@ static int ks_wlan_set_wap(struct net_device *dev, struct iw_request_info *info, priv->need_commit |= SME_MODE_SET; } } else { - memset(priv->reg.bssid, 0x0, ETH_ALEN); + eth_zero_addr(priv->reg.bssid); return -EOPNOTSUPP; } @@ -432,7 +432,7 @@ static int ks_wlan_get_wap(struct net_device *dev, struct iw_request_info *info, if ((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS) { memcpy(awrq->sa_data, &(priv->current_ap.bssid[0]), ETH_ALEN); } else { - memset(awrq->sa_data, 0, ETH_ALEN); + eth_zero_addr(awrq->sa_data); } awrq->sa_family = ARPHRD_ETHER; @@ -2091,7 +2091,7 @@ static int ks_wlan_set_pmksa(struct net_device *dev, list_for_each(ptr, &priv->pmklist.head) { pmk = list_entry(ptr, struct pmk_t, list); if (!memcmp(pmksa->bssid.sa_data, pmk->bssid, ETH_ALEN)) { /* match address! list del. */ - memset(pmk->bssid, 0, ETH_ALEN); + eth_zero_addr(pmk->bssid); memset(pmk->pmkid, 0, IW_PMKID_LEN); list_del_init(&pmk->list); break;