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