Linux-RISC-V Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Nam Cao <namcao@linutronix.de>
To: Andreas Schwab <schwab@suse.de>
Cc: Palmer Dabbelt <palmer@rivosinc.com>, linux-riscv@lists.infradead.org
Subject: Re: [PATCH] RISC-V: io: Don't have a void* PCI_IOBASE
Date: Mon, 27 May 2024 10:03:40 +0200	[thread overview]
Message-ID: <20240527080340.cghUNM1o@linutronix.de> (raw)
In-Reply-To: <20240527075509.gOIDkp3X@linutronix.de>

On Mon, May 27, 2024 at 09:55:15AM +0200, Nam Cao wrote:
> On Mon, May 27, 2024 at 09:44:13AM +0200, Andreas Schwab 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.
> 
> Null pointer has nothing to do with this. The warning is about arithmetic
> operation on void*, which is undefined behavior.

Wait, I am dumb. It is about null pointer.
Pretend you didn't see my email.

> 
> Compilers usually do arithmetic on void* the same way as for u8*, but that
> is not defined by C.
> 
> Best regards,
> Nam

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

  reply	other threads:[~2024-05-27  8:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2024-05-28 22:47   ` Palmer Dabbelt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240527080340.cghUNM1o@linutronix.de \
    --to=namcao@linutronix.de \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@rivosinc.com \
    --cc=schwab@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox