summaryrefslogtreecommitdiff
path: root/coccinelle
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2017-12-14 19:47:46 +0100
committerLennart Poettering <lennart@poettering.net>2017-12-14 19:47:46 +0100
commit673192494c129975b605541ee688143ecf2a6416 (patch)
treeb67b544a5b9a0994bf4e2664a1968739bbebe77c /coccinelle
parentfbd0b64f44a7bae678137d67ad5da202f6b8d809 (diff)
coccinelle: automatically rewrite memset() to zero() or memzero() where we can
We are pretty good at this already, hence only a single case is actually found by this.
Diffstat (limited to 'coccinelle')
-rw-r--r--coccinelle/memzero.cocci30
1 files changed, 30 insertions, 0 deletions
diff --git a/coccinelle/memzero.cocci b/coccinelle/memzero.cocci
new file mode 100644
index 0000000000..ebdc3f6a2a
--- /dev/null
+++ b/coccinelle/memzero.cocci
@@ -0,0 +1,30 @@
+@@
+expression s;
+@@
+- memset(&s, 0, sizeof(s))
++ zero(s)
+@@
+expression s;
+@@
+- memset(s, 0, sizeof(*s))
++ zero(*s)
+@@
+expression s;
+@@
+- bzero(&s, sizeof(s))
++ zero(s)
+@@
+expression s;
+@@
+- bzero(s, sizeof(*s))
++ zero(*s)
+@@
+expression a, b;
+@@
+- memset(a, 0, b)
++ memzero(a, b)
+@@
+expression a, b;
+@@
+- bzero(a, b)
++ memzero(a, b)