From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47549) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bLMaX-0001tV-05 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-0005RF-Qi for qemu-devel@nongnu.org; Thu, 07 Jul 2016 23:36:23 -0400 Received: from ozlabs.org ([103.22.144.67]:51950) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bLMaS-0005Qn-7u for qemu-devel@nongnu.org; Thu, 07 Jul 2016 23:36:20 -0400 Date: Fri, 8 Jul 2016 13:33:24 +1000 From: David Gibson Message-ID: <20160708033324.GY14675@voom.fritz.box> References: <1467934423-5997-1-git-send-email-andrew.smirnov@gmail.com> <1467934423-5997-3-git-send-email-andrew.smirnov@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="P6PRkhImOxklJvkF" Content-Disposition: inline In-Reply-To: <1467934423-5997-3-git-send-email-andrew.smirnov@gmail.com> Subject: Re: [Qemu-devel] [PATCH 2/9] Change signature of address_space_read() to avoid casting List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Andrey Smirnov Cc: qemu-devel@nongnu.org --P6PRkhImOxklJvkF Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jul 07, 2016 at 04:33:36PM -0700, Andrey Smirnov wrote: > Change signature of address_space_read() 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 Seems reasonable. Reviewed-by: David Gibson > --- > exec.c | 2 +- > hw/net/dp8393x.c | 16 ++++++++-------- > hw/virtio/virtio.c | 2 +- > include/exec/memory.h | 2 +- > 4 files changed, 11 insertions(+), 11 deletions(-) >=20 > diff --git a/exec.c b/exec.c > index 93611f1..1bd2204 100644 > --- a/exec.c > +++ b/exec.c > @@ -2736,7 +2736,7 @@ MemTxResult address_space_rw(AddressSpace *as, hwad= dr addr, MemTxAttrs attrs, > if (is_write) { > return address_space_write(as, addr, attrs, (uint8_t *)buf, len); > } else { > - return address_space_read(as, addr, attrs, (uint8_t *)buf, len); > + return address_space_read(as, addr, attrs, buf, len); > } > } > =20 > diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c > index 2849542..06dc99b 100644 > --- a/hw/net/dp8393x.c > +++ b/hw/net/dp8393x.c > @@ -205,7 +205,7 @@ static void dp8393x_do_load_cam(dp8393xState *s) > /* Fill current entry */ > address_space_read(&s->as, > (s->regs[SONIC_URRA] << 16) | s->regs[SONIC_CDP], > - MEMTXATTRS_UNSPECIFIED, (uint8_t *)data, size); > + MEMTXATTRS_UNSPECIFIED, data, size); > s->cam[index][0] =3D data[1 * width] & 0xff; > s->cam[index][1] =3D data[1 * width] >> 8; > s->cam[index][2] =3D data[2 * width] & 0xff; > @@ -224,7 +224,7 @@ static void dp8393x_do_load_cam(dp8393xState *s) > /* Read CAM enable */ > address_space_read(&s->as, > (s->regs[SONIC_URRA] << 16) | s->regs[SONIC_CDP], > - MEMTXATTRS_UNSPECIFIED, (uint8_t *)data, size); > + MEMTXATTRS_UNSPECIFIED, data, size); > s->regs[SONIC_CE] =3D data[0 * width]; > DPRINTF("load cam done. cam enable mask 0x%04x\n", s->regs[SONIC_CE]= ); > =20 > @@ -244,7 +244,7 @@ static void dp8393x_do_read_rra(dp8393xState *s) > size =3D sizeof(uint16_t) * 4 * width; > address_space_read(&s->as, > (s->regs[SONIC_URRA] << 16) | s->regs[SONIC_RRP], > - MEMTXATTRS_UNSPECIFIED, (uint8_t *)data, size); > + MEMTXATTRS_UNSPECIFIED, data, size); > =20 > /* Update SONIC registers */ > s->regs[SONIC_CRBA0] =3D data[0 * width]; > @@ -362,7 +362,7 @@ static void dp8393x_do_transmit_packets(dp8393xState = *s) > s->regs[SONIC_TTDA] =3D s->regs[SONIC_CTDA]; > address_space_read(&s->as, > ((s->regs[SONIC_UTDA] << 16) | s->regs[SONIC_TTDA]) + sizeof= (uint16_t) * width, > - MEMTXATTRS_UNSPECIFIED, (uint8_t *)data, size); > + MEMTXATTRS_UNSPECIFIED, data, size); > tx_len =3D 0; > =20 > /* Update registers */ > @@ -397,7 +397,7 @@ static void dp8393x_do_transmit_packets(dp8393xState = *s) > size =3D sizeof(uint16_t) * 3 * width; > address_space_read(&s->as, > ((s->regs[SONIC_UTDA] << 16) | s->regs[SONIC_TTDA]) = + sizeof(uint16_t) * (4 + 3 * i) * width, > - MEMTXATTRS_UNSPECIFIED, (uint8_t *)data, size); > + MEMTXATTRS_UNSPECIFIED, data, size); > s->regs[SONIC_TSA0] =3D data[0 * width]; > s->regs[SONIC_TSA1] =3D data[1 * width]; > s->regs[SONIC_TFS] =3D data[2 * width]; > @@ -438,7 +438,7 @@ static void dp8393x_do_transmit_packets(dp8393xState = *s) > size =3D sizeof(uint16_t) * width; > address_space_read(&s->as, > ((s->regs[SONIC_UTDA] << 16) | s->regs[SONIC_TTDA]) + si= zeof(uint16_t) * (4 + 3 * s->regs[SONIC_TFC]) * width, > - MEMTXATTRS_UNSPECIFIED, (uint8_t *)data, size); > + MEMTXATTRS_UNSPECIFIED, data, size); > s->regs[SONIC_CTDA] =3D data[0 * width] & ~0x1; > if (data[0 * width] & 0x1) { > /* EOL detected */ > @@ -702,7 +702,7 @@ static ssize_t dp8393x_receive(NetClientState *nc, co= nst uint8_t * buf, > size =3D sizeof(uint16_t) * 1 * width; > address =3D ((s->regs[SONIC_URDA] << 16) | s->regs[SONIC_CRDA]) = + sizeof(uint16_t) * 5 * width; > address_space_read(&s->as, address, MEMTXATTRS_UNSPECIFIED, > - (uint8_t *)data, size); > + data, size); > if (data[0 * width] & 0x1) { > /* Still EOL ; stop reception */ > return -1; > @@ -760,7 +760,7 @@ static ssize_t dp8393x_receive(NetClientState *nc, co= nst uint8_t * buf, > size =3D sizeof(uint16_t) * width; > address_space_read(&s->as, > ((s->regs[SONIC_URDA] << 16) | s->regs[SONIC_CRDA]) + sizeof(uin= t16_t) * 5 * width, > - MEMTXATTRS_UNSPECIFIED, (uint8_t *)data, size); > + MEMTXATTRS_UNSPECIFIED, data, size); > s->regs[SONIC_LLFA] =3D data[0 * width]; > if (s->regs[SONIC_LLFA] & 0x1) { > /* EOL detected */ > diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c > index 7ed06ea..449f125 100644 > --- a/hw/virtio/virtio.c > +++ b/hw/virtio/virtio.c > @@ -122,7 +122,7 @@ static void vring_desc_read(VirtIODevice *vdev, VRing= Desc *desc, > hwaddr desc_pa, int i) > { > address_space_read(&address_space_memory, desc_pa + i * sizeof(VRing= Desc), > - MEMTXATTRS_UNSPECIFIED, (void *)desc, sizeof(VRin= gDesc)); > + MEMTXATTRS_UNSPECIFIED, desc, sizeof(VRingDesc)); > virtio_tswap64s(vdev, &desc->addr); > virtio_tswap32s(vdev, &desc->len); > virtio_tswap16s(vdev, &desc->flags); > diff --git a/include/exec/memory.h b/include/exec/memory.h > index 4ab6800..576c5a5 100644 > --- a/include/exec/memory.h > +++ b/include/exec/memory.h > @@ -1418,7 +1418,7 @@ static inline bool memory_access_is_direct(MemoryRe= gion *mr, bool is_write) > */ > static inline __attribute__((__always_inline__)) > MemTxResult address_space_read(AddressSpace *as, hwaddr addr, MemTxAttrs= attrs, > - uint8_t *buf, int len) > + void *buf, int len) > { > MemTxResult result =3D MEMTX_OK; > hwaddr l, addr1; --=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 --P6PRkhImOxklJvkF Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJXfx8EAAoJEGw4ysog2bOS53MQAIaoTJbhdup9SkGSiHB6LvhU 0dcJJhbFbPhgHQllTPMgOtwzND5nE2kSlpCndFnIvr9+/IBghBty/MJdf5whlvvS FGVcMgAUyaCgisdt76mMZwn2gpX1+XaTjPRIX94olVu8w2Ck0jKuWkEENPVbBzoL I2MticU6svjobjHrXUhs3Ot82b8bSAYfr8O7EhQryacuAlk4d0QKpqbmzMpj99wQ adYL9Teoeim29LO3Jna5JM10WbAh6qQkGEj0osxEuuXQHM/OOcJ1HGLSkwcS8XdX 9acfQZUNTCj+olDLkVYwEe/MZHWqpG1dutJLlwylrvWuwpTPOUNisKzqnhMEyQsq YCdlkc5Pwb22FB7gQqvdJuYNwb2VznPEG2NLshjzLd2zsFJ2jWwq17NGu8m2Sw1J WxvCjzDiIW5iTev6KuVYFqVe/qBx2h20lQz4j2fRr0bwMa+lnARI15RqcWAjG9eK Ga/agRdxEBzf3WAf8IuQw+kf+PKEEpZh7OQeZ4WueGmKgQkfFzM0YBNCZ+ub9770 JB9NxyB1nhR53H98d9evxhw/opPxNCh34zDrc69V1jawy5jkl+MYxcmSLLhqjn0t hfBcotbVrkhQTBWCcqMwY1um8X78vqlC0HmwKjP7aGsFUVSXYLsaiJZF4VrI9vLu s7gMMso2LcIK5VUxqB52 =IgzI -----END PGP SIGNATURE----- --P6PRkhImOxklJvkF--