summaryrefslogtreecommitdiffstats
path: root/scripts/coccinelle
diff options
context:
space:
mode:
authorLaurent Vivier2016-05-31 18:35:50 +0200
committerMichael Tokarev2016-06-07 17:19:24 +0200
commitdb718b4b150dd8a732e2b26368eba510b6887f01 (patch)
tree61e18f13ba84a353f40d0a5654a308e2c1a2508d /scripts/coccinelle
parentthunk: Rename args and fields in host-target bitmask conversion code (diff)
downloadqemu-db718b4b150dd8a732e2b26368eba510b6887f01.tar.gz
qemu-db718b4b150dd8a732e2b26368eba510b6887f01.tar.xz
qemu-db718b4b150dd8a732e2b26368eba510b6887f01.zip
coccinelle: use macro DIV_ROUND_UP instead of (((n) + (d) - 1) /(d))
sample from http://coccinellery.org/ Signed-off-by: Laurent Vivier <lvivier@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Diffstat (limited to 'scripts/coccinelle')
-rw-r--r--scripts/coccinelle/round.cocci19
1 files changed, 19 insertions, 0 deletions
diff --git a/scripts/coccinelle/round.cocci b/scripts/coccinelle/round.cocci
new file mode 100644
index 0000000000..ed06773289
--- /dev/null
+++ b/scripts/coccinelle/round.cocci
@@ -0,0 +1,19 @@
+// Use macro DIV_ROUND_UP instead of (((n) + (d) - 1) /(d))
+@@
+expression e1;
+expression e2;
+@@
+(
+- ((e1) + e2 - 1) / (e2)
++ DIV_ROUND_UP(e1,e2)
+|
+- ((e1) + (e2 - 1)) / (e2)
++ DIV_ROUND_UP(e1,e2)
+)
+
+@@
+expression e1;
+expression e2;
+@@
+-(DIV_ROUND_UP(e1,e2))
++DIV_ROUND_UP(e1,e2)