From 5118d7f4e6e00b7eac3ce08a16392a732edc0b2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Wed, 3 May 2017 17:16:55 +0700 Subject: print errno when reporting a system call error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- builtin/log.c | 3 ++- rerere.c | 4 ++-- xdiff-interface.c | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/builtin/log.c b/builtin/log.c index b3b10cc1ed..26d6a3cf14 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -858,7 +858,8 @@ static int open_next_file(struct commit *commit, const char *subject, printf("%s\n", filename.buf + outdir_offset); if ((rev->diffopt.file = fopen(filename.buf, "w")) == NULL) - return error(_("Cannot open patch file %s"), filename.buf); + return error_errno(_("Cannot open patch file %s"), + filename.buf); strbuf_release(&filename); return 0; diff --git a/rerere.c b/rerere.c index 971bfedfb2..1351b0c3fb 100644 --- a/rerere.c +++ b/rerere.c @@ -484,13 +484,13 @@ static int handle_file(const char *path, unsigned char *sha1, const char *output io.input = fopen(path, "r"); io.io.wrerror = 0; if (!io.input) - return error("Could not open %s", path); + return error_errno("Could not open %s", path); if (output) { io.io.output = fopen(output, "w"); if (!io.io.output) { fclose(io.input); - return error("Could not write %s", output); + return error_errno("Could not write %s", output); } } diff --git a/xdiff-interface.c b/xdiff-interface.c index 060038c2d6..d3f78ca2a7 100644 --- a/xdiff-interface.c +++ b/xdiff-interface.c @@ -164,9 +164,9 @@ int read_mmfile(mmfile_t *ptr, const char *filename) size_t sz; if (stat(filename, &st)) - return error("Could not stat %s", filename); + return error_errno("Could not stat %s", filename); if ((f = fopen(filename, "rb")) == NULL) - return error("Could not open %s", filename); + return error_errno("Could not open %s", filename); sz = xsize_t(st.st_size); ptr->ptr = xmalloc(sz ? sz : 1); if (sz && fread(ptr->ptr, sz, 1, f) != 1) { -- cgit v1.2.3