Merge branch 'jk/simplify-csum-file-sha1fd-check'
Code simplification. * jk/simplify-csum-file-sha1fd-check: sha1fd_check: die when we cannot open the file
This commit is contained in:
10
csum-file.c
10
csum-file.c
@ -130,14 +130,10 @@ struct sha1file *sha1fd_check(const char *name)
|
|||||||
|
|
||||||
sink = open("/dev/null", O_WRONLY);
|
sink = open("/dev/null", O_WRONLY);
|
||||||
if (sink < 0)
|
if (sink < 0)
|
||||||
return NULL;
|
die_errno("unable to open /dev/null");
|
||||||
check = open(name, O_RDONLY);
|
check = open(name, O_RDONLY);
|
||||||
if (check < 0) {
|
if (check < 0)
|
||||||
int saved_errno = errno;
|
die_errno("unable to open '%s'", name);
|
||||||
close(sink);
|
|
||||||
errno = saved_errno;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
f = sha1fd(sink, name);
|
f = sha1fd(sink, name);
|
||||||
f->check_fd = check;
|
f->check_fd = check;
|
||||||
return f;
|
return f;
|
||||||
|
Reference in New Issue
Block a user