olga / rpms / glibc

Forked from rpms/glibc 5 years ago
Clone
00db10
diff --git glibc-2.17-c758a686/libio/fileops.c glibc-2.17-c758a686/libio/fileops.c
00db10
index 61b61b3..5f3dae7 100644
00db10
--- glibc-2.17-c758a686/libio/fileops.c
00db10
+++ glibc-2.17-c758a686/libio/fileops.c
00db10
@@ -1245,13 +1245,12 @@ _IO_new_file_write (f, data, n)
00db10
      _IO_ssize_t n;
00db10
 {
00db10
   _IO_ssize_t to_do = n;
00db10
-  _IO_ssize_t count = 0;
00db10
   while (to_do > 0)
00db10
     {
00db10
-      count = (__builtin_expect (f->_flags2
00db10
-				 & _IO_FLAGS2_NOTCANCEL, 0)
00db10
-	       ? write_not_cancel (f->_fileno, data, to_do)
00db10
-	       : write (f->_fileno, data, to_do));
00db10
+      _IO_ssize_t count = (__builtin_expect (f->_flags2
00db10
+					     & _IO_FLAGS2_NOTCANCEL, 0)
00db10
+			   ? write_not_cancel (f->_fileno, data, to_do)
00db10
+			   : write (f->_fileno, data, to_do));
00db10
       if (count < 0)
00db10
 	{
00db10
 	  f->_flags |= _IO_ERR_SEEN;
00db10
@@ -1263,7 +1262,7 @@ _IO_new_file_write (f, data, n)
00db10
   n -= to_do;
00db10
   if (f->_offset >= 0)
00db10
     f->_offset += n;
00db10
-  return count < 0 ? count : n;
00db10
+  return n;
00db10
 }
00db10
00db10
 _IO_size_t
00db10
@@ -1323,13 +1322,11 @@ _IO_new_file_xsputn (f, data, n)
00db10
       _IO_size_t block_size, do_write;
00db10
       /* Next flush the (full) buffer. */
00db10
       if (_IO_OVERFLOW (f, EOF) == EOF)
00db10
-	/* If nothing else has to be written or nothing has been written, we
00db10
-	   must not signal the caller that the call was even partially
00db10
-	   successful.  */
00db10
-	return (to_do == 0 || to_do == n) ? EOF : n - to_do;
00db10
+	/* If nothing else has to be written we must not signal the
00db10
+	   caller that everything has been written.  */
00db10
+	return to_do == 0 ? EOF : n - to_do;
00db10
00db10
-      /* Try to maintain alignment: write a whole number of blocks.
00db10
-	 dont_write is what gets left over. */
00db10
+      /* Try to maintain alignment: write a whole number of blocks.  */
00db10
       block_size = f->_IO_buf_end - f->_IO_buf_base;
00db10
       do_write = to_do - (block_size >= 128 ? to_do % block_size : 0);
00db10
00db10
diff --git glibc-2.17-c758a686/libio/iofwrite.c glibc-2.17-c758a686/libio/iofwrite.c
00db10
index 81596a6..66542ea 100644
00db10
--- glibc-2.17-c758a686/libio/iofwrite.c
00db10
+++ glibc-2.17-c758a686/libio/iofwrite.c
00db10
@@ -42,12 +42,12 @@ _IO_fwrite (buf, size, count, fp)
00db10
   if (_IO_vtable_offset (fp) != 0 || _IO_fwide (fp, -1) == -1)
00db10
     written = _IO_sputn (fp, (const char *) buf, request);
00db10
   _IO_release_lock (fp);
00db10
-  /* We are guaranteed to have written all of the input, none of it, or
00db10
-     some of it.  */
00db10
-  if (written == request)
00db10
+  /* We have written all of the input in case the return value indicates
00db10
+     this or EOF is returned.  The latter is a special case where we
00db10
+     simply did not manage to flush the buffer.  But the data is in the
00db10
+     buffer and therefore written as far as fwrite is concerned.  */
00db10
+  if (written == request || written == EOF)
00db10
     return count;
00db10
-  else if (written == EOF)
00db10
-    return 0;
00db10
   else
00db10
     return written / size;
00db10
 }
00db10
diff --git glibc-2.17-c758a686/libio/iofwrite_u.c glibc-2.17-c758a686/libio/iofwrite_u.c
00db10
index 4a9d6ca..18dc6d0 100644
00db10
--- glibc-2.17-c758a686/libio/iofwrite_u.c
00db10
+++ glibc-2.17-c758a686/libio/iofwrite_u.c
00db10
@@ -44,12 +44,12 @@ fwrite_unlocked (buf, size, count, fp)
00db10
   if (_IO_fwide (fp, -1) == -1)
00db10
     {
00db10
       written = _IO_sputn (fp, (const char *) buf, request);
00db10
-      /* We are guaranteed to have written all of the input, none of it, or
00db10
-	 some of it.  */
00db10
-      if (written == request)
00db10
+      /* We have written all of the input in case the return value indicates
00db10
+	 this or EOF is returned.  The latter is a special case where we
00db10
+	 simply did not manage to flush the buffer.  But the data is in the
00db10
+	 buffer and therefore written as far as fwrite is concerned.  */
00db10
+      if (written == request || written == EOF)
00db10
 	return count;
00db10
-      else if (written == EOF)
00db10
-	return 0;
00db10
     }
00db10
00db10
   return written / size;
00db10
diff --git glibc-2.17-c758a686/libio/iopadn.c glibc-2.17-c758a686/libio/iopadn.c
00db10
index cc93c0f..5ebbcf4 100644
00db10
--- glibc-2.17-c758a686/libio/iopadn.c
00db10
+++ glibc-2.17-c758a686/libio/iopadn.c
00db10
@@ -59,7 +59,7 @@ _IO_padn (fp, pad, count)
00db10
       w = _IO_sputn (fp, padptr, PADSIZE);
00db10
       written += w;
00db10
       if (w != PADSIZE)
00db10
-	return w == EOF ? w : written;
00db10
+	return written;
00db10
     }
00db10
00db10
   if (i > 0)
00db10
diff --git glibc-2.17-c758a686/libio/iowpadn.c glibc-2.17-c758a686/libio/iowpadn.c
00db10
index d94db71..5600f37 100644
00db10
--- glibc-2.17-c758a686/libio/iowpadn.c
00db10
+++ glibc-2.17-c758a686/libio/iowpadn.c
00db10
@@ -65,7 +65,7 @@ _IO_wpadn (fp, pad, count)
00db10
       w = _IO_sputn (fp, (char *) padptr, PADSIZE);
00db10
       written += w;
00db10
       if (w != PADSIZE)
00db10
-	return w == EOF ? w : written;
00db10
+	return written;
00db10
     }
00db10
00db10
   if (i > 0)
00db10
diff --git glibc-2.17-c758a686/stdio-common/vfprintf.c glibc-2.17-c758a686/stdio-common/vfprintf.c
00db10
index c8bcf5a..61d9dc2 100644
00db10
--- glibc-2.17-c758a686/stdio-common/vfprintf.c
00db10
+++ glibc-2.17-c758a686/stdio-common/vfprintf.c
00db10
@@ -90,13 +90,13 @@
00db10
   do {									      \
00db10
     if (width > 0)							      \
00db10
       {									      \
00db10
-	unsigned int d = _IO_padn (s, (Padchar), width);		      \
00db10
-	if (__builtin_expect (d == EOF, 0))				      \
00db10
+	_IO_ssize_t written = _IO_padn (s, (Padchar), width);		      \
00db10
+	if (__glibc_unlikely (written != width))			      \
00db10
 	  {								      \
00db10
 	    done = -1;							      \
00db10
 	    goto all_done;						      \
00db10
 	  }								      \
00db10
-	done_add (d);							      \
00db10
+	done_add (written);						      \
00db10
       }									      \
00db10
   } while (0)
00db10
 # define PUTC(C, F)	_IO_putc_unlocked (C, F)
00db10
@@ -119,13 +119,13 @@
00db10
   do {									      \
00db10
     if (width > 0)							      \
00db10
       {									      \
00db10
-	unsigned int d = _IO_wpadn (s, (Padchar), width);		      \
00db10
-	if (__builtin_expect (d == EOF, 0))				      \
00db10
+	_IO_ssize_t written = _IO_wpadn (s, (Padchar), width);		      \
00db10
+	if (__glibc_unlikely (written != width))			      \
00db10
 	  {								      \
00db10
 	    done = -1;							      \
00db10
 	    goto all_done;						      \
00db10
 	  }								      \
00db10
-	done_add (d);							      \
00db10
+	done_add (written);						      \
00db10
       }									      \
00db10
   } while (0)
00db10
 # define PUTC(C, F)	_IO_putwc_unlocked (C, F)
00db10