sequencer.c: check return value of close() in rewrite_file()

Not checking close(2) can hide errors as not all errors are reported
during the write(2).

Signed-off-by: Simon Ruderich <simon@ruderich.org>
Reviewed-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Simon Ruderich 2017-11-01 15:45:42 +01:00 коммит произвёл Junio C Hamano
Родитель c8cee96e8a
Коммит 9360ec0002
1 изменённых файлов: 2 добавлений и 1 удалений

Просмотреть файл

@ -2673,7 +2673,8 @@ static int rewrite_file(const char *path, const char *buf, size_t len)
return error_errno(_("could not open '%s' for writing"), path);
if (write_in_full(fd, buf, len) < 0)
rc = error_errno(_("could not write to '%s'"), path);
close(fd);
if (close(fd) && !rc)
rc = error_errno(_("could not close '%s'"), path);
return rc;
}