mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-26 02:39:48 +00:00
am65-cpsw: avoid null pointer arithmetic
clang warns about arithmetic on NULL pointers: drivers/net/ethernet/ti/am65-cpsw-ethtool.c:71:2: error: performing pointer subtraction with a null pointer has undefined behavior [-Werror,-Wnull-pointer-subtraction] AM65_CPSW_REGDUMP_REC(AM65_CPSW_REGDUMP_MOD_NUSS, 0x0, 0x1c), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/net/ethernet/ti/am65-cpsw-ethtool.c:64:29: note: expanded from macro 'AM65_CPSW_REGDUMP_REC' .hdr.len = (((u32 *)(end)) - ((u32 *)(start)) + 1) * sizeof(u32) * 2 + \ ^ ~~~~~~~~~~~~~~~~ The expression here is easily changed to a calculation based on integers that is no less readable. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
f43bed7193
commit
861f40fa0e
1 changed files with 1 additions and 1 deletions
|
@ -61,7 +61,7 @@ struct am65_cpsw_regdump_item {
|
|||
|
||||
#define AM65_CPSW_REGDUMP_REC(mod, start, end) { \
|
||||
.hdr.module_id = (mod), \
|
||||
.hdr.len = (((u32 *)(end)) - ((u32 *)(start)) + 1) * sizeof(u32) * 2 + \
|
||||
.hdr.len = (end + 4 - start) * 2 + \
|
||||
sizeof(struct am65_cpsw_regdump_hdr), \
|
||||
.start_ofs = (start), \
|
||||
.end_ofs = end, \
|
||||
|
|
Loading…
Reference in a new issue