From 5342dd8f293f42c0cd7b550c3b6927a013e12838 Mon Sep 17 00:00:00 2001 From: Maxim Buzdalov Date: Mon, 8 Jul 2019 04:03:08 +0300 Subject: [PATCH] Get rid of the unnecessary local ieee80211_band enum --- os_dep/linux/ioctl_cfg80211.c | 36 ++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/os_dep/linux/ioctl_cfg80211.c b/os_dep/linux/ioctl_cfg80211.c index ed36a13..dbd6899 100644 --- a/os_dep/linux/ioctl_cfg80211.c +++ b/os_dep/linux/ioctl_cfg80211.c @@ -31,14 +31,18 @@ #define STATION_INFO_ASSOC_REQ_IES 0 #endif /* Linux kernel >= 4.0.0 */ #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)) -enum ieee80211_band { - IEEE80211_BAND_2GHZ = NL80211_BAND_2GHZ, - IEEE80211_BAND_5GHZ = NL80211_BAND_5GHZ, - IEEE80211_BAND_60GHZ = NL80211_BAND_60GHZ, - /* keep last */ - IEEE80211_NUM_BANDS -}; +// Creating your own enum to compare with another one is not very accurate. +// I have rewritten this through defines, so that it means the same, while keeping compilers happy. +#define ieee80211_band nl80211_band +#define IEEE80211_BAND_2GHZ NL80211_BAND_2GHZ +#define IEEE80211_BAND_5GHZ NL80211_BAND_5GHZ +#define IEEE80211_BAND_60GHZ NL80211_BAND_60GHZ + +// this was not used in the entire *.c file, so I just safely drop it +/* keep last */ +// IEEE80211_NUM_BANDS + #endif /* Linux kernel >= 4.7.0 */ #include @@ -224,9 +228,7 @@ void rtw_5g_rates_init(struct ieee80211_rate *rates) ); } -struct ieee80211_supported_band *rtw_spt_band_alloc( - enum ieee80211_band band - ) +struct ieee80211_supported_band *rtw_spt_band_alloc(enum ieee80211_band band) { struct ieee80211_supported_band *spt_band = NULL; int n_channels, n_bitrates; @@ -805,17 +807,17 @@ check_bss: struct wiphy *wiphy = pwdev->wiphy; struct ieee80211_channel *notify_channel; u32 freq; - u16 channel = cur_network->network.Configuration.DSConfig; - #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0) - struct cfg80211_roam_info roam_info = {}; + u16 channel = cur_network->network.Configuration.DSConfig; + #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0) + struct cfg80211_roam_info roam_info = {}; #endif freq = rtw_ch2freq(channel); notify_channel = ieee80211_get_channel(wiphy, freq); #endif - DBG_871X(FUNC_ADPT_FMT" call cfg80211_roamed\n", FUNC_ADPT_ARG(padapter)); - #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0) + DBG_871X(FUNC_ADPT_FMT" call cfg80211_roamed\n", FUNC_ADPT_ARG(padapter)); + #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0) { struct cfg80211_roam_info roam_info = { .channel = notify_channel, @@ -3983,8 +3985,8 @@ static int rtw_cfg80211_add_monitor_if(_adapter *padapter, char *name, struct ne mon_ndev->priv_destructor = rtw_ndev_destructor; #else mon_ndev->destructor = rtw_ndev_destructor; -#endif - +#endif + #if (LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,29)) mon_ndev->netdev_ops = &rtw_cfg80211_monitor_if_ops; #else