summaryrefslogtreecommitdiff
path: root/drivers/platform
diff options
context:
space:
mode:
authorMichael Ellerman <mpe@ellerman.id.au>2024-05-03 17:56:18 +1000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-06-27 13:46:16 +0200
commit7bbcd3b1c20cb55ded1c7abe800b338e51f92988 (patch)
tree85123b1ba828e3e417a2f7b3ca8201de31e99d72 /drivers/platform
parent8aa11aa001576bf3b00dcb8559564ad7a3113588 (diff)
downloadlinux-7bbcd3b1c20cb55ded1c7abe800b338e51f92988.tar.gz
linux-7bbcd3b1c20cb55ded1c7abe800b338e51f92988.tar.bz2
linux-7bbcd3b1c20cb55ded1c7abe800b338e51f92988.zip
powerpc/io: Avoid clang null pointer arithmetic warnings
[ Upstream commit 03c0f2c2b2220fc9cf8785cd7b61d3e71e24a366 ] With -Wextra clang warns about pointer arithmetic using a null pointer. When building with CONFIG_PCI=n, that triggers a warning in the IO accessors, eg: In file included from linux/arch/powerpc/include/asm/io.h:672: linux/arch/powerpc/include/asm/io-defs.h:23:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] 23 | DEF_PCI_AC_RET(inb, u8, (unsigned long port), (port), pio, port) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ... linux/arch/powerpc/include/asm/io.h:591:53: note: expanded from macro '__do_inb' 591 | #define __do_inb(port) readb((PCI_IO_ADDR)_IO_BASE + port); | ~~~~~~~~~~~~~~~~~~~~~ ^ That is because when CONFIG_PCI=n, _IO_BASE is defined as 0. Although _IO_BASE is defined as plain 0, the cast (PCI_IO_ADDR) converts it to void * before the addition with port happens. Instead the addition can be done first, and then the cast. The resulting value will be the same, but avoids the warning, and also avoids void pointer arithmetic which is apparently non-standard. Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org> Closes: https://lore.kernel.org/all/CA+G9fYtEh8zmq8k8wE-8RZwW-Qr927RLTn+KqGnq1F=ptaaNsA@mail.gmail.com Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://msgid.link/20240503075619.394467-1-mpe@ellerman.id.au Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/platform')
0 files changed, 0 insertions, 0 deletions