From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47551) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bLMaX-0001tY-0I for qemu-devel@nongnu.org; Thu, 07 Jul 2016 23:36:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bLMaS-0005RL-Qx for qemu-devel@nongnu.org; Thu, 07 Jul 2016 23:36:23 -0400 Received: from ozlabs.org ([103.22.144.67]:38019) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bLMaS-0005Qo-82 for qemu-devel@nongnu.org; Thu, 07 Jul 2016 23:36:20 -0400 Date: Fri, 8 Jul 2016 13:34:26 +1000 From: David Gibson Message-ID: <20160708033426.GZ14675@voom.fritz.box> References: <1467934423-5997-1-git-send-email-andrew.smirnov@gmail.com> <1467934423-5997-4-git-send-email-andrew.smirnov@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="xd76R9tHJzDpbIo0" Content-Disposition: inline In-Reply-To: <1467934423-5997-4-git-send-email-andrew.smirnov@gmail.com> Subject: Re: [Qemu-devel] [PATCH 3/9] Change signature of address_space_write() to avoid casting List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Andrey Smirnov Cc: qemu-devel@nongnu.org --xd76R9tHJzDpbIo0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jul 07, 2016 at 04:33:37PM -0700, Andrey Smirnov wrote: > Change signature of address_space_write() to expectet void * as a buffer > instead of uint8_t * to avoid forcing the caller of the function to do a > type cast. >=20 > Signed-off-by: Andrey Smirnov Reviewed-by: David Gibson > --- > exec.c | 10 +++++----- > hw/net/dp8393x.c | 10 +++++----- > hw/virtio/virtio.c | 2 +- > include/exec/memory.h | 2 +- > 4 files changed, 12 insertions(+), 12 deletions(-) >=20 > diff --git a/exec.c b/exec.c > index 1bd2204..c26bcea 100644 > --- a/exec.c > +++ b/exec.c > @@ -2621,7 +2621,7 @@ static MemTxResult address_space_write_continue(Add= ressSpace *as, hwaddr addr, > } > =20 > MemTxResult address_space_write(AddressSpace *as, hwaddr addr, MemTxAttr= s attrs, > - const uint8_t *buf, int len) > + const void *buf, int len) > { > hwaddr l; > hwaddr addr1; > @@ -2734,7 +2734,7 @@ MemTxResult address_space_rw(AddressSpace *as, hwad= dr addr, MemTxAttrs attrs, > uint8_t *buf, int len, bool is_write) > { > if (is_write) { > - return address_space_write(as, addr, attrs, (uint8_t *)buf, len); > + return address_space_write(as, addr, attrs, buf, len); > } else { > return address_space_read(as, addr, attrs, buf, len); > } > @@ -3582,7 +3582,7 @@ void address_space_stq(AddressSpace *as, hwaddr add= r, uint64_t val, > { > MemTxResult r; > val =3D tswap64(val); > - r =3D address_space_write(as, addr, attrs, (void *) &val, 8); > + r =3D address_space_write(as, addr, attrs, &val, 8); > if (result) { > *result =3D r; > } > @@ -3593,7 +3593,7 @@ void address_space_stq_le(AddressSpace *as, hwaddr = addr, uint64_t val, > { > MemTxResult r; > val =3D cpu_to_le64(val); > - r =3D address_space_write(as, addr, attrs, (void *) &val, 8); > + r =3D address_space_write(as, addr, attrs, &val, 8); > if (result) { > *result =3D r; > } > @@ -3603,7 +3603,7 @@ void address_space_stq_be(AddressSpace *as, hwaddr = addr, uint64_t val, > { > MemTxResult r; > val =3D cpu_to_be64(val); > - r =3D address_space_write(as, addr, attrs, (void *) &val, 8); > + r =3D address_space_write(as, addr, attrs, &val, 8); > if (result) { > *result =3D r; > } > diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c > index 06dc99b..4196194 100644 > --- a/hw/net/dp8393x.c > +++ b/hw/net/dp8393x.c > @@ -431,7 +431,7 @@ static void dp8393x_do_transmit_packets(dp8393xState = *s) > size =3D sizeof(uint16_t) * width; > address_space_write(&s->as, > (s->regs[SONIC_UTDA] << 16) | s->regs[SONIC_TTDA], > - MEMTXATTRS_UNSPECIFIED, (uint8_t *)data, size); > + MEMTXATTRS_UNSPECIFIED, data, size); > =20 > if (!(s->regs[SONIC_CR] & SONIC_CR_HTX)) { > /* Read footer of packet */ > @@ -722,10 +722,10 @@ static ssize_t dp8393x_receive(NetClientState *nc, = const uint8_t * buf, > DPRINTF("Receive packet at %08x\n", (s->regs[SONIC_CRBA1] << 16) | s= ->regs[SONIC_CRBA0]); > address =3D (s->regs[SONIC_CRBA1] << 16) | s->regs[SONIC_CRBA0]; > address_space_write(&s->as, address, > - MEMTXATTRS_UNSPECIFIED, (uint8_t *)buf, rx_len); > + MEMTXATTRS_UNSPECIFIED, buf, rx_len); > address +=3D rx_len; > address_space_write(&s->as, address, > - MEMTXATTRS_UNSPECIFIED, (uint8_t *)&checksum, 4); > + MEMTXATTRS_UNSPECIFIED, &checksum, 4); > rx_len +=3D 4; > s->regs[SONIC_CRBA1] =3D address >> 16; > s->regs[SONIC_CRBA0] =3D address & 0xffff; > @@ -754,7 +754,7 @@ static ssize_t dp8393x_receive(NetClientState *nc, co= nst uint8_t * buf, > data[4 * width] =3D s->regs[SONIC_RSC]; /* seq_no */ > size =3D sizeof(uint16_t) * 5 * width; > address_space_write(&s->as, (s->regs[SONIC_URDA] << 16) | s->regs[SO= NIC_CRDA], > - MEMTXATTRS_UNSPECIFIED, (uint8_t *)data, size); > + MEMTXATTRS_UNSPECIFIED, data, size); > =20 > /* Move to next descriptor */ > size =3D sizeof(uint16_t) * width; > @@ -769,7 +769,7 @@ static ssize_t dp8393x_receive(NetClientState *nc, co= nst uint8_t * buf, > data[0 * width] =3D 0; /* in_use */ > address_space_write(&s->as, > ((s->regs[SONIC_URDA] << 16) | s->regs[SONIC_CRDA]) + sizeof= (uint16_t) * 6 * width, > - MEMTXATTRS_UNSPECIFIED, (uint8_t *)data, sizeof(uint16_t)); > + MEMTXATTRS_UNSPECIFIED, data, sizeof(uint16_t)); > s->regs[SONIC_CRDA] =3D s->regs[SONIC_LLFA]; > s->regs[SONIC_ISR] |=3D SONIC_ISR_PKTRX; > s->regs[SONIC_RSC] =3D (s->regs[SONIC_RSC] & 0xff00) | (((s->reg= s[SONIC_RSC] & 0x00ff) + 1) & 0x00ff); > diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c > index 449f125..cda7075 100644 > --- a/hw/virtio/virtio.c > +++ b/hw/virtio/virtio.c > @@ -164,7 +164,7 @@ static inline void vring_used_write(VirtQueue *vq, VR= ingUsedElem *uelem, > virtio_tswap32s(vq->vdev, &uelem->len); > pa =3D vq->vring.used + offsetof(VRingUsed, ring[i]); > address_space_write(&address_space_memory, pa, MEMTXATTRS_UNSPECIFIE= D, > - (void *)uelem, sizeof(VRingUsedElem)); > + uelem, sizeof(VRingUsedElem)); > } > =20 > static uint16_t vring_used_idx(VirtQueue *vq) > diff --git a/include/exec/memory.h b/include/exec/memory.h > index 576c5a5..51e4c2f 100644 > --- a/include/exec/memory.h > +++ b/include/exec/memory.h > @@ -1271,7 +1271,7 @@ MemTxResult address_space_rw(AddressSpace *as, hwad= dr addr, > */ > MemTxResult address_space_write(AddressSpace *as, hwaddr addr, > MemTxAttrs attrs, > - const uint8_t *buf, int len); > + const void *buf, int len); > =20 > /* address_space_ld*: load from an address space > * address_space_st*: store to an address space --=20 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 --xd76R9tHJzDpbIo0 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJXfx9CAAoJEGw4ysog2bOSB6gQAJjHuVnz7X4UIhqLJ6CTwLgP kJbW+ltp3/EyH3klF8VSsAiGg+A2fqyQagKZQOePh+d8nSHeWXH2KR/+DUXaFcFu UIyJQDKL+5JLYgpkZSaDjxk72MfwxT0dyUWDcROAwTVmIOLuxDRsGoB3BeEg6Tx5 Pz+yLn7ASNBj3MwS9jmjlgEumcQOPR86UAPfdJ+SCd1vr37NdrpWFUGgFH+OYt5x 0yfooiVr4OJjnKH7yzZKYgiFapcIS3DwX5U0brPP7vFuSz5FPYFNVa74He3+Ik1n KPyTXZ+3hearwAinAsJsI6mfx2E7jT9HHwPq0/k2MLBk5K1ZAct/IqSl0FjthGW6 Qohoi3mQ+2uywPRYgIzJVYh6CVhVknDo82mq8m28+K0sKQzvbSG4/L5W3LVZIRTH /vkQrD3DvStti5+HVVIBFY1kMCWtH+2N8XLrsW948X8TLk47abnI+Je+P7o/2iKJ pnTUWzi+tWwyco2XE7whsBUEZXX8bVE5taVaxPhhmGXxulNEvR43IpDc3Z8fEUdY GlpmqUtBrWa8LWB3m67QpvOPSDkrJYAqY2ZeQyvk4pOZcHtb75rTxOCTqJVOEzM4 qXpidQmyRUYNcrlaoFrUnCLsiqJ6ed6ZTxfc569M2wIM2g8xurUOT7tKIiClQXop No5YLYz1djj+TbLLrp9K =rEBv -----END PGP SIGNATURE----- --xd76R9tHJzDpbIo0--