summaryrefslogtreecommitdiff
path: root/sequencer.c
diff options
context:
space:
mode:
authorLibravatar Simon Ruderich <simon@ruderich.org>2017-11-01 15:45:42 +0100
committerLibravatar Junio C Hamano <gitster@pobox.com>2017-11-02 13:39:13 +0900
commit9360ec0002369f3194cc5ac75ec50dab4979c988 (patch)
tree8227ae17780a1aa0e9f7216eef10b55dcabbb7c1 /sequencer.c
parentsequencer: use O_TRUNC to truncate files (diff)
downloadtgif-9360ec0002369f3194cc5ac75ec50dab4979c988.tar.xz
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>
Diffstat (limited to 'sequencer.c')
-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;
}