[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#11631: closed (Re: bug#11631: Head command does not position file po
From: |
Eric Blake |
Subject: |
bug#11631: closed (Re: bug#11631: Head command does not position file pointer correctly for negative line count) |
Date: |
Wed, 06 Jun 2012 05:52:23 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 |
On 06/06/2012 02:02 AM, Jim Meyering wrote:
> +++ b/src/head.c
> @@ -663,10 +663,9 @@ elide_tail_lines_seekable (const char *pretty_filename,
> int fd,
> }
>
> /* Output the initial portion of the buffer
> - in which we found the desired newline byte.
> - Don't bother testing for failure for such a small amount.
> - Any failure will be detected upon close. */
> - fwrite (buffer, 1, n + 1, stdout);
> + in which we found the desired newline byte. */
> + if (fwrite (buffer, 1, n + 1, stdout) < n + 1)
> + error (EXIT_FAILURE, errno, _("write error"));
Is testing for fwrite() sufficient? Shouldn't you actually be testing
for fflush() errors, since fwrite() buffers the output and might not
actually encounter an error until it flushes? Or even on NFS, where
fflush() may succeed but fclose() fails? In other words, our atexit()
handler for detecting fclose() failure will already catch things; we may
still be in a situation where fwrite() succeeds, we then do lseek(), but
fclose() fails, in spite of our efforts. I don't see how this patch
improves anything, other than earlier error reporting.
--
Eric Blake address@hidden +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- bug#11631: Head command does not position file pointer correctly for negative line count, (continued)
- bug#11631: Head command does not position file pointer correctly for negative line count, Jim Meyering, 2012/06/05
- Message not available
- bug#11631: Head command does not position file pointer correctly for negative line count, Jim Meyering, 2012/06/05
- bug#11631: Head command does not position file pointer correctly for negative line count, Jim Meyering, 2012/06/05
- bug#11631: Head command does not position file pointer correctly for negative line count, Pádraig Brady, 2012/06/05
- bug#11631: Head command does not position file pointer correctly for negative line count, Jim Meyering, 2012/06/05
- bug#11631: Head command does not position file pointer correctly for negative line count, Jim Meyering, 2012/06/05
Message not available
- bug#11631: closed (Re: bug#11631: Head command does not position file pointer correctly for negative line count), Anoop Sharma, 2012/06/06
- bug#11631: closed (Re: bug#11631: Head command does not position file pointer correctly for negative line count), Jim Meyering, 2012/06/06
- bug#11631: closed (Re: bug#11631: Head command does not position file pointer correctly for negative line count),
Eric Blake <=
- bug#11631: closed (Re: bug#11631: Head command does not position file pointer correctly for negative line count), Jim Meyering, 2012/06/06
- bug#11631: closed (Re: bug#11631: Head command does not position file pointer correctly for negative line count), Anoop Sharma, 2012/06/07
- bug#11631: closed (Re: bug#11631: Head command does not position file pointer correctly for negative line count), Jim Meyering, 2012/06/07
- bug#11631: closed (Re: bug#11631: Head command does not position file pointer correctly for negative line count), Anoop Sharma, 2012/06/08
- bug#11631: closed (Re: bug#11631: Head command does not position file pointer correctly for negative line count), Eric Blake, 2012/06/07
- bug#11631: closed (Re: bug#11631: Head command does not position file pointer correctly for negative line count), Anoop Sharma, 2012/06/08
bug#11631: closed (Re: bug#11631: Head command does not position file pointer correctly for negative line count), Jim Meyering, 2012/06/06