summaryrefslogtreecommitdiff
path: root/src/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/io.c')
-rw-r--r--src/io.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/io.c b/src/io.c
index 76c9444..ee48dee 100644
--- a/src/io.c
+++ b/src/io.c
@@ -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;
}