Skip to content

Commit 5118d7f

Browse files
pcloudsgitster
authored andcommitted
print errno when reporting a system call error
Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 382fb07 commit 5118d7f

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

builtin/log.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,8 @@ static int open_next_file(struct commit *commit, const char *subject,
858858
printf("%s\n", filename.buf + outdir_offset);
859859

860860
if ((rev->diffopt.file = fopen(filename.buf, "w")) == NULL)
861-
return error(_("Cannot open patch file %s"), filename.buf);
861+
return error_errno(_("Cannot open patch file %s"),
862+
filename.buf);
862863

863864
strbuf_release(&filename);
864865
return 0;

rerere.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,13 +484,13 @@ static int handle_file(const char *path, unsigned char *sha1, const char *output
484484
io.input = fopen(path, "r");
485485
io.io.wrerror = 0;
486486
if (!io.input)
487-
return error("Could not open %s", path);
487+
return error_errno("Could not open %s", path);
488488

489489
if (output) {
490490
io.io.output = fopen(output, "w");
491491
if (!io.io.output) {
492492
fclose(io.input);
493-
return error("Could not write %s", output);
493+
return error_errno("Could not write %s", output);
494494
}
495495
}
496496

xdiff-interface.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,9 @@ int read_mmfile(mmfile_t *ptr, const char *filename)
164164
size_t sz;
165165

166166
if (stat(filename, &st))
167-
return error("Could not stat %s", filename);
167+
return error_errno("Could not stat %s", filename);
168168
if ((f = fopen(filename, "rb")) == NULL)
169-
return error("Could not open %s", filename);
169+
return error_errno("Could not open %s", filename);
170170
sz = xsize_t(st.st_size);
171171
ptr->ptr = xmalloc(sz ? sz : 1);
172172
if (sz && fread(ptr->ptr, sz, 1, f) != 1) {

0 commit comments

Comments
 (0)