Linux-RISC-V Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] RISC-V: io: Don't have a void* PCI_IOBASE
@ 2024-05-26 21:36 Palmer Dabbelt
  2024-05-27  7:44 ` Andreas Schwab
  0 siblings, 1 reply; 5+ messages in thread
From: Palmer Dabbelt @ 2024-05-26 21:36 UTC (permalink / raw)
  To: linux-riscv; +Cc: Palmer Dabbelt

I recently started noticing warnings along the lines of

    include/asm-generic/io.h:752:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
            insw(addr, buffer, count);
            ^~~~~~~~~~~~~~~~~~~~~~~~~
    arch/riscv/include/asm/io.h:105:53: note: expanded from macro 'insw'
    #define insw(addr, buffer, count) __insw(PCI_IOBASE + (addr), buffer, count)

which are triggered by having PCI_IOBASE be a "void __iomem *".  I'm not
quite sure what the right thing to do is here: having it as u8 to make
the pointer arithmetic work seems reasonable to me, but a bunch of other
ports still have it as "void __iomem *".

Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
---
Not sure if I just started noticing these, but a bunch show up when
merging Linus' master from this afternoon.  Having some sort of fix here
seems reasonable, as "void *" arithmetic is undefined.  I didn't check
if the other ports are suffering from this too, I figured I'd just send
a patch so I don't forget about it.
---
 arch/riscv/include/asm/io.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv/include/asm/io.h b/arch/riscv/include/asm/io.h
index 1c5c641075d2..a2d2d10c48cf 100644
--- a/arch/riscv/include/asm/io.h
+++ b/arch/riscv/include/asm/io.h
@@ -27,7 +27,7 @@
  */
 #ifdef CONFIG_MMU
 #define IO_SPACE_LIMIT		(PCI_IO_SIZE - 1)
-#define PCI_IOBASE		((void __iomem *)PCI_IO_START)
+#define PCI_IOBASE		((u8 __iomem *)PCI_IO_START)
 #endif /* CONFIG_MMU */
 
 /*
-- 
2.45.0


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-05-28 22:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-26 21:36 [PATCH] RISC-V: io: Don't have a void* PCI_IOBASE Palmer Dabbelt
2024-05-27  7:44 ` Andreas Schwab
2024-05-27  7:55   ` Nam Cao
2024-05-27  8:03     ` Nam Cao
2024-05-28 22:47   ` Palmer Dabbelt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox