diff options
author | Christopher Faylor <me@cgf.cx> | 2003-07-28 21:13:17 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2003-07-28 21:13:17 +0000 |
commit | d2466c7aa03059682924cec3ae1919a7fdb4795e (patch) | |
tree | 64127b3368e111c65bfa6c56e51dba67d657f1c0 /winsup/cygwin | |
parent | df4b5a9c5a4d063ad09aea1755cae0dc778853c5 (diff) | |
download | newlib-d2466c7aa03059682924cec3ae1919a7fdb4795e.zip newlib-d2466c7aa03059682924cec3ae1919a7fdb4795e.tar.gz newlib-d2466c7aa03059682924cec3ae1919a7fdb4795e.tar.bz2 |
* fhandler_base.cc (fhandler_base::readv): Rework to properly return number of
bytes from read.
Diffstat (limited to 'winsup/cygwin')
-rw-r--r-- | winsup/cygwin/ChangeLog | 5 | ||||
-rw-r--r-- | winsup/cygwin/fhandler.cc | 15 |
2 files changed, 13 insertions, 7 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 2c9ec50..1304fd8 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2003-07-28 Christopher Faylor <cgf@redhat.com> + + * fhandler_base.cc (fhandler_base::readv): Rework to properly return + number of bytes from read. + 2003-07-26 Christopher Faylor <cgf@redhat.com> * exceptions.cc (ctrl_c_handler): Send SIGHUP when events occur only if diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc index 2ab56f5..ef0328d 100644 --- a/winsup/cygwin/fhandler.cc +++ b/winsup/cygwin/fhandler.cc @@ -758,28 +758,29 @@ fhandler_base::readv (const struct iovec *const iov, const int iovcnt, assert (iov); assert (iovcnt >= 1); + size_t len = tot; if (iovcnt == 1) { - size_t len = iov->iov_len; + len = iov->iov_len; read (iov->iov_base, len); return len; } if (tot == -1) // i.e. if not pre-calculated by the caller. { - tot = 0; + len = 0; const struct iovec *iovptr = iov + iovcnt; do { iovptr -= 1; - tot += iovptr->iov_len; + len += iovptr->iov_len; } while (iovptr != iov); } assert (tot >= 0); - if (tot == 0) + if (!len) return 0; char *buf = (char *) alloca (tot); @@ -790,10 +791,10 @@ fhandler_base::readv (const struct iovec *const iov, const int iovcnt, return -1; } - read (buf, (size_t) tot); + read (buf, len); + ssize_t nbytes = (ssize_t) len; const struct iovec *iovptr = iov; - int nbytes = tot; while (nbytes > 0) { @@ -804,7 +805,7 @@ fhandler_base::readv (const struct iovec *const iov, const int iovcnt, nbytes -= frag; } - return tot; + return len; } ssize_t |