Commit fe5fcefc authored by Liu Shixin's avatar Liu Shixin Committed by Greg Kroah-Hartman
Browse files

staging: rtl8188eu: Use is_{zero/broadcast}_ether_addr() instead of memcmp()



Simplify the code by using is_{zero/broadcast}_ether_addr() instead of
directly using memcmp() to determine if the ethernet address is all
zeros or broadcast address.

Signed-off-by: default avatarLiu Shixin <liushixin2@huawei.com>
Link: https://lore.kernel.org/r/20210609085650.1269008-1-liushixin2@huawei.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 5697686e
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -19,6 +19,7 @@
#include <wlan_bssdef.h>
#include <wlan_bssdef.h>
#include <rtw_ioctl_set.h>
#include <rtw_ioctl_set.h>
#include <linux/vmalloc.h>
#include <linux/vmalloc.h>
#include <linux/etherdevice.h>


extern const u8 MCS_rate_1R[16];
extern const u8 MCS_rate_1R[16];


@@ -179,9 +180,8 @@ struct wlan_network *rtw_find_network(struct __queue *scanned_queue, u8 *addr)
{
{
	struct list_head *phead, *plist;
	struct list_head *phead, *plist;
	struct wlan_network *pnetwork = NULL;
	struct wlan_network *pnetwork = NULL;
	u8 zero_addr[ETH_ALEN] = {0, 0, 0, 0, 0, 0};


	if (!memcmp(zero_addr, addr, ETH_ALEN)) {
	if (is_zero_ether_addr(addr)) {
		pnetwork = NULL;
		pnetwork = NULL;
		goto exit;
		goto exit;
	}
	}
+3 −4
Original line number Original line Diff line number Diff line
@@ -7,6 +7,7 @@
#define _RTW_MLME_EXT_C_
#define _RTW_MLME_EXT_C_


#include <linux/ieee80211.h>
#include <linux/ieee80211.h>
#include <linux/etherdevice.h>
#include <asm/unaligned.h>
#include <asm/unaligned.h>


#include <osdep_service.h>
#include <osdep_service.h>
@@ -4049,13 +4050,12 @@ static void _mgt_dispatcher(struct adapter *padapter,
			    struct mlme_handler *ptable,
			    struct mlme_handler *ptable,
			    struct recv_frame *precv_frame)
			    struct recv_frame *precv_frame)
{
{
	u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
	u8 *pframe = precv_frame->pkt->data;
	u8 *pframe = precv_frame->pkt->data;


	if (ptable->func) {
	if (ptable->func) {
		/* receive the frames that ra(a1) is my address or ra(a1) is bc address. */
		/* receive the frames that ra(a1) is my address or ra(a1) is bc address. */
		if (memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN) &&
		if (memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN) &&
		    memcmp(GetAddr1Ptr(pframe), bc_addr, ETH_ALEN))
		    !is_broadcast_ether_addr(GetAddr1Ptr(pframe)))
			return;
			return;
		ptable->func(padapter, precv_frame);
		ptable->func(padapter, precv_frame);
	}
	}
@@ -4068,7 +4068,6 @@ void mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame)
#ifdef CONFIG_88EU_AP_MODE
#ifdef CONFIG_88EU_AP_MODE
	struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
	struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
#endif
#endif
	u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
	u8 *pframe = precv_frame->pkt->data;
	u8 *pframe = precv_frame->pkt->data;
	struct sta_info *psta = rtw_get_stainfo(&padapter->stapriv, GetAddr2Ptr(pframe));
	struct sta_info *psta = rtw_get_stainfo(&padapter->stapriv, GetAddr2Ptr(pframe));


@@ -4086,7 +4085,7 @@ void mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame)


	/* receive the frames that ra(a1) is my address or ra(a1) is bc address. */
	/* receive the frames that ra(a1) is my address or ra(a1) is bc address. */
	if (memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN) &&
	if (memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN) &&
	    memcmp(GetAddr1Ptr(pframe), bc_addr, ETH_ALEN))
	    !is_broadcast_ether_addr(GetAddr1Ptr(pframe)))
		return;
		return;


	ptable = mlme_sta_tbl;
	ptable = mlme_sta_tbl;
+6 −5
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@
#include <mon.h>
#include <mon.h>
#include <wifi.h>
#include <wifi.h>
#include <linux/vmalloc.h>
#include <linux/vmalloc.h>
#include <linux/etherdevice.h>
#include <net/cfg80211.h>
#include <net/cfg80211.h>


#define LLC_HEADER_SIZE			6	/*  LLC Header Length */
#define LLC_HEADER_SIZE			6	/*  LLC Header Length */
@@ -649,8 +650,8 @@ static int sta2sta_data_frame(struct adapter *adapter,
			goto exit;
			goto exit;
		}
		}


		if (!memcmp(pattrib->bssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) ||
		if (is_zero_ether_addr(pattrib->bssid) ||
		    !memcmp(mybssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) ||
		    is_zero_ether_addr(mybssid) ||
		    memcmp(pattrib->bssid, mybssid, ETH_ALEN)) {
		    memcmp(pattrib->bssid, mybssid, ETH_ALEN)) {
			ret = _FAIL;
			ret = _FAIL;
			goto exit;
			goto exit;
@@ -732,8 +733,8 @@ static int ap2sta_data_frame(struct adapter *adapter,
		}
		}


		/*  check BSSID */
		/*  check BSSID */
		if (!memcmp(pattrib->bssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) ||
		if (is_zero_ether_addr(pattrib->bssid) ||
		    !memcmp(mybssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) ||
		    is_zero_ether_addr(mybssid) ||
		    (memcmp(pattrib->bssid, mybssid, ETH_ALEN))) {
		    (memcmp(pattrib->bssid, mybssid, ETH_ALEN))) {
			RT_TRACE(_module_rtl871x_recv_c_, _drv_info_,
			RT_TRACE(_module_rtl871x_recv_c_, _drv_info_,
				 (" %s:  compare BSSID fail ; BSSID=%pM\n", __func__, (pattrib->bssid)));
				 (" %s:  compare BSSID fail ; BSSID=%pM\n", __func__, (pattrib->bssid)));
+3 −2
Original line number Original line Diff line number Diff line
@@ -5,6 +5,8 @@
 *
 *
 ******************************************************************************/
 ******************************************************************************/


#include <linux/etherdevice.h>

#include "odm_precomp.h"
#include "odm_precomp.h"
#include "phy.h"
#include "phy.h"


@@ -893,7 +895,6 @@ void odm_RSSIMonitorCheckCE(struct odm_dm_struct *pDM_Odm)
	u8	sta_cnt = 0;
	u8	sta_cnt = 0;
	u32 PWDB_rssi[NUM_STA] = {0};/* 0~15]:MACID, [16~31]:PWDB_rssi */
	u32 PWDB_rssi[NUM_STA] = {0};/* 0~15]:MACID, [16~31]:PWDB_rssi */
	struct sta_info *psta;
	struct sta_info *psta;
	u8 bcast_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};


	if (!check_fwstate(&Adapter->mlmepriv, _FW_LINKED))
	if (!check_fwstate(&Adapter->mlmepriv, _FW_LINKED))
		return;
		return;
@@ -902,7 +903,7 @@ void odm_RSSIMonitorCheckCE(struct odm_dm_struct *pDM_Odm)
		psta = pDM_Odm->pODM_StaInfo[i];
		psta = pDM_Odm->pODM_StaInfo[i];
		if (IS_STA_VALID(psta) &&
		if (IS_STA_VALID(psta) &&
		    (psta->state & WIFI_ASOC_STATE) &&
		    (psta->state & WIFI_ASOC_STATE) &&
		    memcmp(psta->hwaddr, bcast_addr, ETH_ALEN) &&
		    !is_broadcast_ether_addr(psta->hwaddr) &&
		    memcmp(psta->hwaddr, myid(&Adapter->eeprompriv), ETH_ALEN)) {
		    memcmp(psta->hwaddr, myid(&Adapter->eeprompriv), ETH_ALEN)) {
			if (psta->rssi_stat.UndecoratedSmoothedPWDB < tmpEntryMinPWDB)
			if (psta->rssi_stat.UndecoratedSmoothedPWDB < tmpEntryMinPWDB)
				tmpEntryMinPWDB = psta->rssi_stat.UndecoratedSmoothedPWDB;
				tmpEntryMinPWDB = psta->rssi_stat.UndecoratedSmoothedPWDB;