summaryrefslogtreecommitdiff
path: root/src/io_gunzip.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2021-07-17 15:43:08 +0300
committerTimo Teräs <timo.teras@iki.fi>2021-07-22 15:30:08 +0300
commitb559a81694d8a95ac786104516aebf98d04b84bc (patch)
tree2bd4601015e0d7202c3eb685bf79756022d11b06 /src/io_gunzip.c
parent94c5e01038a819e8abd062ed81aec321cdff4aa3 (diff)
downloadapk-tools-b559a81694d8a95ac786104516aebf98d04b84bc.tar.gz
apk-tools-b559a81694d8a95ac786104516aebf98d04b84bc.tar.bz2
apk-tools-b559a81694d8a95ac786104516aebf98d04b84bc.tar.xz
apk-tools-b559a81694d8a95ac786104516aebf98d04b84bc.zip
io: rework apk_istream_get_* to not return erros in blob value
The interface was slightly cumbersome, so replace these functions to return explicit error, and make the return blob a pointer arg.
Diffstat (limited to 'src/io_gunzip.c')
-rw-r--r--src/io_gunzip.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/io_gunzip.c b/src/io_gunzip.c
index e1a23d6..3cab464 100644
--- a/src/io_gunzip.c
+++ b/src/io_gunzip.c
@@ -67,17 +67,18 @@ static ssize_t gzi_read(struct apk_istream *is, void *ptr, size_t size)
APK_BLOB_PTR_LEN(gis->cbprev,
(void *)gis->zs.next_in - gis->cbprev));
}
- blob = apk_istream_get_all(gis->zis);
+ r = apk_istream_get_all(gis->zis, &blob);
gis->cbprev = blob.ptr;
gis->zs.avail_in = blob.len;
gis->zs.next_in = (void *) gis->cbprev;
- if (blob.len < 0) {
- gis->is.err = blob.len;
- goto ret;
- } else if (gis->zs.avail_in == 0) {
- gis->is.err = 1;
- gis->cbarg = APK_BLOB_NULL;
- gzi_boundary_change(gis);
+ if (r < 0) {
+ if (r == -APKE_EOF) {
+ gis->is.err = 1;
+ gis->cbarg = APK_BLOB_NULL;
+ gzi_boundary_change(gis);
+ } else {
+ gis->is.err = r;
+ }
goto ret;
}
}