summaryrefslogtreecommitdiff
path: root/src/io.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2023-11-21 09:56:26 +0100
committerJörg Frings-Fürst <debian@jff-webhosting.net>2023-11-21 09:56:26 +0100
commit987942a206ef0f2342bf81d5de6432c6af42b7e7 (patch)
tree6befd1ab8680f2936d94ac84c94cf4f68f16c14e /src/io.c
parent163bc6d7fc268bdb1c7cc03699f69d0c5cc0b4cd (diff)
New upstream version 4.17upstream/4.17
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;
}