Source-Changes-HG archive

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

[src/trunk]: src/lib/libc/stdio Include the 0 return from write. Although the...



details:   https://anonhg.NetBSD.org/src/rev/26079bc7223c
branches:  trunk
changeset: 984455:26079bc7223c
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Jul 08 15:44:44 2021 +0000

description:
Include the 0 return from write. Although the real write system call does
not return 0, the synthetic writes from funopen/fmemopen could. This avoids
infinite loops in >= test19 in fmemopen, but the tests still fail, perhaps
because they assume the previous behavior, where flush does not adjust the
stdio pointers on error.

diffstat:

 lib/libc/stdio/fflush.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (27 lines):

diff -r db9129debe5b -r 26079bc7223c lib/libc/stdio/fflush.c
--- a/lib/libc/stdio/fflush.c   Thu Jul 08 15:21:40 2021 +0000
+++ b/lib/libc/stdio/fflush.c   Thu Jul 08 15:44:44 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fflush.c,v 1.21 2021/07/08 09:06:51 christos Exp $     */
+/*     $NetBSD: fflush.c,v 1.22 2021/07/08 15:44:44 christos Exp $     */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)fflush.c   8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: fflush.c,v 1.21 2021/07/08 09:06:51 christos Exp $");
+__RCSID("$NetBSD: fflush.c,v 1.22 2021/07/08 15:44:44 christos Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -107,7 +107,7 @@
 
        for (; n > 0; n -= t, p += t) {
                t = (*fp->_write)(fp->_cookie, (char *)p, n);
-               if (t < 0) {
+               if (t <= 0) {
                        /* Reset _p and _w. */
                        if (p > fp->_p) {
                                /* Some was written. */



Home | Main Index | Thread Index | Old Index