summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ruderich <simon@ruderich.org>2017-11-01 15:45:42 +0100
committerJunio C Hamano <gitster@pobox.com>2017-11-02 13:39:13 +0900
commit9360ec0002369f3194cc5ac75ec50dab4979c988 (patch)
tree8227ae17780a1aa0e9f7216eef10b55dcabbb7c1
parentc8cee96e8a8de2e9c6f12bfac8295f1b9ee29112 (diff)
downloadgit-rs/sequencer-rewrite-file-cleanup.tar.gz
sequencer.c: check return value of close() in rewrite_file()rs/sequencer-rewrite-file-cleanup
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>
-rw-r--r--sequencer.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/sequencer.c b/sequencer.c
index f93b60f615..e0cc2f777e 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -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;
}