[Mesa-dev] [PATCH 1/3] coccinelle: remove null check before free

Thomas Hindoe Paaboel Andersen phomes at gmail.com
Wed May 4 04:15:35 UTC 2016


Adds a coccinelle dir for semantic patches. The first patch here
just removes null checks before calling free.

To create a patch call e.g.:
spatch --sp-file null-check-before-free.cocci --dir ../src > patch
---
 coccinelle/null-check-before-free.cocci | 6 ++++++
 1 file changed, 6 insertions(+)
 create mode 100644 coccinelle/null-check-before-free.cocci

diff --git a/coccinelle/null-check-before-free.cocci b/coccinelle/null-check-before-free.cocci
new file mode 100644
index 0000000..b95b252
--- /dev/null
+++ b/coccinelle/null-check-before-free.cocci
@@ -0,0 +1,6 @@
+@@
+expression p;
+@@
+- if(p) free(p);
++ free(p);
+
-- 
2.7.4



More information about the mesa-dev mailing list