From: Nguyễn Thái Ngọc Duy Date: Wed, 3 May 2017 10:16:55 +0000 (+0700) Subject: print errno when reporting a system call error X-Git-Tag: v2.14.0-rc0~82^2~5 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=5118d7f4e6e00b7eac3ce08a16392a732edc0b2b;p=git-core%2Fgit.git print errno when reporting a system call error Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- diff --git a/builtin/log.c b/builtin/log.c index b3b10cc1e..26d6a3cf1 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 971bfedfb..1351b0c3f 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 060038c2d..d3f78ca2a 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) {