Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5149366pxj; Wed, 9 Jun 2021 10:13:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJztxTvtWAwhUN9/Y7sI7B0j7B/RN/iUOu/JBr4ndskkX/PPxUmHB2ejn9iAClWiv9se2EQI X-Received: by 2002:a17:906:1986:: with SMTP id g6mr844216ejd.265.1623258831247; Wed, 09 Jun 2021 10:13:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623258831; cv=none; d=google.com; s=arc-20160816; b=m96vhJEpYHFOqCScBI4qPD2Cea+0fZ4mWQjrc79ywBA491U7nn5unRsDfr7wUcfgAl IQzQ0tL4Zv8FiEaCWu8yisHOH3ZaPlnwOX/XxBmVQCZgFPe5rmFUUZdpaag3wLsfeK90 0CYHt5JbYrdBw2o+jTyy/mSQfq2BG5WZN+Vu0p5NguImHzdAj55AFF1svo1k1p5fv8HS LIwnxGU4jW02+6wAKx7Uv6cZzeirnDXmM/Qnb9YytTX2xjLYso1IP2oYeAP+CjsdSXay UmKirJIAZ3/sffqZwMT4qS1hdh4a7VRbimjWr7Lbgs5jKTJvlzhVCfMokiG2wd7VCEYl 3ALA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=PcAz/nigj7xDCyblkhHxamBS3xGT79JVIj8uN4ryJzk=; b=QYjD5WGDyduGKb+9WE/rZQBbDzMCVytlaazoMZgkuyYqA7wA8IrbVMQYZ51VR1jll5 S7p21LL4fab/M3cWRC6GRCGdMri11d4hvIKHj99bbocAs8TUJCzgyOqKK9ksa0BKz1b9 ICrue9lgiz4Afe18SMXw+fR0LE+4HRoIrgQE7JPitEy9z/Uor7zGtGiIYPTmFuQ6DS6v tDV/4gfzTKr2MLrCkaCWWCAmJ4V0f6JNCOpxHoGTj26NESUupGohJV4ZH/3PJq+ZFH+y EXIky/Z0B3qkSNj7gyKWIjwCx8vWLD6bGKszm7yLEhVRKU7lErTfBDLt2M5Zblot2xM2 qoWg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i7si298030ejo.265.2021.06.09.10.13.26; Wed, 09 Jun 2021 10:13:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237539AbhFII0c (ORCPT + 99 others); Wed, 9 Jun 2021 04:26:32 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:3811 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236161AbhFII0b (ORCPT ); Wed, 9 Jun 2021 04:26:31 -0400 Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4G0Klf72FbzWtNL; Wed, 9 Jun 2021 16:19:42 +0800 (CST) Received: from dggpemm500009.china.huawei.com (7.185.36.225) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Wed, 9 Jun 2021 16:24:34 +0800 Received: from huawei.com (10.175.113.32) by dggpemm500009.china.huawei.com (7.185.36.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Wed, 9 Jun 2021 16:24:34 +0800 From: Liu Shixin To: Greg Kroah-Hartman , Joe Perches , Fabio Aiuto CC: , , "Liu Shixin" Subject: [PATCH -next v2 1/2] staging: rtl8188eu: Use is_{zero/broadcast}_ether_addr() instead of memcmp() Date: Wed, 9 Jun 2021 16:56:49 +0800 Message-ID: <20210609085650.1269008-1-liushixin2@huawei.com> X-Mailer: git-send-email 2.18.0.huawei.25 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500009.china.huawei.com (7.185.36.225) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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: Liu Shixin --- v1->v2: 1. Add the benefit of this patch in changelog. 2. Change the subject line according to fabio's reminder. drivers/staging/rtl8188eu/core/rtw_mlme.c | 4 ++-- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 7 +++---- drivers/staging/rtl8188eu/core/rtw_recv.c | 11 ++++++----- drivers/staging/rtl8188eu/hal/odm.c | 5 +++-- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index ba73ac5325e2..01bbfd29488f 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -19,6 +19,7 @@ #include #include #include +#include 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 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; goto exit; } diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index b4d81d3a856c..8c1bc04dd830 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -7,6 +7,7 @@ #define _RTW_MLME_EXT_C_ #include +#include #include #include @@ -4048,13 +4049,12 @@ static void _mgt_dispatcher(struct adapter *padapter, struct mlme_handler *ptable, struct recv_frame *precv_frame) { - u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; u8 *pframe = precv_frame->pkt->data; if (ptable->func) { /* receive the frames that ra(a1) is my address or ra(a1) is bc address. */ if (memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN) && - memcmp(GetAddr1Ptr(pframe), bc_addr, ETH_ALEN)) + !is_broadcast_ether_addr(GetAddr1Ptr(pframe))) return; ptable->func(padapter, precv_frame); } @@ -4067,7 +4067,6 @@ void mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame) #ifdef CONFIG_88EU_AP_MODE struct mlme_priv *pmlmepriv = &padapter->mlmepriv; #endif - u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; u8 *pframe = precv_frame->pkt->data; struct sta_info *psta = rtw_get_stainfo(&padapter->stapriv, GetAddr2Ptr(pframe)); @@ -4085,7 +4084,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. */ if (memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN) && - memcmp(GetAddr1Ptr(pframe), bc_addr, ETH_ALEN)) + !is_broadcast_ether_addr(GetAddr1Ptr(pframe))) return; ptable = mlme_sta_tbl; diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index e79cfdd4bf90..cb0629fefbc5 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #define ETHERNET_HEADER_SIZE 14 /* Ethernet Header Length */ @@ -651,8 +652,8 @@ static int sta2sta_data_frame(struct adapter *adapter, goto exit; } - if (!memcmp(pattrib->bssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) || - !memcmp(mybssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) || + if (is_zero_ether_addr(pattrib->bssid) || + is_zero_ether_addr(mybssid) || memcmp(pattrib->bssid, mybssid, ETH_ALEN)) { ret = _FAIL; goto exit; @@ -734,9 +735,9 @@ static int ap2sta_data_frame(struct adapter *adapter, } /* check BSSID */ - if (!memcmp(pattrib->bssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) || - !memcmp(mybssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) || - (memcmp(pattrib->bssid, mybssid, ETH_ALEN))) { + if (is_zero_ether_addr(pattrib->bssid) || + is_zero_ether_addr(mybssid) || + (memcmp(pattrib->bssid, mybssid, ETH_ALEN))) { RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, (" %s: compare BSSID fail ; BSSID=%pM\n", __func__, (pattrib->bssid))); RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("mybssid=%pM\n", (mybssid))); diff --git a/drivers/staging/rtl8188eu/hal/odm.c b/drivers/staging/rtl8188eu/hal/odm.c index 8348e02b4c86..041ee2965add 100644 --- a/drivers/staging/rtl8188eu/hal/odm.c +++ b/drivers/staging/rtl8188eu/hal/odm.c @@ -5,6 +5,8 @@ * ******************************************************************************/ +#include + #include "odm_precomp.h" #include "phy.h" @@ -893,7 +895,6 @@ void odm_RSSIMonitorCheckCE(struct odm_dm_struct *pDM_Odm) u8 sta_cnt = 0; u32 PWDB_rssi[NUM_STA] = {0};/* 0~15]:MACID, [16~31]:PWDB_rssi */ struct sta_info *psta; - u8 bcast_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; if (!check_fwstate(&Adapter->mlmepriv, _FW_LINKED)) return; @@ -902,7 +903,7 @@ void odm_RSSIMonitorCheckCE(struct odm_dm_struct *pDM_Odm) psta = pDM_Odm->pODM_StaInfo[i]; if (IS_STA_VALID(psta) && (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)) { if (psta->rssi_stat.UndecoratedSmoothedPWDB < tmpEntryMinPWDB) tmpEntryMinPWDB = psta->rssi_stat.UndecoratedSmoothedPWDB; -- 2.18.0.huawei.25