summaryrefslogtreecommitdiff
path: root/src/io.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2015-04-13 09:41:49 +0300
committerTimo Teräs <timo.teras@iki.fi>2015-04-13 09:42:27 +0300
commit3490ff789a9375d3047c6580f24a55157ebef4f0 (patch)
treea07390ce63f550a0f8e8f0736df5079354ee6602 /src/io.c
parent43955329325c823579ded743efb324cc8ea1daba (diff)
downloadapk-tools-3490ff789a9375d3047c6580f24a55157ebef4f0.tar.gz
apk-tools-3490ff789a9375d3047c6580f24a55157ebef4f0.tar.bz2
apk-tools-3490ff789a9375d3047c6580f24a55157ebef4f0.tar.xz
apk-tools-3490ff789a9375d3047c6580f24a55157ebef4f0.zip
fix tee io error handling
use ERR_PTR mechanism, and handle it at all places.
Diffstat (limited to 'src/io.c')
-rw-r--r--src/io.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/io.c b/src/io.c
index 765afc5..fa8a048 100644
--- a/src/io.c
+++ b/src/io.c
@@ -421,22 +421,24 @@ static void tee_close(void *stream, size_t *size)
struct apk_bstream *apk_bstream_tee(struct apk_bstream *from, int atfd, const char *to, apk_progress_cb cb, void *cb_ctx)
{
struct apk_tee_bstream *tbs;
- int fd;
+ int fd, r;
if (IS_ERR_OR_NULL(from)) return ERR_CAST(from);
fd = openat(atfd, to, O_CREAT | O_RDWR | O_TRUNC | O_CLOEXEC,
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (fd < 0) {
+ r = errno;
from->close(from, NULL);
- return NULL;
+ return ERR_PTR(-r);
}
tbs = malloc(sizeof(struct apk_tee_bstream));
if (!tbs) {
+ r = errno;
close(fd);
from->close(from, NULL);
- return NULL;
+ return ERR_PTR(-r);
}
tbs->bs = (struct apk_bstream) {