[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Avoid cpu_physical_memory_rw() with a constant is_write argu
From: |
Stefan Weil |
Subject: |
Re: [PATCH] Avoid cpu_physical_memory_rw() with a constant is_write argument |
Date: |
Tue, 18 Feb 2020 19:59:08 +0100 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 |
Am 18.02.20 um 19:49 schrieb Peter Maydell:
> I think that we should fix the inconsistency where these functions
> all take "uint8_t* buf":
>
> - address_space_rw()
> - address_space_read()
> - address_space_write()
> - address_space_write_rom()
> - cpu_physical_memory_rw()
> - cpu_memory_rw_debug()
>
> but these take void*:
> - cpu_physical_memory_read()
> - cpu_physical_memory_write()
> - address_space_write_cached()
> - address_space_read_cached_slow()
> - address_space_write_cached_slow()
> - pci_dma_read()
> - pci_dma_write()
> - pci_dma_rw()
> - dma_memory_read()
> - dma_memory_write()
> - dma_memory_rw()
> - dma_memory_rw_relaxed()
>
> Depending on which way we go we would either want to remove these
> casts, or not.
>
> I guess that we have more cases of 'void*', and that would
> certainly be the easier way to convert (otherwise we probably
> need to add a bunch of new casts to uint8_t* in various callsites),
> but I don't have a strong opinion. Paolo ?
>
> thanks
> -- PMM
Indeed, fixing such inconsitencies would be good.
Personally I like the way how the standard C library handles such
pointers for functions like memcpy, fread, fwrite and others.
Therefore I suggest to use `const void *` and `void *` and to avoid type
casts.
Regards
Stefan