[PATCH] RISC-V: io: Don't have a void* PCI_IOBASE

Palmer Dabbelt palmer at rivosinc.com
Tue May 28 15:47:54 PDT 2024


On Mon, 27 May 2024 00:44:13 PDT (-0700), schwab at suse.de wrote:
> On Mai 26 2024, Palmer Dabbelt wrote:
>
>> 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,
>
> A u8 null pointer is still a null pointer.  Are you sure you are quoting
> the right warning?  AFAICS, PCI_IOBASE is not a null pointer.

Ya, sorry, I just saw the void* UB and didn't even read to the "null"...



More information about the linux-riscv mailing list