summaryrefslogtreecommitdiff
path: root/contrib/coccinelle/xopen.cocci
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/coccinelle/xopen.cocci')
-rw-r--r--contrib/coccinelle/xopen.cocci19
1 files changed, 19 insertions, 0 deletions
diff --git a/contrib/coccinelle/xopen.cocci b/contrib/coccinelle/xopen.cocci
new file mode 100644
index 0000000000..b71db67019
--- /dev/null
+++ b/contrib/coccinelle/xopen.cocci
@@ -0,0 +1,19 @@
+@@
+identifier fd;
+identifier die_fn =~ "^(die|die_errno)$";
+@@
+ int fd =
+- open
++ xopen
+ (...);
+- if ( \( fd < 0 \| fd == -1 \) ) { die_fn(...); }
+
+@@
+expression fd;
+identifier die_fn =~ "^(die|die_errno)$";
+@@
+ fd =
+- open
++ xopen
+ (...);
+- if ( \( fd < 0 \| fd == -1 \) ) { die_fn(...); }