diff options
author | Philippe Mathieu-Daudé <philmd@redhat.com> | 2020-02-20 11:25:40 +0100 |
---|---|---|
committer | Philippe Mathieu-Daudé <philmd@redhat.com> | 2020-02-20 14:47:08 +0100 |
commit | 4ef044cb148a5238161310f06bc581aeed70059f (patch) | |
tree | 98bd540884f6640a2be5dcced871697e556b31a6 /hw/net | |
parent | daa3dda43af90d1c88d439891c6c7129959ccc77 (diff) | |
download | qemu-4ef044cb148a5238161310f06bc581aeed70059f.zip qemu-4ef044cb148a5238161310f06bc581aeed70059f.tar.gz qemu-4ef044cb148a5238161310f06bc581aeed70059f.tar.bz2 |
hw/net: Avoid casting non-const pointer, use address_space_write()
The NetReceive prototype gets a const buffer:
typedef ssize_t (NetReceive)(NetClientState *, const uint8_t *, size_t);
We already have the address_space_write() method to write a const
buffer to an address space. Use it to avoid:
hw/net/i82596.c: In function ‘i82596_receive’:
hw/net/i82596.c:644:54: error: passing argument 4 of ‘address_space_rw’ discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
This commit was produced with the included Coccinelle script
scripts/coccinelle/exec_rw_const.
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Diffstat (limited to 'hw/net')
-rw-r--r-- | hw/net/dp8393x.c | 3 | ||||
-rw-r--r-- | hw/net/i82596.c | 4 |
2 files changed, 3 insertions, 4 deletions
diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c index a134d43..580ae44 100644 --- a/hw/net/dp8393x.c +++ b/hw/net/dp8393x.c @@ -787,8 +787,7 @@ static ssize_t dp8393x_receive(NetClientState *nc, const uint8_t * buf, /* Put packet into RBA */ DPRINTF("Receive packet at %08x\n", dp8393x_crba(s)); address = dp8393x_crba(s); - address_space_rw(&s->as, address, - MEMTXATTRS_UNSPECIFIED, (uint8_t *)buf, rx_len, 1); + address_space_write(&s->as, address, MEMTXATTRS_UNSPECIFIED, buf, rx_len); address += rx_len; address_space_rw(&s->as, address, MEMTXATTRS_UNSPECIFIED, (uint8_t *)&checksum, 4, 1); diff --git a/hw/net/i82596.c b/hw/net/i82596.c index 3a0e1ec..a292984 100644 --- a/hw/net/i82596.c +++ b/hw/net/i82596.c @@ -640,8 +640,8 @@ ssize_t i82596_receive(NetClientState *nc, const uint8_t *buf, size_t sz) } rba = get_uint32(rbd + 8); /* printf("rba is 0x%x\n", rba); */ - address_space_rw(&address_space_memory, rba, - MEMTXATTRS_UNSPECIFIED, (void *)buf, num, 1); + address_space_write(&address_space_memory, rba, + MEMTXATTRS_UNSPECIFIED, buf, num); rba += num; buf += num; len -= num; |