about summary refs log tree commit diff
path: root/contrib/coccinelle/xstrdup_or_null.cocci
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/coccinelle/xstrdup_or_null.cocci')
-rw-r--r--contrib/coccinelle/xstrdup_or_null.cocci13
1 files changed, 13 insertions, 0 deletions
diff --git a/contrib/coccinelle/xstrdup_or_null.cocci b/contrib/coccinelle/xstrdup_or_null.cocci
new file mode 100644
index 000000000000..8e05d1ca4b61
--- /dev/null
+++ b/contrib/coccinelle/xstrdup_or_null.cocci
@@ -0,0 +1,13 @@
+@@
+expression E;
+expression V;
+@@
+- if (E)
+-    V = xstrdup(E);
++ V = xstrdup_or_null(E);
+
+@@
+expression E;
+@@
+- xstrdup(absolute_path(E))
++ absolute_pathdup(E)