summaryrefslogtreecommitdiff
path: root/coccinelle
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-02-27 19:09:22 +0100
committerLennart Poettering <lennart@poettering.net>2018-03-02 12:39:07 +0100
commit62d74c78b59f95a76778d9fa8dbe3b098afa2aad (patch)
tree138ea4e336b01254a6766e547fdc10c3728255ef /coccinelle
parent3209c8e6502c095bb7a88a3e915f06dd56228ed4 (diff)
coccinelle: add reallocarray() coccinelle script
Let's systematically make use of reallocarray() whereever we invoke realloc() with a product of two values.
Diffstat (limited to 'coccinelle')
-rw-r--r--coccinelle/reallocarray.cocci20
1 files changed, 20 insertions, 0 deletions
diff --git a/coccinelle/reallocarray.cocci b/coccinelle/reallocarray.cocci
new file mode 100644
index 0000000000..21fe9dfbfd
--- /dev/null
+++ b/coccinelle/reallocarray.cocci
@@ -0,0 +1,20 @@
+@@
+expression q, p, n, m;
+@@
+- q = realloc(p, (n)*(m))
++ q = reallocarray(p, n, m)
+@@
+expression q, p, n, m;
+@@
+- q = realloc(p, n*(m))
++ q = reallocarray(p, n, m)
+@@
+expression q, p, n, m;
+@@
+- q = realloc(p, (n)*m)
++ q = reallocarray(p, n, m)
+@@
+expression q, p, n, m;
+@@
+- q = realloc(p, n*m)
++ q = reallocarray(p, n, m)