Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
sequencer.c: check return value of close() in rewrite_file()
author
Simon Ruderich
<simon@ruderich.org>
Wed, 1 Nov 2017 14:45:42 +0000
(15:45 +0100)
committer
Junio C Hamano
<gitster@pobox.com>
Thu, 2 Nov 2017 04:39:13 +0000
(13:39 +0900)
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>
sequencer.c
patch
|
blob
|
history
raw
|
patch
| inline |
side by side
(parent:
c8cee96
)
diff --git
a/sequencer.c
b/sequencer.c
index f93b60f615ca390f16f80f42e13f04dd7d3afacc..e0cc2f777e46f70ba1b393cb97c4bf3a90f09ada 100644
(file)
--- 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;
}