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// Convert to boolean 13@@ 14expression E1, E2, E3, E4, E5; 15@@ 16( 17- address_space_rw(E1, E2, E3, E4, E5, 0) 18+ address_space_rw(E1, E2, E3, E4, E5, false) 19| 20- address_space_rw(E1, E2, E3, E4, E5, 1) 21+ address_space_rw(E1, E2, E3, E4, E5, true) 22) 23 24// Use address_space_write instead of casting to non-const 25@@ 26type T; 27const T *V; 28expression E1, E2, E3, E4; 29@@ 30( 31- address_space_rw(E1, E2, E3, (T *)V, E4, 1) 32+ address_space_write(E1, E2, E3, V, E4) 33| 34- address_space_rw(E1, E2, E3, (void *)V, E4, 1) 35+ address_space_write(E1, E2, E3, V, E4) 36) 37 38// Avoid uses of address_space_rw() with a constant is_write argument. 39@@ 40expression E1, E2, E3, E4, E5; 41symbol true, false; 42@@ 43( 44- address_space_rw(E1, E2, E3, E4, E5, false) 45+ address_space_read(E1, E2, E3, E4, E5) 46| 47- address_space_rw(E1, E2, E3, E4, E5, true) 48+ address_space_write(E1, E2, E3, E4, E5) 49) 50 51// Remove useless cast 52@@ 53expression E1, E2, E3, E4, E5, E6; 54type T; 55@@ 56( 57- address_space_rw(E1, E2, E3, (T *)(E4), E5, E6) 58+ address_space_rw(E1, E2, E3, E4, E5, E6) 59| 60- address_space_read(E1, E2, E3, (T *)(E4), E5) 61+ address_space_read(E1, E2, E3, E4, E5) 62| 63- address_space_write(E1, E2, E3, (T *)(E4), E5) 64+ address_space_write(E1, E2, E3, E4, E5) 65| 66- address_space_write_rom(E1, E2, E3, (T *)(E4), E5) 67+ address_space_write_rom(E1, E2, E3, E4, E5) 68| 69 70- cpu_physical_memory_rw(E1, (T *)(E2), E3, E4) 71+ cpu_physical_memory_rw(E1, E2, E3, E4) 72| 73- cpu_physical_memory_read(E1, (T *)(E2), E3) 74+ cpu_physical_memory_read(E1, E2, E3) 75| 76- cpu_physical_memory_write(E1, (T *)(E2), E3) 77+ cpu_physical_memory_write(E1, E2, E3) 78| 79 80- dma_memory_read(E1, E2, (T *)(E3), E4) 81+ dma_memory_read(E1, E2, E3, E4) 82| 83- dma_memory_write(E1, E2, (T *)(E3), E4) 84+ dma_memory_write(E1, E2, E3, E4) 85) 86