2020-02-20 12:39:00 +03:00
|
|
|
/*
|
|
|
|
Usage:
|
|
|
|
|
|
|
|
spatch \
|
|
|
|
--macro-file scripts/cocci-macro-file.h \
|
|
|
|
--sp-file scripts/coccinelle/exec_rw_const.cocci \
|
|
|
|
--keep-comments \
|
|
|
|
--in-place \
|
|
|
|
--dir .
|
|
|
|
*/
|
|
|
|
|
2020-02-19 22:14:26 +03:00
|
|
|
// Convert to boolean
|
|
|
|
@@
|
|
|
|
expression E1, E2, E3, E4, E5;
|
|
|
|
@@
|
|
|
|
(
|
|
|
|
- address_space_rw(E1, E2, E3, E4, E5, 0)
|
|
|
|
+ address_space_rw(E1, E2, E3, E4, E5, false)
|
|
|
|
|
|
|
|
|
- address_space_rw(E1, E2, E3, E4, E5, 1)
|
|
|
|
+ address_space_rw(E1, E2, E3, E4, E5, true)
|
2020-02-19 22:20:42 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
- cpu_physical_memory_rw(E1, E2, E3, 0)
|
|
|
|
+ cpu_physical_memory_rw(E1, E2, E3, false)
|
|
|
|
|
|
|
|
|
- cpu_physical_memory_rw(E1, E2, E3, 1)
|
|
|
|
+ cpu_physical_memory_rw(E1, E2, E3, true)
|
|
|
|
|
|
|
|
|
|
|
|
|
- cpu_physical_memory_map(E1, E2, 0)
|
|
|
|
+ cpu_physical_memory_map(E1, E2, false)
|
|
|
|
|
|
|
|
|
- cpu_physical_memory_map(E1, E2, 1)
|
|
|
|
+ cpu_physical_memory_map(E1, E2, true)
|
2020-02-19 22:14:26 +03:00
|
|
|
)
|
|
|
|
|
2020-02-20 13:25:40 +03:00
|
|
|
// 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)
|
|
|
|
)
|
|
|
|
|
2020-02-18 14:24:57 +03:00
|
|
|
// Avoid uses of address_space_rw() with a constant is_write argument.
|
|
|
|
@@
|
|
|
|
expression E1, E2, E3, E4, E5;
|
|
|
|
symbol true, false;
|
|
|
|
@@
|
|
|
|
(
|
|
|
|
- address_space_rw(E1, E2, E3, E4, E5, false)
|
|
|
|
+ address_space_read(E1, E2, E3, E4, E5)
|
|
|
|
|
|
|
|
|
- address_space_rw(E1, E2, E3, E4, E5, true)
|
|
|
|
+ address_space_write(E1, E2, E3, E4, E5)
|
|
|
|
)
|
|
|
|
|
2020-02-19 22:34:58 +03:00
|
|
|
// Avoid uses of cpu_physical_memory_rw() with a constant is_write argument.
|
|
|
|
@@
|
|
|
|
expression E1, E2, E3;
|
|
|
|
@@
|
|
|
|
(
|
|
|
|
- cpu_physical_memory_rw(E1, E2, E3, false)
|
|
|
|
+ cpu_physical_memory_read(E1, E2, E3)
|
|
|
|
|
|
|
|
|
- cpu_physical_memory_rw(E1, E2, E3, true)
|
|
|
|
+ cpu_physical_memory_write(E1, E2, E3)
|
|
|
|
)
|
|
|
|
|
2020-02-20 12:39:00 +03:00
|
|
|
// Remove useless cast
|
|
|
|
@@
|
2020-02-19 22:28:22 +03:00
|
|
|
expression E1, E2, E3, E4, E5, E6;
|
2020-02-20 12:39:00 +03:00
|
|
|
type T;
|
|
|
|
@@
|
|
|
|
(
|
2020-02-19 22:28:22 +03:00
|
|
|
- address_space_rw(E1, E2, E3, (T *)(E4), E5, E6)
|
|
|
|
+ address_space_rw(E1, E2, E3, E4, E5, E6)
|
|
|
|
|
|
|
|
|
- address_space_read(E1, E2, E3, (T *)(E4), E5)
|
|
|
|
+ address_space_read(E1, E2, E3, E4, E5)
|
|
|
|
|
|
|
|
|
- address_space_write(E1, E2, E3, (T *)(E4), E5)
|
|
|
|
+ address_space_write(E1, E2, E3, E4, E5)
|
|
|
|
|
|
|
|
|
- address_space_write_rom(E1, E2, E3, (T *)(E4), E5)
|
|
|
|
+ address_space_write_rom(E1, E2, E3, E4, E5)
|
|
|
|
|
|
|
|
|
|
2020-02-20 12:51:35 +03:00
|
|
|
- cpu_physical_memory_rw(E1, (T *)(E2), E3, E4)
|
|
|
|
+ cpu_physical_memory_rw(E1, E2, E3, E4)
|
|
|
|
|
|
|
|
|
- cpu_physical_memory_read(E1, (T *)(E2), E3)
|
|
|
|
+ cpu_physical_memory_read(E1, E2, E3)
|
|
|
|
|
|
|
|
|
- cpu_physical_memory_write(E1, (T *)(E2), E3)
|
|
|
|
+ cpu_physical_memory_write(E1, E2, E3)
|
|
|
|
|
|
|
|
|
|
2020-02-20 12:39:00 +03:00
|
|
|
- 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)
|
|
|
|
)
|