diff options
Diffstat (limited to 'src/io.c')
-rw-r--r-- | src/io.c | 11 |
1 files changed, 4 insertions, 7 deletions
@@ -655,7 +655,7 @@ static ssize_t HX_sendfile_rw(int dst, int src, size_t count) { static const size_t bufsize = 0x10000; size_t xferd = 0; - ssize_t ret; + ssize_t ret = 0; void *buf = malloc(bufsize); if (buf == nullptr) return -ENOMEM; @@ -665,16 +665,13 @@ static ssize_t HX_sendfile_rw(int dst, int src, size_t count) size_t readsize = bufsize; if (count < readsize) readsize = count; + /* Return value of fullread/write is same as read/write(2). */ ret = HXio_fullread(src, buf, readsize); - if (ret < 0) { - errno = -ret; + if (ret < 0) break; - } ret = HXio_fullwrite(dst, buf, ret); - if (ret < 0) { - errno = -ret; + if (ret < 0) break; - } xferd += ret; count -= ret; } |