Skip to contentSkip to conversation

brcmsmac: avoid function pointer casts

PATCH In review Arnd Bergmann 4 participants 8 messages Feb 13, 2024 – Feb 16, 2024 Broadcom BRCM80211 IEEE802.11 wireless drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 brcmsmac: avoid function pointer casts

From: Arnd Bergmann <[email protected]>

An old cleanup went a little too far and causes a warning with clang-16 and higher as it breaks control flow integrity (KCFI) rules:

drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy_shim.c:64:34: error: cast from 'void (*)(struct brcms_phy *)' to 'void (*)(void *)' converts to incompatible function type [-Werror,-Wcast-function-type-strict]
64 | brcms_init_timer(physhim->wl, (void (*)(void *))fn,

      |                                                       ^~~~~~~~~~~~~~~~~~~~

Change this one instance back to passing a void pointer so it can be used with the timer callback interface.

Fixes d89a4c80601d ("staging: brcm80211: removed void * from softmac phy")
---
 .../net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_cmn.c   | 3 ++-
 drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy_shim.c  | 5 ++---
 drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy_shim.h  | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_cmn.c +2 -1
index 07f83ff5a54a..a27d6f0b8819 100644
@@ -383,8 +383,9 @@ struct shared_phy *wlc_phy_shared_attach(struct shared_phy_params *shp)
 	return sh;
 }
 
-static void wlc_phy_timercb_phycal(struct brcms_phy *pi)
+static void wlc_phy_timercb_phycal(void *ptr)
 {
+	struct brcms_phy *pi = ptr;
 	uint delay = 5;
 
 	if (PHY_PERICAL_MPHASE_PENDING(pi)) {
drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy_shim.c +2 -3
index a0de5db0cd64..b72381791536 100644
@@ -57,12 +57,11 @@ void wlc_phy_shim_detach(struct phy_shim_info *physhim)
 }
 
 struct wlapi_timer *wlapi_init_timer(struct phy_shim_info *physhim,
-				     void (*fn)(struct brcms_phy *pi),
+				     void (*fn)(void *pi),
 				     void *arg, const char *name)
 {
 	return (struct wlapi_timer *)
-			brcms_init_timer(physhim->wl, (void (*)(void *))fn,
-					 arg, name);
+			brcms_init_timer(physhim->wl, fn, arg, name);
 }
 
 void wlapi_free_timer(struct wlapi_timer *t)
drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy_shim.h +1 -1
index dd8774717ade..27d0934e600e 100644
@@ -131,7 +131,7 @@ void wlc_phy_shim_detach(struct phy_shim_info *physhim);
 
 /* PHY to WL utility functions */
 struct wlapi_timer *wlapi_init_timer(struct phy_shim_info *physhim,
-				     void (*fn)(struct brcms_phy *pi),
+				     void (*fn)(void *pi),
 				     void *arg, const char *name);
 void wlapi_free_timer(struct wlapi_timer *t);
 void wlapi_add_timer(struct wlapi_timer *t, uint ms, int periodic);
Signature · 1 line
2.39.2
#1 lore raw
Quoted 7 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

An old cleanup went a little too far and causes a warning with clang-16 and higher as it breaks control flow integrity (KCFI) rules:

drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy_shim.c:64:34: error: cast from 'void (*)(struct brcms_phy *)' to 'void (*)(void *)' converts to incompatible function type [-Werror,-Wcast-function-type-strict]
64 | brcms_init_timer(physhim->wl, (void (*)(void *))fn,

Quoted 7 lines
      |                                                       ^~~~~~~~~~~~~~~~~~~~

Change this one instance back to passing a void pointer so it can be used with the timer callback interface.

Fixes d89a4c80601d ("staging: brcm80211: removed void * from softmac phy")

I guess this should go to wireless tree?

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
maintainer
#2 lore raw
Quoted 11 lines · Kalle Valo
Quoted 9 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

An old cleanup went a little too far and causes a warning with clang-16 and higher as it breaks control flow integrity (KCFI) rules:

drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy_shim.c:64:34: error: cast from 'void (*)(struct brcms_phy *)' to 'void (*)(void *)' converts to incompatible function type [-Werror,-Wcast-function-type-strict]

    64 |                         brcms_init_timer(physhim->wl, (void (*)(void *))fn,
       |                                                       ^~~~~~~~~~~~~~~~~~~~
Quoted 7 lines
Quoted 5 lines

Change this one instance back to passing a void pointer so it can be used with the timer callback interface.

Fixes d89a4c80601d ("staging: brcm80211: removed void * from softmac phy")

I guess this should go to wireless tree?

This has been like this forever looking at the "staging" part in the Fixes tag. Is it really so urgent now? On the other hand I have no real problem with moving this to the wireless tree. Just wondering out loud.

Regards,
Arend

#3 lore raw
Quoted 15 lines · Arend van Spriel
Quoted 14 lines · Kalle Valo
Quoted 12 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

An old cleanup went a little too far and causes a warning with clang-16 and higher as it breaks control flow integrity (KCFI) rules:

drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy_shim.c:64:34: error: cast from 'void (*)(struct brcms_phy *)' to 'void (*)(void *)' converts to incompatible function type [-Werror,-Wcast-function-type-strict]

    64 |                         brcms_init_timer(physhim->wl, (void (*)(void *))fn,
       |                                                       ^~~~~~~~~~~~~~~~~~~~

Change this one instance back to passing a void pointer so it can be used with the timer callback interface.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Fixes d89a4c80601d ("staging: brcm80211: removed void * from softmac phy")

I guess this should go to wireless tree?

This has been like this forever looking at the "staging" part in the Fixes tag. Is it really so urgent now? On the other hand I have no real problem with moving this to the wireless tree. Just wondering out loud.

It's probably fine either way. Some maintainers like to backport the warning fixes to stable kernels, others don't. Since the warning is currently only enabled at W=1 level, it's probably fine to fix it for linux-next only, but if we want the fix backported, it should also go into 6.8.

Arnd

#4 lore raw
Quoted 26 lines · Arnd Bergmann
Quoted 15 lines · Arend van Spriel
Quoted 14 lines · Kalle Valo
Quoted 12 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

An old cleanup went a little too far and causes a warning with clang-16 and higher as it breaks control flow integrity (KCFI) rules:

drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy_shim.c:64:34: error: cast from 'void (*)(struct brcms_phy *)' to 'void (*)(void *)' converts to incompatible function type [-Werror,-Wcast-function-type-strict]

    64 |                         brcms_init_timer(physhim->wl, (void (*)(void *))fn,
       |                                                       ^~~~~~~~~~~~~~~~~~~~

Change this one instance back to passing a void pointer so it can be used with the timer callback interface.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Fixes d89a4c80601d ("staging: brcm80211: removed void * from softmac phy")

I guess this should go to wireless tree?

This has been like this forever looking at the "staging" part in the Fixes tag. Is it really so urgent now? On the other hand I have no real problem with moving this to the wireless tree. Just wondering out loud.

Quoted 5 lines

It's probably fine either way. Some maintainers like to backport the warning fixes to stable kernels, others don't. Since the warning is currently only enabled at W=1 level, it's probably fine to fix it for linux-next only, but if we want the fix backported, it should also go into 6.8.

Thanks, let's take it wireless-next then.

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#5 lore raw
In reply to Arnd Bergmann
Quoted 7 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

An old cleanup went a little too far and causes a warning with clang-16 and higher as it breaks control flow integrity (KCFI) rules:

drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy_shim.c:64:34: error: cast from 'void (*)(struct brcms_phy *)' to 'void (*)(void *)' converts to incompatible function type [-Werror,-Wcast-function-type-strict]
64 | brcms_init_timer(physhim->wl, (void (*)(void *))fn,

Quoted 7 lines
      |                                                       ^~~~~~~~~~~~~~~~~~~~

Change this one instance back to passing a void pointer so it can be used with the timer callback interface.

Fixes d89a4c80601d ("staging: brcm80211: removed void * from softmac phy")

I can add 'wifi:' during commit. Arend, ack?

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
maintainer Acked-by
#6 lore raw
Quoted 11 lines · Kalle Valo
Quoted 9 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

An old cleanup went a little too far and causes a warning with clang-16 and higher as it breaks control flow integrity (KCFI) rules:

drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy_shim.c:64:34: error: cast from 'void (*)(struct brcms_phy *)' to 'void (*)(void *)' converts to incompatible function type [-Werror,-Wcast-function-type-strict]
64 | brcms_init_timer(physhim->wl, (void (*)(void *))fn,
| ^~~~~~~~~~~~~~~~~~~~

Quoted 7 lines
Quoted 5 lines

Change this one instance back to passing a void pointer so it can be used with the timer callback interface.

Fixes d89a4c80601d ("staging: brcm80211: removed void * from softmac phy")

I can add 'wifi:' during commit. Arend, ack?

Here it is:

Quoted 5 lines

--
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

#7 lore raw

Re: wifi: brcmsmac: avoid function pointer casts

In reply to Arnd Bergmann
Quoted 7 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

An old cleanup went a little too far and causes a warning with clang-16 and higher as it breaks control flow integrity (KCFI) rules:

drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy_shim.c:64:34: error: cast from 'void (*)(struct brcms_phy *)' to 'void (*)(void *)' converts to incompatible function type [-Werror,-Wcast-function-type-strict]
64 | brcms_init_timer(physhim->wl, (void (*)(void *))fn,

Quoted 8 lines
      |                                                       ^~~~~~~~~~~~~~~~~~~~

Change this one instance back to passing a void pointer so it can be used with the timer callback interface.

Fixes d89a4c80601d ("staging: brcm80211: removed void * from softmac phy")

Patch applied to wireless-next.git, thanks.

e1ea6db35fc3 wifi: brcmsmac: avoid function pointer casts

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches