summaryrefslogtreecommitdiff
path: root/contrib/coccinelle
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2021-09-08 13:30:32 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2021-09-08 13:30:32 -0700
commit7b062226196c7234818106ab5274b32519e41575 (patch)
treeaf74b94d18186099a4a7929968a7691138058735 /contrib/coccinelle
parentMerge branch 'dd/diff-files-unmerged-fix' (diff)
parentuse xopen() to handle fatal open(2) failures (diff)
downloadtgif-7b062226196c7234818106ab5274b32519e41575.tar.xz
Merge branch 'rs/xopen-reports-open-failures'
Error diagnostics improvement. * rs/xopen-reports-open-failures: use xopen() to handle fatal open(2) failures xopen: explicitly report creation failures
Diffstat (limited to 'contrib/coccinelle')
-rw-r--r--contrib/coccinelle/xopen.cocci16
1 files changed, 16 insertions, 0 deletions
diff --git a/contrib/coccinelle/xopen.cocci b/contrib/coccinelle/xopen.cocci
new file mode 100644
index 0000000000..814d7b8a1a
--- /dev/null
+++ b/contrib/coccinelle/xopen.cocci
@@ -0,0 +1,16 @@
+@@
+identifier fd;
+identifier die_fn =~ "^(die|die_errno)$";
+@@
+(
+ fd =
+- open
++ xopen
+ (...);
+|
+ int fd =
+- open
++ xopen
+ (...);
+)
+- if ( \( fd < 0 \| fd == -1 \) ) { die_fn(...); }