bug-coreutils
[Top][All Lists]
Advanced

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

Re: [Bug-gnulib] invalid use of errno after ferror


From: Jim Meyering
Subject: Re: [Bug-gnulib] invalid use of errno after ferror
Date: Tue, 23 Sep 2003 09:58:25 +0200

Thank you!
I've begun applying those changes.

The only additional change I've had to make so far is this one:

        * src/tee.c (tee): Adjust fwrite arguments so that the return
        value is the number of bytes written.

Otherwise, tee would almost always fail.

Index: tee.c
===================================================================
RCS file: /fetish/cu/src/tee.c,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -p -u -r1.67 -r1.68
--- tee.c       22 Sep 2003 16:00:49 -0000      1.67
+++ tee.c       23 Sep 2003 07:51:02 -0000      1.68
@@ -210,7 +210,7 @@ tee (int nfiles, const char **files)
         Standard output is the first one.  */
       for (i = 0; i <= nfiles; i++)
        if (descriptors[i]
-           && fwrite (buffer, bytes_read, 1, descriptors[i]) != bytes_read)
+           && fwrite (buffer, 1, bytes_read, descriptors[i]) != bytes_read)
          {
            error (0, errno, "%s", files[i]);
            descriptors[i] = NULL;


Paul Eggert <address@hidden> wrote:
> Here's a revised patch to fix invalid use of errno after ferror in
> coreutils.
...
> 2003-09-16  Paul Eggert  <address@hidden>
>
>       Don't assume ferror sets errno.  Bug reported by Bruno Haible.
...
>       * src/tee.c (tee): Once a write failure has occurred, don't bother
>       writing anything more to that stream.
...
> Index: src/tee.c
> ===================================================================
> RCS file: /cvsroot/coreutils/coreutils/src/tee.c,v
> retrieving revision 1.63
> diff -p -u -r1.63 tee.c
> --- src/tee.c 23 Jul 2003 07:29:55 -0000      1.63
> +++ src/tee.c 16 Sep 2003 20:10:37 -0000
> @@ -209,10 +209,13 @@ tee (int nfiles, const char **files)
>        /* Write to all NFILES + 1 descriptors.
>        Standard output is the first one.  */
>        for (i = 0; i <= nfiles; i++)
> -     {
> -       if (descriptors[i] != NULL)
> -         fwrite (buffer, bytes_read, 1, descriptors[i]);
> -     }
> +     if (descriptors[i]
> +         && fwrite (buffer, bytes_read, 1, descriptors[i]) != bytes_read)
...




reply via email to

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