xref: /qemu/scripts/coccinelle/exec_rw_const.cocci (revision 4ef044cb148a5238161310f06bc581aeed70059f)
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;
29type T;
30@@
31(
32- dma_memory_read(E1, E2, (T *)(E3), E4)
33+ dma_memory_read(E1, E2, E3, E4)
34|
35- dma_memory_write(E1, E2, (T *)(E3), E4)
36+ dma_memory_write(E1, E2, E3, E4)
37)
38