cxgb: avoid open-coded offsetof()
Subsystems (2)
PATCH 1/1 cxgb: avoid open-coded offsetof()
From: Arnd Bergmann <[email protected]>
clang-14 does not like the custom offsetof() macro in vsc7326:
drivers/net/ethernet/chelsio/cxgb/vsc7326.c:597:3: error: performing pointer subtraction with a null pointer has undefined behavior [-Werror,-Wnull-pointer-subtraction]
HW_STAT(RxUnicast, RxUnicastFramesOK),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/chelsio/cxgb/vsc7326.c:594:56: note: expanded from macro 'HW_STAT'
{ reg, (&((struct cmac_statistics *)NULL)->stat_name) - (u64 *)NULL }Rewrite this to use the version provided by the kernel.
--- drivers/net/ethernet/chelsio/cxgb/vsc7326.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/chelsio/cxgb/vsc7326.c +1 -1
@@ -591,7 +591,7 @@ static void port_stats_update(struct cmac *mac) } hw_stats[] = {#define HW_STAT (reg, stat_name) \ - { reg, (&((struct cmac_statistics *)NULL)->stat_name) - (u64 *)NULL } + { reg, offsetof(struct cmac_statistics, stat_name) / sizeof(u64) }/* Rx stats */ HW_STAT(RxUnicast, RxUnicastFramesOK),
Signature · 1 line
2.29.2
This patch was applied to netdev/net-next.git (refs/heads/master):
Hello:
This patch was applied to netdev/net-next.git (refs/heads/master):
Quoted 11 lines · On Mon, 27 Sep 2021 14:16:04 +0200 you wrote:
From: Arnd Bergmann <[email protected]>
clang-14 does not like the custom
offsetof()macro in vsc7326:
drivers/net/ethernet/chelsio/cxgb/vsc7326.c:597:3: error: performing pointer subtraction with a null pointer has undefined behavior [-Werror,-Wnull-pointer-subtraction]HW_STAT(RxUnicast, RxUnicastFramesOK), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/net/ethernet/chelsio/cxgb/vsc7326.c:594:56: note: expanded from macro 'HW_STAT' { reg, (&((struct cmac_statistics *)NULL)->stat_name) - (u64 *)NULL }[...]
Here is the summary with links:
- cxgb: avoid open-coded offsetof()
https://git.kernel.org/netdev/net-next/c/ef5d6356e2ac
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html