aboutsummaryrefslogtreecommitdiff
path: root/scripts/coccinelle
diff options
context:
space:
mode:
authorPhilippe Mathieu-Daudé <philmd@redhat.com>2020-02-19 20:34:58 +0100
committerPhilippe Mathieu-Daudé <philmd@redhat.com>2020-02-20 14:47:08 +0100
commitadeefe01671fb06a930beba624dc3db8367901a3 (patch)
treef44912b5d7fec71b783a96fbcd8f1b2c95efed11 /scripts/coccinelle
parent85eb7c18ee39e26002de6fa6abc5638af140e588 (diff)
Avoid cpu_physical_memory_rw() with a constant is_write argument
This commit was produced with the included Coccinelle script scripts/coccinelle/exec_rw_const. Inspired-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Diffstat (limited to 'scripts/coccinelle')
-rw-r--r--scripts/coccinelle/exec_rw_const.cocci12
1 files changed, 12 insertions, 0 deletions
diff --git a/scripts/coccinelle/exec_rw_const.cocci b/scripts/coccinelle/exec_rw_const.cocci
index 35ab79e6d7..1a20296951 100644
--- a/scripts/coccinelle/exec_rw_const.cocci
+++ b/scripts/coccinelle/exec_rw_const.cocci
@@ -62,6 +62,18 @@ symbol true, false;
+ address_space_write(E1, E2, E3, E4, E5)
)
+// Avoid uses of cpu_physical_memory_rw() with a constant is_write argument.
+@@
+expression E1, E2, E3;
+@@
+(
+- cpu_physical_memory_rw(E1, E2, E3, false)
++ cpu_physical_memory_read(E1, E2, E3)
+|
+- cpu_physical_memory_rw(E1, E2, E3, true)
++ cpu_physical_memory_write(E1, E2, E3)
+)
+
// Remove useless cast
@@
expression E1, E2, E3, E4, E5, E6;