1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-04-30 11:55:12 +02:00
git/contrib/coccinelle/xopen.cocci
René Scharfe 66e905b7dd use xopen() to handle fatal open(2) failures
Add and apply a semantic patch for using xopen() instead of calling
open(2) and die() or die_errno() explicitly.  This makes the error
messages more consistent and shortens the code.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-08-25 14:39:08 -07:00

17 lines
186 B
Plaintext

@@
identifier fd;
identifier die_fn =~ "^(die|die_errno)$";
@@
(
fd =
- open
+ xopen
(...);
|
int fd =
- open
+ xopen
(...);
)
- if ( \( fd < 0 \| fd == -1 \) ) { die_fn(...); }