* [PATCH] cxgb: avoid open-coded offsetof()
@ 2021-09-27 12:16 Arnd Bergmann
2021-09-27 13:10 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2021-09-27 12:16 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski
Cc: Arnd Bergmann, Nathan Chancellor, Nick Desaulniers, netdev,
linux-kernel, llvm
From: Arnd Bergmann <arnd@arndb.de>
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.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/net/ethernet/chelsio/cxgb/vsc7326.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/chelsio/cxgb/vsc7326.c b/drivers/net/ethernet/chelsio/cxgb/vsc7326.c
index 873c1c7b4ca0..a19284bdb80e 100644
--- a/drivers/net/ethernet/chelsio/cxgb/vsc7326.c
+++ b/drivers/net/ethernet/chelsio/cxgb/vsc7326.c
@@ -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),
--
2.29.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] cxgb: avoid open-coded offsetof()
2021-09-27 12:16 [PATCH] cxgb: avoid open-coded offsetof() Arnd Bergmann
@ 2021-09-27 13:10 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-09-27 13:10 UTC (permalink / raw)
To: Arnd Bergmann
Cc: davem, kuba, arnd, nathan, ndesaulniers, netdev, linux-kernel, llvm
Hello:
This patch was applied to netdev/net-next.git (refs/heads/master):
On Mon, 27 Sep 2021 14:16:04 +0200 you wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-09-27 13:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-27 12:16 [PATCH] cxgb: avoid open-coded offsetof() Arnd Bergmann
2021-09-27 13:10 ` patchwork-bot+netdevbpf
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.