From: Simon Ruderich Date: Wed, 1 Nov 2017 14:45:42 +0000 (+0100) Subject: sequencer.c: check return value of close() in rewrite_file() X-Git-Tag: v2.15.1~10^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=9360ec0002369f3194cc5ac75ec50dab4979c988;p=git-core%2Fgit.git 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 Reviewed-by: René Scharfe Signed-off-by: Junio C Hamano --- 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; }