summaryrefslogtreecommitdiff
path: root/src/io.c
diff options
context:
space:
mode:
authorthibault.ferrante <thibault.ferrante@gmail.com>2021-01-07 17:21:36 +0100
committerTimo Teräs <timo.teras@iki.fi>2021-01-11 11:26:49 +0200
commit0fb0d304774630d53867fa3563dfd39246cc67b7 (patch)
treeb65d3ee173f4f7eab613c99487494d476a30965b /src/io.c
parentb58d79e78f704233f7c412343b25f20c8fb5257c (diff)
downloadapk-tools-0fb0d304774630d53867fa3563dfd39246cc67b7.tar.gz
apk-tools-0fb0d304774630d53867fa3563dfd39246cc67b7.tar.bz2
apk-tools-0fb0d304774630d53867fa3563dfd39246cc67b7.tar.xz
apk-tools-0fb0d304774630d53867fa3563dfd39246cc67b7.zip
database: Propagate errors when loading an APKINDEX
In case of failure when loading an APKINDEX, no errors are propagated to the user which may uncorrectly interpret the current problem.
Diffstat (limited to 'src/io.c')
-rw-r--r--src/io.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/io.c b/src/io.c
index 97b0d57..dde1d23 100644
--- a/src/io.c
+++ b/src/io.c
@@ -207,14 +207,16 @@ static ssize_t segment_read(struct apk_istream *is, void *ptr, size_t size)
return r;
}
-static void segment_close(struct apk_istream *is)
+static int segment_close(struct apk_istream *is)
{
+ int r = is->err;
struct apk_segment_istream *sis = container_of(is, struct apk_segment_istream, is);
if (sis->bytes_left) {
apk_istream_read(sis->pis, NULL, sis->bytes_left);
sis->bytes_left = 0;
}
+ return r < 0 ? r : 0;
}
static const struct apk_istream_ops segment_istream_ops = {
@@ -283,8 +285,9 @@ static ssize_t tee_read(struct apk_istream *is, void *ptr, size_t size)
return __tee_write(tee, ptr, r);
}
-static void tee_close(struct apk_istream *is)
+static int tee_close(struct apk_istream *is)
{
+ int r;
struct apk_tee_istream *tee = container_of(is, struct apk_tee_istream, is);
struct apk_file_meta meta;
@@ -293,9 +296,10 @@ static void tee_close(struct apk_istream *is)
apk_file_meta_to_fd(tee->fd, &meta);
}
- apk_istream_close(tee->inner_is);
+ r = apk_istream_close(tee->inner_is);
close(tee->fd);
free(tee);
+ return r;
}
static const struct apk_istream_ops tee_istream_ops = {
@@ -368,13 +372,15 @@ static ssize_t mmap_read(struct apk_istream *is, void *ptr, size_t size)
return 0;
}
-static void mmap_close(struct apk_istream *is)
+static int mmap_close(struct apk_istream *is)
{
+ int r = is->err;
struct apk_mmap_istream *mis = container_of(is, struct apk_mmap_istream, is);
munmap(mis->is.buf, mis->is.buf_size);
close(mis->fd);
free(mis);
+ return r < 0 ? r : 0;
}
static const struct apk_istream_ops mmap_istream_ops = {
@@ -434,12 +440,14 @@ static ssize_t fdi_read(struct apk_istream *is, void *ptr, size_t size)
return r;
}
-static void fdi_close(struct apk_istream *is)
+static int fdi_close(struct apk_istream *is)
{
+ int r = is->err;
struct apk_fd_istream *fis = container_of(is, struct apk_fd_istream, is);
close(fis->fd);
free(fis);
+ return r < 0 ? r : 0;
}
static const struct apk_istream_ops fd_istream_ops = {