[PATCH 4/8] staging: rtl8192e: Use standard function in rtllib_rx_check_duplicate()

Philipp Hortmann posted 8 patches 2 years, 3 months ago
There is a newer version of this series
[PATCH 4/8] staging: rtl8192e: Use standard function in rtllib_rx_check_duplicate()
Posted by Philipp Hortmann 2 years, 3 months ago
Use standard function ieee80211_is_beacon() to avoid proprietary code and
to increase readability.

Signed-off-by: Philipp Hortmann <philipp.g.hortmann@gmail.com>
---
 drivers/staging/rtl8192e/rtllib_rx.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c
index 89c8d66765fe..80eee43ee444 100644
--- a/drivers/staging/rtl8192e/rtllib_rx.c
+++ b/drivers/staging/rtl8192e/rtllib_rx.c
@@ -904,11 +904,8 @@ static int rtllib_rx_check_duplicate(struct rtllib_device *ieee,
 {
 	struct rtllib_hdr_4addr *hdr = (struct rtllib_hdr_4addr *)skb->data;
 	u16 fc, sc;
-	u8 frag, type, stype;
+	u8 frag;
 
-	fc = le16_to_cpu(hdr->frame_ctl);
-	type = WLAN_FC_GET_TYPE(fc);
-	stype = WLAN_FC_GET_STYPE(fc);
 	sc = le16_to_cpu(hdr->seq_ctl);
 	frag = WLAN_GET_SEQ_FRAG(sc);
 
@@ -916,8 +913,7 @@ static int rtllib_rx_check_duplicate(struct rtllib_device *ieee,
 		!ieee->current_network.qos_data.active ||
 		!IsDataFrame(skb->data) ||
 		IsLegacyDataFrame(skb->data)) {
-		if (!((type == RTLLIB_FTYPE_MGMT) &&
-		      (stype == RTLLIB_STYPE_BEACON))) {
+		if (!ieee80211_is_beacon(hdr->frame_ctl)) {
 			if (is_duplicate_packet(ieee, hdr))
 				return -1;
 		}
-- 
2.41.0
Re: [PATCH 4/8] staging: rtl8192e: Use standard function in rtllib_rx_check_duplicate()
Posted by kernel test robot 2 years, 3 months ago
Hi Philipp,

kernel test robot noticed the following build warnings:

[auto build test WARNING on staging/staging-testing]

url:    https://github.com/intel-lab-lkp/linux/commits/Philipp-Hortmann/staging-rtl8192e-Remove-useless-equation-in-debug-output/20230910-022154
base:   staging/staging-testing
patch link:    https://lore.kernel.org/r/c636aadd4cf4898c57c348a1d789790c5a459749.1694282907.git.philipp.g.hortmann%40gmail.com
patch subject: [PATCH 4/8] staging: rtl8192e: Use standard function in rtllib_rx_check_duplicate()
config: i386-allyesconfig (https://download.01.org/0day-ci/archive/20230912/202309120956.6aSRBSxJ-lkp@intel.com/config)
compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230912/202309120956.6aSRBSxJ-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202309120956.6aSRBSxJ-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/staging/rtl8192e/rtllib_rx.c:925:9: warning: variable 'fc' is uninitialized when used here [-Wuninitialized]
                           if ((fc & (1 << 11)) && (frag == pRxTS->rx_last_frag_num) &&
                                ^~
   drivers/staging/rtl8192e/rtllib_rx.c:906:8: note: initialize the variable 'fc' to silence this warning
           u16 fc, sc;
                 ^
                  = 0
   1 warning generated.


vim +/fc +925 drivers/staging/rtl8192e/rtllib_rx.c

94a799425eee82 Larry Finger       2011-08-23  901  
49aab5fd9df153 Larry Finger       2011-08-25  902  static int rtllib_rx_check_duplicate(struct rtllib_device *ieee,
49aab5fd9df153 Larry Finger       2011-08-25  903  				     struct sk_buff *skb, u8 multicast)
94a799425eee82 Larry Finger       2011-08-23  904  {
94a799425eee82 Larry Finger       2011-08-23  905  	struct rtllib_hdr_4addr *hdr = (struct rtllib_hdr_4addr *)skb->data;
94a799425eee82 Larry Finger       2011-08-23  906  	u16 fc, sc;
ffed9955529a37 Philipp Hortmann   2023-09-09  907  	u8 frag;
94a799425eee82 Larry Finger       2011-08-23  908  
94a799425eee82 Larry Finger       2011-08-23  909  	sc = le16_to_cpu(hdr->seq_ctl);
94a799425eee82 Larry Finger       2011-08-23  910  	frag = WLAN_GET_SEQ_FRAG(sc);
94a799425eee82 Larry Finger       2011-08-23  911  
ccdbe14b77a5e3 Philipp Hortmann   2022-11-13  912  	if (!ieee->ht_info->cur_rx_reorder_enable ||
94a799425eee82 Larry Finger       2011-08-23  913  		!ieee->current_network.qos_data.active ||
94a799425eee82 Larry Finger       2011-08-23  914  		!IsDataFrame(skb->data) ||
94a799425eee82 Larry Finger       2011-08-23  915  		IsLegacyDataFrame(skb->data)) {
ffed9955529a37 Philipp Hortmann   2023-09-09  916  		if (!ieee80211_is_beacon(hdr->frame_ctl)) {
db8971b618ed96 Larry Finger       2011-08-25  917  			if (is_duplicate_packet(ieee, hdr))
94a799425eee82 Larry Finger       2011-08-23  918  				return -1;
94a799425eee82 Larry Finger       2011-08-23  919  		}
94a799425eee82 Larry Finger       2011-08-23  920  	} else {
2c47ae282a4bba Larry Finger       2011-07-18  921  		struct rx_ts_record *pRxTS = NULL;
3a6b70c3f3558a Matthew Casey      2014-08-22  922  
74724de1c40192 Larry Finger       2011-07-18  923  		if (GetTs(ieee, (struct ts_common_info **)&pRxTS, hdr->addr2,
94a799425eee82 Larry Finger       2011-08-23  924  			(u8)Frame_QoSTID((u8 *)(skb->data)), RX_DIR, true)) {
3b32b210c0717d William Durand     2021-03-01 @925  			if ((fc & (1 << 11)) && (frag == pRxTS->rx_last_frag_num) &&
6d852649821da7 William Durand     2021-03-01  926  			    (WLAN_GET_SEQ_SEQ(sc) == pRxTS->rx_last_seq_num))
94a799425eee82 Larry Finger       2011-08-23  927  				return -1;
3b32b210c0717d William Durand     2021-03-01  928  			pRxTS->rx_last_frag_num = frag;
6d852649821da7 William Durand     2021-03-01  929  			pRxTS->rx_last_seq_num = WLAN_GET_SEQ_SEQ(sc);
94a799425eee82 Larry Finger       2011-08-23  930  		} else {
11e672c3e2d2a1 Mateusz Kulikowski 2015-05-31  931  			netdev_warn(ieee->dev, "%s(): No TS! Skip the check!\n",
11e672c3e2d2a1 Mateusz Kulikowski 2015-05-31  932  				    __func__);
94a799425eee82 Larry Finger       2011-08-23  933  			return -1;
94a799425eee82 Larry Finger       2011-08-23  934  		}
94a799425eee82 Larry Finger       2011-08-23  935  	}
94a799425eee82 Larry Finger       2011-08-23  936  
94a799425eee82 Larry Finger       2011-08-23  937  	return 0;
94a799425eee82 Larry Finger       2011-08-23  938  }
db8971b618ed96 Larry Finger       2011-08-25  939  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki