Skip to content

Commit b1b065e

Browse files
committed
Merge branch 'rs/use-xopen-in-index-pack'
Code clean-up. * rs/use-xopen-in-index-pack: index-pack: use xopen in init_thread
2 parents d1e376d + 6346f70 commit b1b065e

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

builtin/index-pack.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,7 @@ static void init_thread(void)
188188
pthread_key_create(&key, NULL);
189189
CALLOC_ARRAY(thread_data, nr_threads);
190190
for (i = 0; i < nr_threads; i++) {
191-
thread_data[i].pack_fd = open(curr_pack, O_RDONLY);
192-
if (thread_data[i].pack_fd == -1)
193-
die_errno(_("unable to open %s"), curr_pack);
191+
thread_data[i].pack_fd = xopen(curr_pack, O_RDONLY);
194192
}
195193

196194
threads_active = 1;

contrib/coccinelle/xopen.cocci

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@
22
identifier fd;
33
identifier die_fn =~ "^(die|die_errno)$";
44
@@
5-
(
6-
fd =
5+
int fd =
76
- open
87
+ xopen
98
(...);
10-
|
11-
int fd =
9+
- if ( \( fd < 0 \| fd == -1 \) ) { die_fn(...); }
10+
11+
@@
12+
expression fd;
13+
identifier die_fn =~ "^(die|die_errno)$";
14+
@@
15+
fd =
1216
- open
1317
+ xopen
1418
(...);
15-
)
1619
- if ( \( fd < 0 \| fd == -1 \) ) { die_fn(...); }

0 commit comments

Comments
 (0)