Skip to content

Commit

Permalink
cxgb: avoid open-coded offsetof()
Browse files Browse the repository at this point in the history
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
arndb authored and davem330 committed Sep 27, 2021
1 parent 3e0d569 commit ef5d635
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/net/ethernet/chelsio/cxgb/vsc7326.c
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit ef5d635

Please sign in to comment.