antoineco / broadcom-wl

Broadcom Linux hybrid wireless driver (64-bit)
https://www.broadcom.com/support/download-search?pg=Wireless+Embedded+Solutions+and+RF+Components&pf=Legacy+Wireless&pa=Driver&dk=BCM4312&l=true
163 stars 47 forks source link

Warning about implicit fallthrough since Linux 5.14 #27

Closed antoineco closed 2 years ago

antoineco commented 2 years ago

This warning is back, despite the fallthrough comment added in #12:

In file included from /home/fedora/actions-runner/_work/broadcom-wl/broadcom-wl/src/wl/sys/wl_cfg80211_hybrid.c:43:
/home/fedora/actions-runner/_work/broadcom-wl/broadcom-wl/src/wl/sys/wl_cfg80211_hybrid.c: In function ‘wl_set_auth_type’:
/home/fedora/actions-runner/_work/broadcom-wl/broadcom-wl/src/wl/sys/wl_cfg80211_hybrid.h:57:12: warning: this statement may fall through [-Wimplicit-fallthrough=]
   57 |         if (wl_dbg_level & WL_DBG_DBG) {                        \
      |            ^
/home/fedora/actions-runner/_work/broadcom-wl/broadcom-wl/src/wl/sys/wl_cfg80211_hybrid.c:826:17: note: in expansion of macro ‘WL_DBG’
  826 |                 WL_DBG(("network eap\n"));
      |                 ^~~~~~
/home/fedora/actions-runner/_work/broadcom-wl/broadcom-wl/src/wl/sys/wl_cfg80211_hybrid.c:828:9: note: here
  828 |         default:
      |         ^~~~~~~

https://gcc.gnu.org/onlinedocs/gcc-12.1.0/gcc/Warning-Options.html#index-Wimplicit-fallthrough

For kernel versions ≥ 5.4, we should probably switch to the fallthrough pseudo-keyword: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=294f69e662d1570703e9b56e95be37a9fd3afba5

antoineco commented 2 years ago

It turns out the default value for -Wimplicit-fallthrough is 5 since Linux 5.14: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b7eb335e26a9c7f258c96b3962c283c379d3ede0

[...] in order to avoid having more comments being introduced, we have to use the option -Wimplicit-fallthrough=5 for GCC, which [...] will cause a warning in case a code comment is intended to be used as a fall-through marking.