[prev in list] [next in list] [prev in thread] [next in thread] 

List:       coreutils
Subject:    Re: [coreutils] [PATCH] split: fix reporting of read errors
From:       Pádraig Brady <P () draigBrady ! com>
Date:       2010-10-07 19:07:45
Message-ID: 4CAE1A81.4070707 () draigBrady ! com
[Download RAW message or body]

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.


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic