From 9360ec0002369f3194cc5ac75ec50dab4979c988 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Wed, 1 Nov 2017 15:45:42 +0100 Subject: [PATCH] sequencer.c: check return value of close() in rewrite_file() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Not checking close(2) can hide errors as not all errors are reported during the write(2). Signed-off-by: Simon Ruderich Reviewed-by: René Scharfe Signed-off-by: Junio C Hamano --- sequencer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sequencer.c b/sequencer.c index f93b60f61..e0cc2f777 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; } -- 2.11.0