bug-cvs
[Top][All Lists]
Advanced

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

Re: CVS problem with ssh


From: Derek Price
Subject: Re: CVS problem with ssh
Date: Thu, 07 Jul 2005 15:19:52 -0400
User-agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)

Richard M. Stallman wrote:

>I wrote the code, checking the specs, and got it to compile correctly.
>I don't have any easy way to test it--Emacs is not well suited to that
>purpose.  Could you test it?
>  
>

You neglected to include a wrapper for at least fflush().

>  subst_fwrite (buffer, 1, out_count, stdout);
>
>  return out_count;
>  
>

You need to free BUFFER after writing it in all your *printf variants.

>int
>subst_fwrite (char *buffer, size_t size, size_t count, FILE *stream)
>  
>

POSIX says fwrite accepts a BUFFER of type `const void *', not `char *'.

>{
>  int count_left = count;
>  int desc = fileno (stream);
>
>  while (1)
>    {
>      int written;
>      fd_set set;
>
>      written = fwrite (buffer, size, count_left, stream);
>  
>

According to POSIX, a short return from fwrite does not guarantee that a
portion of the following item was not written for items of SIZE > 1, so
you need to convert BUFFER to COUNT * SIZE items of size 1 and loop
around writes of that to avoid writing data twice.  I'm not sure of the
most appropriate way to deal with overflow in COUNT * SIZE here.

>      if (written == count_left)
>       break;
>  
>

If errno != EAGAIN here, the function should return the short item count
anyhow, without molesting errno.  For instance, POSIX states that fputc
(and thus fwrite) can return a short count with errno = ENOSPC for a
disk full error.  This wrapper should not continue to attempt writes in
such a case.

>      /* Wait for space to be available.  */
>      FD_ZERO (&set);
>      FD_SET (desc, &set);
>      select (desc + 1, NULL, &set, NULL, NULL);
>
>      buffer += written;
>      count_left -= written;
>    }
>
>  return count;
>}
>  
>

Regards,

Derek





reply via email to

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