coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [coreutils] [PATCH] split: fix reporting of read errors


From: Pádraig Brady
Subject: Re: [coreutils] [PATCH] split: fix reporting of read errors
Date: Thu, 07 Oct 2010 20:07:45 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3

On 07/10/10 13:38, Jim Meyering wrote:
> Pádraig Brady wrote:
>> Ok to push this for the imminent release?
>> Subject: [PATCH] split: fix reporting of read errors
>>
>> The bug was introduced with commit 23f6d41f, 19-02-2003.
>>
>> * src/split.c (bytes_split, lines_split, line_bytes_split):
>> Correctly check the return from full_read().
>> * NEWS: Mention the fix.
> ...
>> @@ -325,7 +325,7 @@ line_bytes_split (size_t n_bytes)
>>        /* Fill up the full buffer size from the input file.  */
>>
>>        n_read = full_read (STDIN_FILENO, buf + n_buffered, n_bytes - 
>> n_buffered);
>> -      if (n_read == SAFE_READ_ERROR)
>> +      if (n_read < (n_bytes - n_buffered) && errno)
> 
> Yes, thanks!
> Good catch.  How did you find it?

I was testing various failure modes for the split --number patch
and noticed split was silent when passed a directory.

> However, I'd prefer to avoid parentheses like those in the final chunk,
> as well as the duplicated expression -- there are too many n_-prefixed
> names in the vicinity.  What do you think of this instead?
> 
>         size_t n =  n_bytes - n_buffered;
>         n_read = full_read (STDIN_FILENO, buf + n_buffered, n);
>         if (n_read < n && errno)

Yes I refactored a little, added a test and pushed.

cheers,
Pádraig.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]