1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-19 04:46:11 +02:00
git/contrib/coccinelle/xopen.cocci
René Scharfe 6346f704a0 index-pack: use xopen in init_thread
Support an arbitrary file descriptor expression in the semantic patch
for replacing open+die_errno with xopen, not just an identifier, and
apply it.  This makes the error message at the single affected place
more consistent and reduces code duplication.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-09-10 14:22:50 -07:00

20 lines
295 B
Plaintext

@@
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(...); }