OSDN Git Service

rerere.c: move error_errno() closer to the source system call
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Tue, 9 May 2017 10:11:33 +0000 (17:11 +0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 26 May 2017 03:33:56 +0000 (12:33 +0900)
We are supposed to report errno from fopen(). fclose() between fopen()
and the report function could either change errno or reset it.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
rerere.c

index 1351b0c..c26c29f 100644 (file)
--- a/rerere.c
+++ b/rerere.c
@@ -489,8 +489,9 @@ static int handle_file(const char *path, unsigned char *sha1, const char *output
        if (output) {
                io.io.output = fopen(output, "w");
                if (!io.io.output) {
+                       error_errno("Could not write %s", output);
                        fclose(io.input);
-                       return error_errno("Could not write %s", output);
+                       return -1;
                }
        }