summaryrefslogtreecommitdiff
path: root/src/io.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2022-12-21 00:12:33 +0200
committerTimo Teräs <timo.teras@iki.fi>2022-12-21 00:22:59 +0200
commit5abb95ef83769d379dda99dbe8643ff7e63b0c11 (patch)
tree2e655f5d542d4d9d86a615948c9ecfd4f96387b8 /src/io.c
parenta77e28ab60f7fec2290405ffb1c32d1b673dd8b2 (diff)
downloadapk-tools-5abb95ef83769d379dda99dbe8643ff7e63b0c11.tar.gz
apk-tools-5abb95ef83769d379dda99dbe8643ff7e63b0c11.tar.bz2
apk-tools-5abb95ef83769d379dda99dbe8643ff7e63b0c11.tar.xz
apk-tools-5abb95ef83769d379dda99dbe8643ff7e63b0c11.zip
io: fix fdo_write direct write path return value and index writing
fixes commit 395e92b6 "io: formalize apk_ostream_write() always writing full data"
Diffstat (limited to 'src/io.c')
-rw-r--r--src/io.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/io.c b/src/io.c
index c802ed5..77993a2 100644
--- a/src/io.c
+++ b/src/io.c
@@ -936,12 +936,11 @@ static int fdo_write(struct apk_ostream *os, const void *ptr, size_t size)
if (size + fos->bytes >= sizeof(fos->buffer)) {
r = fdo_flush(fos);
- if (r != 0)
- return r;
+ if (r != 0) return r;
if (size >= sizeof(fos->buffer) / 2) {
r = apk_write_fully(fos->fd, ptr, size);
- if (r != size) apk_ostream_cancel(&fos->os, r < 0 ? r : -ENOSPC);
- return r;
+ if (r == size) return 0;
+ return apk_ostream_cancel(&fos->os, r < 0 ? r : -ENOSPC);
}
}