GETIOV(;);\r
w = (*fp->_write)(fp->_cookie, p,\r
(int)MIN(len, BUFSIZ));\r
- if (w <= 0)\r
+ if (w < 0)\r
goto err;\r
p += w;\r
len -= w;\r
- } while ((uio->uio_resid -= w) != 0);\r
+ } while ((uio->uio_resid -= w) > 0);\r
+ uio->uio_resid = 0; // Just in case it went negative such as when NL is expanded to CR NL\r
} else if ((fp->_flags & __SLBF) == 0) {\r
/*\r
* Fully buffered: fill partially full buffer, if any,\r