OSDN Git Service

print errno when reporting a system call error
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Wed, 3 May 2017 10:16:55 +0000 (17:16 +0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 26 May 2017 03:33:56 +0000 (12:33 +0900)
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/log.c
rerere.c
xdiff-interface.c

index b3b10cc..26d6a3c 100644 (file)
@@ -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;
index 971bfed..1351b0c 100644 (file)
--- 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);
                }
        }
 
index 060038c..d3f78ca 100644 (file)
@@ -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) {