[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-arm] [PATCH v3 03/10] Change signature of address_space_write() to
From: |
Andrey Smirnov |
Subject: |
[Qemu-arm] [PATCH v3 03/10] Change signature of address_space_write() to avoid casting |
Date: |
Tue, 19 Jul 2016 22:02:53 -0700 |
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.
Reviewed-by: David Gibson <address@hidden>
Signed-off-by: Andrey Smirnov <address@hidden>
---
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(-)
diff --git a/exec.c b/exec.c
index 76d55ed..44cd424 100644
--- a/exec.c
+++ b/exec.c
@@ -2621,7 +2621,7 @@ static MemTxResult
address_space_write_continue(AddressSpace *as, hwaddr addr,
}
MemTxResult address_space_write(AddressSpace *as, hwaddr addr, MemTxAttrs
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, hwaddr
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 addr,
uint64_t val,
{
MemTxResult r;
val = tswap64(val);
- r = address_space_write(as, addr, attrs, (void *) &val, 8);
+ r = address_space_write(as, addr, attrs, &val, 8);
if (result) {
*result = r;
}
@@ -3593,7 +3593,7 @@ void address_space_stq_le(AddressSpace *as, hwaddr addr,
uint64_t val,
{
MemTxResult r;
val = cpu_to_le64(val);
- r = address_space_write(as, addr, attrs, (void *) &val, 8);
+ r = address_space_write(as, addr, attrs, &val, 8);
if (result) {
*result = r;
}
@@ -3603,7 +3603,7 @@ void address_space_stq_be(AddressSpace *as, hwaddr addr,
uint64_t val,
{
MemTxResult r;
val = cpu_to_be64(val);
- r = address_space_write(as, addr, attrs, (void *) &val, 8);
+ r = address_space_write(as, addr, attrs, &val, 8);
if (result) {
*result = r;
}
diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c
index b8b33ee..e5712a2 100644
--- a/hw/net/dp8393x.c
+++ b/hw/net/dp8393x.c
@@ -431,7 +431,7 @@ static void dp8393x_do_transmit_packets(dp8393xState *s)
size = 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);
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 = (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 += rx_len;
address_space_write(&s->as, address,
- MEMTXATTRS_UNSPECIFIED, (uint8_t *)&checksum, 4);
+ MEMTXATTRS_UNSPECIFIED, &checksum, 4);
rx_len += 4;
s->regs[SONIC_CRBA1] = address >> 16;
s->regs[SONIC_CRBA0] = address & 0xffff;
@@ -756,7 +756,7 @@ static ssize_t dp8393x_receive(NetClientState *nc, const
uint8_t * buf,
address_space_write(&s->as,
(s->regs[SONIC_URDA] << 16) |
s->regs[SONIC_CRDA],
- MEMTXATTRS_UNSPECIFIED, (uint8_t *)data, size);
+ MEMTXATTRS_UNSPECIFIED, data, size);
/* Move to next descriptor */
size = sizeof(uint16_t) * width;
@@ -771,7 +771,7 @@ static ssize_t dp8393x_receive(NetClientState *nc, const
uint8_t * buf,
data[0 * width] = 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] = s->regs[SONIC_LLFA];
s->regs[SONIC_ISR] |= SONIC_ISR_PKTRX;
s->regs[SONIC_RSC] = (s->regs[SONIC_RSC] & 0xff00) |
(((s->regs[SONIC_RSC] & 0x00ff) + 1) & 0x00ff);
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 6e04cea..f4b7d59 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -164,7 +164,7 @@ static inline void vring_used_write(VirtQueue *vq,
VRingUsedElem *uelem,
virtio_tswap32s(vq->vdev, &uelem->len);
pa = vq->vring.used + offsetof(VRingUsed, ring[i]);
address_space_write(&address_space_memory, pa, MEMTXATTRS_UNSPECIFIED,
- (void *)uelem, sizeof(VRingUsedElem));
+ uelem, sizeof(VRingUsedElem));
}
static uint16_t vring_used_idx(VirtQueue *vq)
diff --git a/include/exec/memory.h b/include/exec/memory.h
index 262ecab..7851ca9 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -1304,7 +1304,7 @@ MemTxResult address_space_rw(AddressSpace *as, hwaddr
addr,
*/
MemTxResult address_space_write(AddressSpace *as, hwaddr addr,
MemTxAttrs attrs,
- const uint8_t *buf, int len);
+ const void *buf, int len);
/* address_space_ld*: load from an address space
* address_space_st*: store to an address space
--
2.5.5
- [Qemu-arm] [PATCH v3 00/10] Support non-direct memory writes in cpu_memory_rw_debug, Andrey Smirnov, 2016/07/20
- [Qemu-arm] [PATCH v3 02/10] Change signature of address_space_read() to avoid casting, Andrey Smirnov, 2016/07/20
- [Qemu-arm] [PATCH v3 03/10] Change signature of address_space_write() to avoid casting,
Andrey Smirnov <=
- [Qemu-arm] [PATCH v3 01/10] Avoid needless calls to address_space_rw(), Andrey Smirnov, 2016/07/20
- [Qemu-arm] [PATCH v3 04/10] address_space_write_continue: Distill common code, Andrey Smirnov, 2016/07/20
- [Qemu-arm] [PATCH v3 09/10] gdbstub: Convert target_memory_rw_debug to use MemoryAccessType, Andrey Smirnov, 2016/07/20
- [Qemu-arm] [PATCH v3 08/10] Convert address_space_rw to use MemoryAccessType, Andrey Smirnov, 2016/07/20
- [Qemu-arm] [PATCH v3 07/10] Convert cpu_memory_rw_debug to use MemoryAccessType, Andrey Smirnov, 2016/07/20
- [Qemu-arm] [PATCH v3 10/10] exec: Use address_space_rw to handle reads and wirtes, Andrey Smirnov, 2016/07/20
- [Qemu-arm] [PATCH v3 05/10] Rename MMUAccessType to MemoryAccessType, Andrey Smirnov, 2016/07/20