Skip to content

Commit

Permalink
Merge branch 'jk/simplify-csum-file-sha1fd-check' into maint
Browse files Browse the repository at this point in the history
Code simplification.

* jk/simplify-csum-file-sha1fd-check:
  sha1fd_check: die when we cannot open the file
  • Loading branch information
Junio C Hamano committed Mar 28, 2015
2 parents b265061 + 599d223 commit a070d62
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions csum-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,10 @@ struct sha1file *sha1fd_check(const char *name)

sink = open("/dev/null", O_WRONLY);
if (sink < 0)
return NULL;
die_errno("unable to open /dev/null");
check = open(name, O_RDONLY);
if (check < 0) {
int saved_errno = errno;
close(sink);
errno = saved_errno;
return NULL;
}
if (check < 0)
die_errno("unable to open '%s'", name);
f = sha1fd(sink, name);
f->check_fd = check;
return f;
Expand Down

0 comments on commit a070d62

Please sign in to comment.