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