summaryrefslogtreecommitdiffstats
path: root/scripts/coccinelle
diff options
context:
space:
mode:
authorPhilippe Mathieu-Daudé2020-02-24 19:52:31 +0100
committerPaolo Bonzini2020-03-17 15:18:48 +0100
commitcf949cbb7079d3856ba61ceab44880ac88f0d7eb (patch)
tree7554af278a64eb689465172f7c4f4f2c0e6acaee /scripts/coccinelle
parenthw/sparc: Use memory_region_init_rom() with read-only regions (diff)
downloadqemu-cf949cbb7079d3856ba61ceab44880ac88f0d7eb.tar.gz
qemu-cf949cbb7079d3856ba61ceab44880ac88f0d7eb.tar.xz
qemu-cf949cbb7079d3856ba61ceab44880ac88f0d7eb.zip
scripts/cocci: Patch to detect potential use of memory_region_init_rom
Add a semantic patch to detect potential replacement of memory_region_init_ram(readonly) by memory_region_init_rom(). Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Diffstat (limited to 'scripts/coccinelle')
-rw-r--r--scripts/coccinelle/memory-region-housekeeping.cocci19
1 files changed, 19 insertions, 0 deletions
diff --git a/scripts/coccinelle/memory-region-housekeeping.cocci b/scripts/coccinelle/memory-region-housekeeping.cocci
index ee3923d369..9cdde71bb1 100644
--- a/scripts/coccinelle/memory-region-housekeeping.cocci
+++ b/scripts/coccinelle/memory-region-housekeeping.cocci
@@ -29,6 +29,25 @@ symbol true;
)
+@possible_memory_region_init_rom@
+expression E1, E2, E3, E4, E5;
+position p;
+@@
+(
+ memory_region_init_ram@p(E1, E2, E3, E4, E5);
+ ...
+ memory_region_set_readonly(E1, true);
+|
+ memory_region_init_ram_nomigrate@p(E1, E2, E3, E4, E5);
+ ...
+ memory_region_set_readonly(E1, true);
+)
+@script:python@
+p << possible_memory_region_init_rom.p;
+@@
+cocci.print_main("potential use of memory_region_init_rom*() in ", p)
+
+
// Replace by-hand memory_region_init_ram_nomigrate/vmstate_register_ram
// code sequences with use of the new memory_region_init_ram function.
// Similarly for the _rom and _rom_device functions.