aboutsummaryrefslogtreecommitdiff
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
parenttree-wide: make use of new STRLEN() macro everywhere (#7639) (diff)
downloadsystemd-673192494c129975b605541ee688143ecf2a6416.tar.gz
systemd-673192494c129975b605541ee688143ecf2a6416.tar.bz2
systemd-673192494c129975b605541ee688143ecf2a6416.zip
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 000000000..ebdc3f6a2
--- /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)