[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 1/3] libqos: Remove PCI assumptions in virtio dr
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-devel] [PATCH 1/3] libqos: Remove PCI assumptions in virtio driver |
Date: |
Mon, 6 Oct 2014 10:02:14 +0100 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
On Fri, Oct 03, 2014 at 01:53:13PM +0200, Marc Marí wrote:
> El Thu, 2 Oct 2014 13:02:25 +0100
> Stefan Hajnoczi <address@hidden> escribió:
> > On Thu, Sep 04, 2014 at 06:24:37PM +0200, Marc Marí wrote:
> > > @@ -60,25 +60,25 @@ static void
> > > qvirtio_pci_assign_device(QVirtioDevice *d, void *data) *vpcidev =
> > > (QVirtioPCIDevice *)d; }
> > >
> > > -static uint8_t qvirtio_pci_config_readb(QVirtioDevice *d, void
> > > *addr) +static uint8_t qvirtio_pci_config_readb(QVirtioDevice *d,
> > > uint64_t addr) {
> > > QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d;
> > > - return qpci_io_readb(dev->pdev, addr);
> > > + return qpci_io_readb(dev->pdev, (void *)addr);
> >
> > You do not need casts in C for void* to any pointer type or any
> > pointer type to void*. Please drop them.
>
> addr is of type uint64_t, not a pointer. So if there's no cast it will
> fail to compile (expected ‘void *’ but argument is of type ‘uint64_t’)
Hmm...on 32-bit hosts that causes an error:
a.c:7:17: warning: cast to pointer from integer of different size
[-Wint-to-pointer-cast]
printf("%p\n", (void*)u64);
You need to cast to uintptr_t first:
(void*)(uintptr_t)addr
This assumes that PCI IO Space addresses are 32-bit when running 32-bit
hosts. Not sure whether or not that's true, but at least for x86 it
works since the legacy PIO address space is 16-bit.
Stefan
pgpCm8HQktLd1.pgp
Description: PGP signature