On Fri, Nov 02, 2012 at 08:31:23AM +0100, Gerd Hoffmann wrote:
> Hi,
>
> > +static inline void xhci_dma_write_u32s(XHCIState *xhci, dma_addr_t addr,
> > + uint32_t *buf, size_t len)
> > +{
> > + int i;
> > +
> > + for (i = 0; i < (len / sizeof(uint32_t)); i++) {
> > + buf[i] = cpu_to_le32(buf[i]);
> > + }
> > + pci_dma_write(&xhci->pci_dev, addr, buf, len);
> > +}
>
> I think we should use a temporary buffer here, otherwise you leave the
> values byteswapped in buf which likely has unwanted side effects.
Yeah, I wondered about that. I did check that the side-effect doesn't
matter in any of the existing callers, so I left it that way to avoid
the extra copies. But you're right, it's a pretty subtle constraint
that could easily be broken by future changes.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson