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
@ -12,9 +12,7 @@
|
||||
|
||||
static void create_output_file(const char *output_file)
|
||||
{
|
||||
int output_fd = open(output_file, O_CREAT | O_WRONLY | O_TRUNC, 0666);
|
||||
if (output_fd < 0)
|
||||
die_errno(_("could not create archive file '%s'"), output_file);
|
||||
int output_fd = xopen(output_file, O_CREAT | O_WRONLY | O_TRUNC, 0666);
|
||||
if (output_fd != 1) {
|
||||
if (dup2(output_fd, 1) < 0)
|
||||
die_errno(_("could not redirect output"));
|
||||
|
||||
Reference in New Issue
Block a user