print errno when reporting a system call error
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
382fb07f7b
commit
5118d7f4e6
@ -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;
|
||||
|
4
rerere.c
4
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user