mirror of
https://github.com/git/git.git
synced 2026-01-09 17:46:37 +00:00
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>
This commit is contained in:
committed by
Junio C Hamano
parent
a7439d0f9d
commit
66e905b7dd
@@ -131,12 +131,8 @@ struct hashfile *hashfd_check(const char *name)
|
||||
int sink, check;
|
||||
struct hashfile *f;
|
||||
|
||||
sink = open("/dev/null", O_WRONLY);
|
||||
if (sink < 0)
|
||||
die_errno("unable to open /dev/null");
|
||||
check = open(name, O_RDONLY);
|
||||
if (check < 0)
|
||||
die_errno("unable to open '%s'", name);
|
||||
sink = xopen("/dev/null", O_WRONLY);
|
||||
check = xopen(name, O_RDONLY);
|
||||
f = hashfd(sink, name);
|
||||
f->check_fd = check;
|
||||
f->check_buffer = xmalloc(f->buffer_len);
|
||||
|
||||
Reference in New Issue
Block a user