Skip to content

Commit 8a20030

Browse files
wdebruijandrom3da
authored andcommitted
hexagon: fix using plain integer as NULL pointer warning in cmpxchg
Sparse reports net/ipv4/inet_diag.c:1511:17: sparse: sparse: Using plain integer as NULL pointer Due to this code calling cmpxchg on a non-integer type struct inet_diag_handler * return !cmpxchg((const struct inet_diag_handler**)&inet_diag_table[type], NULL, h) ? 0 : -EEXIST; While hexagon's cmpxchg assigns an integer value to a variable of this type. __typeof__(*(ptr)) __oldval = 0; Update this assignment to cast 0 to the correct type. The original issue is easily reproduced at head with the below block, and is absent after this change. make LLVM=1 ARCH=hexagon defconfig make C=1 LLVM=1 ARCH=hexagon net/ipv4/inet_diag.o Fixes: 99a70aa ("Hexagon: Add processor and system headers") Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202411091538.PGSTqUBi-lkp@intel.com/ Signed-off-by: Willem de Bruijn <willemb@google.com> Tested-by: Christian Gmeiner <cgmeiner@igalia.com> Link: https://lore.kernel.org/r/20241203221736.282020-1-willemdebruijn.kernel@gmail.com Signed-off-by: Brian Cain <bcain@quicinc.com> Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
1 parent cd45f36 commit 8a20030

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/hexagon/include/asm/cmpxchg.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ __arch_xchg(unsigned long x, volatile void *ptr, int size)
5656
__typeof__(ptr) __ptr = (ptr); \
5757
__typeof__(*(ptr)) __old = (old); \
5858
__typeof__(*(ptr)) __new = (new); \
59-
__typeof__(*(ptr)) __oldval = 0; \
59+
__typeof__(*(ptr)) __oldval = (__typeof__(*(ptr))) 0; \
6060
\
6161
asm volatile( \
6262
"1: %0 = memw_locked(%1);\n" \

0 commit comments

Comments
 (0)