Re: [PATCH v2 15/21] rerere.c: report correct errno
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- May 3, 2017, 15:24 UTC
- Message-ID
- <alpine.DEB.2.20.1705031722420.3480@virtualbox>
- In-Reply-To
- <20170503101706.9223-16-pclouds@gmail.com>
Hi Duy,
On Wed, 3 May 2017, Nguyễn Thái Ngọc Duy wrote:
Show 10 quoted lines
> 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);IMO the error() -> error_errno() changes should all be part of the same commit, as they probably share the explanation why fopen_or_warn() is not appropriate here.
Show 8 quoted lines
> 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;
> }This one is logically different from the change above, as it not only cannot be replaced by fopen_or_warn(), but also requires the reordering due to the different nature of the change.
Ciao, Dscho