xref: /qemu/scripts/coccinelle/exec_rw_const.cocci (revision 0eeef0a4d328b0da543c44678d00cfb7546b11a1)
1/*
2  Usage:
3
4    spatch \
5           --macro-file scripts/cocci-macro-file.h \
6           --sp-file scripts/coccinelle/exec_rw_const.cocci \
7           --keep-comments \
8           --in-place \
9           --dir .
10*/
11
12// Use address_space_write instead of casting to non-const
13@@
14type T;
15const T *V;
16expression E1, E2, E3, E4;
17@@
18(
19- address_space_rw(E1, E2, E3, (T *)V, E4, 1)
20+ address_space_write(E1, E2, E3, V, E4)
21|
22- address_space_rw(E1, E2, E3, (void *)V, E4, 1)
23+ address_space_write(E1, E2, E3, V, E4)
24)
25
26// Remove useless cast
27@@
28expression E1, E2, E3, E4, E5, E6;
29type T;
30@@
31(
32- address_space_rw(E1, E2, E3, (T *)(E4), E5, E6)
33+ address_space_rw(E1, E2, E3, E4, E5, E6)
34|
35- address_space_read(E1, E2, E3, (T *)(E4), E5)
36+ address_space_read(E1, E2, E3, E4, E5)
37|
38- address_space_write(E1, E2, E3, (T *)(E4), E5)
39+ address_space_write(E1, E2, E3, E4, E5)
40|
41- address_space_write_rom(E1, E2, E3, (T *)(E4), E5)
42+ address_space_write_rom(E1, E2, E3, E4, E5)
43|
44
45- cpu_physical_memory_rw(E1, (T *)(E2), E3, E4)
46+ cpu_physical_memory_rw(E1, E2, E3, E4)
47|
48- cpu_physical_memory_read(E1, (T *)(E2), E3)
49+ cpu_physical_memory_read(E1, E2, E3)
50|
51- cpu_physical_memory_write(E1, (T *)(E2), E3)
52+ cpu_physical_memory_write(E1, E2, E3)
53|
54
55- dma_memory_read(E1, E2, (T *)(E3), E4)
56+ dma_memory_read(E1, E2, E3, E4)
57|
58- dma_memory_write(E1, E2, (T *)(E3), E4)
59+ dma_memory_write(E1, E2, E3, E4)
60)
61