[PATCH v2 15/21] rerere.c: report correct errno
- From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
- Date
- May 3, 2017, 10:17 UTC
- Message-ID
- <20170503101706.9223-16-pclouds@gmail.com>
- In-Reply-To
- <20170503101706.9223-1-pclouds@gmail.com>
In the first case, we should have reported the reason fopen() fails. In the second case, fclose() might change errno but we want to report fopen() failure.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> --- rerere.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/rerere.c b/rerere.c index 971bfedfb2..c26c29f87a 100644 --- a/rerere.c +++ b/rerere.c @@ -484,13 +484,14 @@ 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) { + error_errno("Could not write %s", output); fclose(io.input); - return error("Could not write %s", output); + return -1; } }
-- 2.11.0.157.gd943d85