Re: [PATCH] copy.c: make copy_fd preserve meaningful errno
- From
Stefan Beller <sbeller@google.com>
- Date
- Nov 17, 2014, 23:13 UTC
- Message-ID
- <CAGZ79kYHzd8ODEXoZyGSb7dkZfXHAoWoiPEUqhsjedMSAjTiXg@mail.gmail.com>
- In-Reply-To
- <xmqq4mtxxw5z.fsf@gitster.dls.corp.google.com>
I am reviewing the series and about to resend it with very minor nits fixed. I just want to point out this fix is orthogonal to the series and can be picked up no matter how long the reviewing/discussion of the series goes.
Thanks, Stefan
On Mon, Nov 17, 2014 at 3:08 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 45 quoted lines
> Stefan Beller <sbeller@google.com> writes:
>
>> This patch was sent previously to the list as part of
>> that series[2], but it seems to be unrelated to me.
>
> I am fine to queue obvious and trivial bits first before the larger
> main course. For now I'll queue this one and also the series that
> has been queued for a while, but at some point I suspect we would
> have to drop the latter.
>
> Thanks.
>
>
>> [1] http://www.mail-archive.com/git@vger.kernel.org/msg61051.html
>> [2] http://www.spinics.net/lists/git/msg240784.html
>> copy.c | 15 ++++++++++-----
>> 1 file changed, 10 insertions(+), 5 deletions(-)
>>
>> diff --git a/copy.c b/copy.c
>> index f2970ec..a8d366e 100644
>> --- a/copy.c
>> +++ b/copy.c
>> @@ -8,12 +8,17 @@ int copy_fd(int ifd, int ofd)
>> if (!len)
>> break;
>> if (len < 0) {
>> - return error("copy-fd: read returned %s",
>> - strerror(errno));
>> + int save_errno = errno;
>> + error("copy-fd: read returned %s", strerror(errno));
>> + errno = save_errno;
>> + return -1;
>> + }
>> + if (write_in_full(ofd, buffer, len) < 0) {
>> + int save_errno = errno;
>> + error("copy-fd: write returned %s", strerror(errno));
>> + errno = save_errno;
>> + return -1;
>> }
>> - if (write_in_full(ofd, buffer, len) < 0)
>> - return error("copy-fd: write returned %s",
>> - strerror(errno));
>> }
>> return 0;
>> }