brektrou / rtl8821CU

Realtek RTL8811CU/RTL8821CU USB Wi-Fi adapter driver for Linux
GNU General Public License v2.0
1.58k stars 458 forks source link

fix for 5.19.3-arch1-1 (not to be merged) #186

Open ylxdzsw opened 1 year ago

ylxdzsw commented 1 year ago

fixes #185

To be honest I dont know what's happening. I just followed the compilation error and made the whatever changes that satisfy the compiler. It works for me on 5.19.3-arch1-1.

As I modified the code without adding pre-processing branches, this version likely won't work with <5.19.3 kernels. Therefore, this PR is not intended to be merged. I just want to share the patch and wish it can help the maintainers to make a real fix.

MichaIng commented 1 year ago

It partly conflicts with #168, not sure whether static inline or __inline is the better solution here.

wvk commented 1 year ago

works for Debian with kernel 5.19.0, too :+1:

ziman commented 1 year ago

Works on 5.19.12-arch1-1, too. Many thanks! You help not only the devs but also other users. :)

birdofprey commented 1 year ago

works for Debian with kernel 5.19.0, too +1

classicrocker883 commented 1 year ago

This worked for me too!

as soon as I upgraded to the newest Ubuntu 22.10, my bluetooth/wifi adapter wasnt working. I actually had to re make and install for every kernel upgrade.

this fix worked, changing these two files. except, here are the warnings I get. @brektrou @ylxdzsw

/rtl8821CU/core/rtw_sta_mgt.c: In function ‘rtw_mfree_stainfo’:
/rtl8821CU/core/rtw_sta_mgt.c:379:25: warning: the comparison will always evaluate as ‘true’ for the address of ‘lock’ will never be NULL [-Waddress]
  379 |         if (&psta->lock != NULL)
      |                         ^~
In file included from /rtl8821CU/include/drv_types.h:107,
                 from /rtl8821CU/core/rtw_sta_mgt.c:17:
/rtl8821CU/include/sta_info.h:256:17: note: ‘lock’ declared here
  256 |         _lock   lock;
      |                 ^~~~
  CC [M]  /rtl8821CU/core/rtw_ap.o
/rtl8821CU/core/rtw_ap.c: In function ‘rtw_ap_update_chbw_by_ifbmp’:
/rtl8821CU/core/rtw_ap.c:4397:42: warning: the comparison will always evaluate as ‘true’ for the address of ‘padapters’ will never be NULL [-Waddress]
 4397 |                 if (!(ifbmp & BIT(i)) || !dvobj->padapters)
      |                                          ^
In file included from /rtl8821CU/core/rtw_ap.c:17:
/rtl8821CU/include/drv_types.h:1020:19: note: ‘padapters’ declared here
 1020 |         _adapter *padapters[CONFIG_IFACE_NUMBER];/*IFACE_ID_MAX*/
      |                   ^~~~~~~~~
/rtl8821CU/core/rtw_ap.c:4417:42: warning: the comparison will always evaluate as ‘true’ for the address of ‘padapters’ will never be NULL [-Waddress]
 4417 |                 if (!(ifbmp & BIT(i)) || !dvobj->padapters)
      |                                          ^
/rtl8821CU/include/drv_types.h:1020:19: note: ‘padapters’ declared here
 1020 |         _adapter *padapters[CONFIG_IFACE_NUMBER];/*IFACE_ID_MAX*/
      |                   ^~~~~~~~~
/rtl8821CU/os_dep/osdep_service.c: In function ‘rtw_change_ifname’:
/rtl8821CU/os_dep/osdep_service.c:2494:28: warning: passing argument 1 of ‘_rtw_memcpy’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
 2494 |         _rtw_memcpy(pnetdev->dev_addr, adapter_mac_addr(padapter), ETH_ALEN);
      |                     ~~~~~~~^~~~~~~~~~
/rtl8821CU/os_dep/osdep_service.c:925:24: note: expected ‘void *’ but argument is of type ‘const unsigned char *’
  925 | void _rtw_memcpy(void *dst, const void *src, u32 sz)
      |                  ~~~~~~^~~
/rtl8821CU/os_dep/linux/ioctl_linux.c: In function ‘rtw_mp_efuse_set’:
/rtl8821CU/os_dep/linux/ioctl_linux.c:9781:46: warning: passing argument 1 of ‘_rtw_memcpy’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
 9781 |                 _rtw_memcpy(padapter->pnetdev->dev_addr, get_hal_mac_addr(padapter), ETH_ALEN); /* set mac addr to net_device */
      |                             ~~~~~~~~~~~~~~~~~^~~~~~~~~~
In file included from /rtl8821CU/include/drv_types.h:27,
                 from /rtl8821CU/os_dep/linux/ioctl_linux.c:17:
/rtl8821CU/include/osdep_service.h:296:35: note: expected ‘void *’ but argument is of type ‘const unsigned char *’
  296 | extern void     _rtw_memcpy(void *dec, const void *sour, u32 sz);
      |                             ~~~~~~^~~
/rtl8821CU/os_dep/linux/ioctl_cfg80211.c: In function ‘cfg80211_rtw_scan’:
/rtl8821CU/os_dep/linux/ioctl_cfg80211.c:2867:33: warning: the comparison will always evaluate as ‘true’ for the address of ‘ssid’ will never be NULL [-Waddress]
 2867 |                 if (ssids->ssid != NULL
      |                                 ^~
In file included from /rtl8821CU/include/osdep_service_linux.h:93,
                 from /rtl8821CU/include/osdep_service.h:50,
                 from /rtl8821CU/include/drv_types.h:27,
                 from /rtl8821CU/os_dep/linux/ioctl_cfg80211.c:17:
./include/net/cfg80211.h:2302:12: note: ‘ssid’ declared here
 2302 |         u8 ssid[IEEE80211_MAX_SSID_LEN];
      |            ^~~~
/rtl8821CU/hal/hal_hci/hal_usb.c: In function ‘usb_init_recv_priv’:
/rtl8821CU/hal/hal_hci/hal_usb.c:28:22: warning: cast between incompatible function types from ‘void (*)(void *)’ to ‘void (*)(long unsigned int)’ [-Wcast-function-type]
   28 |                      (void(*)(unsigned long))usb_recv_tasklet,
      |                      ^
/rtl8821CU/hal/rtl8821c/usb/rtl8821cu_xmit.c: In function ‘rtl8821cu_init_xmit_priv’:
/rtl8821CU/hal/rtl8821c/usb/rtl8821cu_xmit.c:911:22: warning: cast between incompatible function types from ‘void (*)(void *)’ to ‘void (*)(long unsigned int)’ [-Wcast-function-type]
  911 |                      (void(*)(unsigned long))rtl8821cu_xmit_tasklet,
      |                      ^
rtl8821CU/hal/phydm/phydm_debug.c: In function ‘phydm_debug_trace’:
/rtl8821CU/hal/phydm/phydm_debug.c:2242:21: warning: the comparison will always evaluate as ‘true’ for the pointer operand in ‘input + (sizetype)((long unsigned int)((int)i + 1) * 16)’ must not be NULL [-Waddress]
 2242 |                 if (input[i + 1])
      |                     ^~~~~
/rtl8821CU/hal/phydm/phydm_debug.c: In function ‘phydm_dump_reg’:
/rtl8821CU/hal/phydm/phydm_debug.c:2641:13: warning: the comparison will always evaluate as ‘true’ for the pointer operand in ‘input + 16’ must not be NULL [-Waddress]
 2641 |         if (input[1])
      |             ^~~~~
/rtl8821CU/hal/phydm/phydm_debug.c: In function ‘phydm_per_tone_evm’:
/rtl8821CU/hal/phydm/phydm_debug.c:2792:21: warning: the comparison will always evaluate as ‘true’ for the pointer operand in ‘input + (sizetype)((long unsigned int)((int)i + 1) * 16)’ must not be NULL [-Waddress]
 2792 |                 if (input[i + 1])
      |                     ^~~~~
/rtl8821CU/hal/phydm/phydm_debug.c: In function ‘phydm_api_adjust’:
/rtl8821CU/hal/phydm/phydm_debug.c:2995:21: warning: the comparison will always evaluate as ‘true’ for the pointer operand in ‘input + (sizetype)((long unsigned int)((int)i + 1) * 16)’ must not be NULL [-Waddress]
 2995 |                 if (input[i + 1])
      |                     ^~~~~
/rtl8821CU/hal/phydm/phydm_debug.c: In function ‘phydm_cmd_parser’:
/rtl8821CU/hal/phydm/phydm_debug.c:3240:29: warning: the comparison will always evaluate as ‘true’ for the pointer operand in ‘input + (sizetype)((long unsigned int)(i + 1) * 16)’ must not be NULL [-Waddress]
 3240 |                         if (input[i + 1]) {
      |                             ^~~~~
/rtl8821CU/hal/phydm/phydm_debug.c:3263:29: warning: the comparison will always evaluate as ‘true’ for the pointer operand in ‘input + (sizetype)((long unsigned int)(i + 1) * 16)’ must not be NULL [-Waddress]
 3263 |                         if (input[i + 1]) {
      |                             ^~~~~
/rtl8821CU/hal/phydm/phydm_debug.c:3291:29: warning: the comparison will always evaluate as ‘true’ for the pointer operand in ‘input + (sizetype)((long unsigned int)(i + 1) * 16)’ must not be NULL [-Waddress]
 3291 |                         if (input[i + 1]) {
      |                             ^~~~~
/rtl8821CU/hal/phydm/phydm_debug.c:3305:29: warning: the comparison will always evaluate as ‘true’ for the pointer operand in ‘input + (sizetype)((long unsigned int)(i + 1) * 16)’ must not be NULL [-Waddress]
 3305 |                         if (input[i + 1]) {
      |                             ^~~~~
/rtl8821CU/hal/phydm/phydm_debug.c:3318:29: warning: the comparison will always evaluate as ‘true’ for the pointer operand in ‘input + (sizetype)((long unsigned int)(i + 1) * 16)’ must not be NULL [-Waddress]
 3318 |                         if (input[i + 1]) {
      |                             ^~~~~
/rtl8821CU/hal/phydm/phydm_debug.c:3356:29: warning: the comparison will always evaluate as ‘true’ for the pointer operand in ‘input + (sizetype)((long unsigned int)(i + 1) * 16)’ must not be NULL [-Waddress]
 3356 |                         if (input[i + 1]) {
      |                             ^~~~~
/rtl8821CU/hal/phydm/phydm_debug.c:3384:29: warning: the comparison will always evaluate as ‘true’ for the pointer operand in ‘input + (sizetype)((long unsigned int)(i + 1) * 16)’ must not be NULL [-Waddress]
 3384 |                         if (input[i + 1])
      |                             ^~~~~
/rtl8821CU/hal/phydm/phydm_debug.c:3465:21: warning: the comparison will always evaluate as ‘true’ for the pointer operand in ‘input + 16’ must not be NULL [-Waddress]
 3465 |                 if (input[1])
      |                     ^~~~~
/rtl8821CU/hal/phydm/phydm_debug.c:3486:29: warning: the comparison will always evaluate as ‘true’ for the pointer operand in ‘input + (sizetype)((long unsigned int)(i + 1) * 16)’ must not be NULL [-Waddress]
 3486 |                         if (input[i + 1]) {
      |                             ^~~~~
/rtl8821CU/hal/phydm/phydm_debug.c:3502:29: warning: the comparison will always evaluate as ‘true’ for the pointer operand in ‘input + (sizetype)((long unsigned int)(i + 1) * 16)’ must not be NULL [-Waddress]
 3502 |                         if (input[i + 1]) {
      |                             ^~~~~
/rtl8821CU/hal/phydm/phydm_debug.c:3559:56: warning: the comparison will always evaluate as ‘true’ for the pointer operand in ‘input + 16’ must not be NULL [-Waddress]
 3559 |                 if (dm->support_ic_type & ODM_RTL8822B && input[1]) {
      |                                                        ^~
/rtl8821CU/hal/phydm/phydm_debug.c:3606:29: warning: the comparison will always evaluate as ‘true’ for the pointer operand in ‘input + (sizetype)((long unsigned int)(i + 1) * 16)’ must not be NULL [-Waddress]
 3606 |                         if (input[i + 1]) {
      |                             ^~~~~
/rtl8821CU/hal/phydm/phydm_debug.c:3620:29: warning: the comparison will always evaluate as ‘true’ for the pointer operand in ‘input + (sizetype)((long unsigned int)(i + 1) * 16)’ must not be NULL [-Waddress]
 3620 |                         if (input[i + 1]) {
      |                             ^~~~~
/rtl8821CU/hal/phydm/phydm_debug.c:3684:21: warning: the comparison will always evaluate as ‘true’ for the pointer operand in ‘input + 16’ must not be NULL [-Waddress]
 3684 |                 if (input[1])
      |                     ^~~~~
/rtl8821CU/hal/phydm/phydm_debug.c:3707:29: warning: the comparison will always evaluate as ‘true’ for the pointer operand in ‘input + (sizetype)((long unsigned int)(i + 1) * 16)’ must not be NULL [-Waddress]
 3707 |                         if (input[i + 1]) {
      |                             ^~~~~
/rtl8821CU/hal/phydm/phydm_debug.c:3736:21: warning: the comparison will always evaluate as ‘true’ for the pointer operand in ‘input + 16’ must not be NULL [-Waddress]
 3736 |                 if (input[1])
      |                     ^~~~~
/rtl8821CU/hal/phydm/phydm.c: In function ‘phydm_pause_func_console’:
/rtl8821CU/hal/phydm/phydm.c:1836:21: warning: the comparison will always evaluate as ‘true’ for the pointer operand in ‘input + (sizetype)((long unsigned int)(i + 1) * 16)’ must not be NULL [-Waddress]
 1836 |                 if (input[i + 1]) {
      |                     ^~~~~
  CC [M]  /rtl8821CU/hal/phydm/phydm_dig.o
  CC [M]  /rtl8821CU/hal/phydm/phydm_pathdiv.o
  CC [M]  /rtl8821CU/hal/phydm/phydm_rainfo.o
/rtl8821CU/hal/phydm/phydm_rainfo.c: In function ‘phydm_ra_debug’:
/rtl8821CU/hal/phydm/phydm_rainfo.c:141:21: warning: the comparison will always evaluate as ‘true’ for the pointer operand in ‘input + (sizetype)((long unsigned int)((int)i + 1) * 16)’ must not be NULL [-Waddress]
  141 |                 if (input[i + 1])
      |                     ^~~~~
/rtl8821CU/hal/phydm/phydm_ccx.c: In function ‘phydm_fahm_dbg’:
/rtl8821CU/hal/phydm/phydm_ccx.c:294:21: warning: the comparison will always evaluate as ‘true’ for the pointer operand in ‘input + (sizetype)((long unsigned int)(i + 1) * 16)’ must not be NULL [-Waddress]
  294 |                 if (input[i + 1])
      |                     ^~~~~
/rtl8821CU/hal/phydm/phydm_ccx.c: In function ‘phydm_nhm_dbg’:
/rtl8821CU/hal/phydm/phydm_ccx.c:955:29: warning: the comparison will always evaluate as ‘true’ for the pointer operand in ‘input + (sizetype)((long unsigned int)((int)i + 1) * 16)’ must not be NULL [-Waddress]
  955 |                         if (input[i + 1]) {
      |                             ^~~~~
/rtl8821CU/hal/phydm/phydm_ccx.c: In function ‘phydm_clm_dbg’:
/rtl8821CU/hal/phydm/phydm_ccx.c:1379:21: warning: the comparison will always evaluate as ‘true’ for the pointer operand in ‘input + (sizetype)((long unsigned int)(i + 1) * 16)’ must not be NULL [-Waddress]
 1379 |                 if (input[i + 1])
      |                     ^~~~~
  CC [M]  /rtl8821CU/hal/phydm/phydm_psd.o
/rtl8821CU/hal/phydm/phydm_psd.c: In function ‘phydm_psd_debug’:
/rtl8821CU/hal/phydm/phydm_psd.c:315:29: warning: the comparison will always evaluate as ‘true’ for the pointer operand in ‘input + (sizetype)((long unsigned int)((int)i + 1) * 16)’ must not be NULL [-Waddress]
  315 |                         if (input[i + 1])
      |                             ^~~~~
/rtl8821CU/hal/phydm/halrf/halrf.c: In function ‘halrf_support_ability_debug’:
/rtl8821CU/hal/phydm/halrf/halrf.c:866:21: warning: the comparison will always evaluate as ‘true’ for the pointer operand in ‘input + (sizetype)((long unsigned int)((int)i + 1) * 16)’ must not be NULL [-Waddress]
  866 |                 if (input[i + 1]) {
      |                     ^~~~~
  CC [M]  /rtl8821CU/hal/phydm/halrf/halrf_debug.o
/rtl8821CU/hal/phydm/halrf/halrf_debug.c: In function ‘halrf_debug_trace’:
/rtl8821CU/hal/phydm/halrf/halrf_debug.c:80:21: warning: the comparison will always evaluate as ‘true’ for the pointer operand in ‘input + (sizetype)((long unsigned int)((int)i + 1) * 16)’ must not be NULL [-Waddress]
   80 |                 if (input[i + 1]) {
      |                     ^~~~~
/rtl8821CU/hal/phydm/halrf/halrf_debug.c: In function ‘halrf_cmd_parser’:
/rtl8821CU/hal/phydm/halrf/halrf_debug.c:218:29: warning: the comparison will always evaluate as ‘true’ for the pointer operand in ‘input + (sizetype)((long unsigned int)(i + 1) * 16)’ must not be NULL [-Waddress]
  218 |                         if (input[i + 1]) {
      |                             ^~~~~