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>

Simon Ruderich committed Nov 1, 2017 at 15:45 UTC 9360ec0002369f3194cc5ac75ec50dab4979c988
1 file changed +2 -1
sequencer.c
+2 -1
@@ -2673,7 +2673,8 @@ static int rewrite_file(const char *path, const char *buf, size_t len)
2673 return error_errno(_("could not open '%s' for writing"), path);
2674 if (write_in_full(fd, buf, len) < 0)
2675 rc = error_errno(_("could not write to '%s'"), path);
2676 - close(fd);
2676 + if (close(fd) && !rc)
2677 + rc = error_errno(_("could not close '%s'"), path);
2678 return rc;
2679 }
2680