Skip to content

Commit a070d62

Browse files
committed
Merge branch 'jk/simplify-csum-file-sha1fd-check' into maint
Code simplification. * jk/simplify-csum-file-sha1fd-check: sha1fd_check: die when we cannot open the file
2 parents b265061 + 599d223 commit a070d62

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

csum-file.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,10 @@ struct sha1file *sha1fd_check(const char *name)
130130

131131
sink = open("/dev/null", O_WRONLY);
132132
if (sink < 0)
133-
return NULL;
133+
die_errno("unable to open /dev/null");
134134
check = open(name, O_RDONLY);
135-
if (check < 0) {
136-
int saved_errno = errno;
137-
close(sink);
138-
errno = saved_errno;
139-
return NULL;
140-
}
135+
if (check < 0)
136+
die_errno("unable to open '%s'", name);
141137
f = sha1fd(sink, name);
142138
f->check_fd = check;
143139
return f;

0 commit comments

Comments
 (0)