mirror of
https://github.com/qemu/qemu.git
synced 2025-08-02 12:45:00 +00:00

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>
38 lines
735 B
Plaintext
38 lines
735 B
Plaintext
/*
|
|
Usage:
|
|
|
|
spatch \
|
|
--macro-file scripts/cocci-macro-file.h \
|
|
--sp-file scripts/coccinelle/exec_rw_const.cocci \
|
|
--keep-comments \
|
|
--in-place \
|
|
--dir .
|
|
*/
|
|
|
|
// Use address_space_write instead of casting to non-const
|
|
@@
|
|
type T;
|
|
const T *V;
|
|
expression E1, E2, E3, E4;
|
|
@@
|
|
(
|
|
- address_space_rw(E1, E2, E3, (T *)V, E4, 1)
|
|
+ address_space_write(E1, E2, E3, V, E4)
|
|
|
|
|
- address_space_rw(E1, E2, E3, (void *)V, E4, 1)
|
|
+ address_space_write(E1, E2, E3, V, E4)
|
|
)
|
|
|
|
// Remove useless cast
|
|
@@
|
|
expression E1, E2, E3, E4;
|
|
type T;
|
|
@@
|
|
(
|
|
- dma_memory_read(E1, E2, (T *)(E3), E4)
|
|
+ dma_memory_read(E1, E2, E3, E4)
|
|
|
|
|
- dma_memory_write(E1, E2, (T *)(E3), E4)
|
|
+ dma_memory_write(E1, E2, E3, E4)
|
|
)
|