aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/io/istream.h2
-rw-r--r--lib/io/src/mem.c3
-rw-r--r--lib/io/src/unix/istream.c5
-rw-r--r--lib/io/src/win32/istream.c7
-rw-r--r--lib/io/src/xfrm/istream.c9
-rw-r--r--lib/io/test/istream_mem.c1
-rw-r--r--lib/io/test/istream_read.c1
-rw-r--r--lib/io/test/istream_skip.c1
-rw-r--r--lib/io/test/stream_splice.c1
-rw-r--r--lib/io/test/xfrm.c1
-rw-r--r--lib/tar/src/iterator.c5
11 files changed, 11 insertions, 25 deletions
diff --git a/include/io/istream.h b/include/io/istream.h
index 06e8a3b..f091aa1 100644
--- a/include/io/istream.h
+++ b/include/io/istream.h
@@ -21,8 +21,6 @@ typedef struct istream_t {
sqfs_object_t base;
size_t buffer_used;
- bool eof;
-
const sqfs_u8 *buffer;
int (*precache)(struct istream_t *strm);
diff --git a/lib/io/src/mem.c b/lib/io/src/mem.c
index b1abbdb..39e0d6b 100644
--- a/lib/io/src/mem.c
+++ b/lib/io/src/mem.c
@@ -51,9 +51,6 @@ static int mem_in_precache(istream_t *strm)
mem->size -= diff;
}
- if (mem->size == 0)
- strm->eof = true;
-
return 0;
}
diff --git a/lib/io/src/unix/istream.c b/lib/io/src/unix/istream.c
index db870d9..8a2dc26 100644
--- a/lib/io/src/unix/istream.c
+++ b/lib/io/src/unix/istream.c
@@ -11,6 +11,7 @@ typedef struct {
char *path;
int fd;
+ bool eof;
sqfs_u8 buffer[BUFSZ];
} file_istream_t;
@@ -29,12 +30,12 @@ static int file_precache(istream_t *strm)
strm->buffer = file->buffer;
- while (!strm->eof && strm->buffer_used < BUFSZ) {
+ while (!file->eof && strm->buffer_used < BUFSZ) {
ssize_t ret = read(file->fd, file->buffer + strm->buffer_used,
BUFSZ - strm->buffer_used);
if (ret == 0)
- strm->eof = true;
+ file->eof = true;
if (ret < 0) {
if (errno == EINTR)
diff --git a/lib/io/src/win32/istream.c b/lib/io/src/win32/istream.c
index 94c8584..c4d7458 100644
--- a/lib/io/src/win32/istream.c
+++ b/lib/io/src/win32/istream.c
@@ -14,6 +14,7 @@ typedef struct {
char *path;
HANDLE hnd;
+ bool eof;
sqfs_u8 buffer[BUFSZ];
} file_istream_t;
@@ -23,7 +24,7 @@ static int file_precache(istream_t *strm)
DWORD diff, actual;
HANDLE hnd;
- if (strm->eof)
+ if (file->eof)
return 0;
assert(strm->buffer >= file->buffer);
@@ -47,7 +48,7 @@ static int file_precache(istream_t *strm)
if (error == ERROR_HANDLE_EOF ||
error == ERROR_BROKEN_PIPE) {
- strm->eof = true;
+ file->eof = true;
break;
}
@@ -58,7 +59,7 @@ static int file_precache(istream_t *strm)
}
if (actual == 0) {
- strm->eof = true;
+ file->eof = true;
break;
}
diff --git a/lib/io/src/xfrm/istream.c b/lib/io/src/xfrm/istream.c
index a89ac3d..2ada5db 100644
--- a/lib/io/src/xfrm/istream.c
+++ b/lib/io/src/xfrm/istream.c
@@ -20,9 +20,6 @@ static int xfrm_precache(istream_t *base)
istream_xfrm_t *xfrm = (istream_xfrm_t *)base;
int ret, sret;
- if (base->eof)
- return 0;
-
assert(base->buffer >= xfrm->uncompressed);
assert(base->buffer <= (xfrm->uncompressed + BUFSZ));
assert(base->buffer_used <= BUFSZ);
@@ -73,11 +70,8 @@ static int xfrm_precache(istream_t *base)
if (ret == XFRM_STREAM_BUFFER_FULL || out_off >= BUFSZ)
break;
- if (mode == XFRM_STREAM_FLUSH_FULL) {
- if (base->buffer_used == 0)
- base->eof = true;
+ if (mode == XFRM_STREAM_FLUSH_FULL)
break;
- }
}
return 0;
@@ -115,7 +109,6 @@ istream_t *istream_xfrm_create(istream_t *strm, xfrm_stream_t *xfrm)
base->precache = xfrm_precache;
base->get_filename = xfrm_get_filename;
base->buffer = stream->uncompressed;
- base->eof = false;
return base;
fail:
fprintf(stderr, "%s: error initializing decompressor stream.\n",
diff --git a/lib/io/test/istream_mem.c b/lib/io/test/istream_mem.c
index c74b1f5..632b1f5 100644
--- a/lib/io/test/istream_mem.c
+++ b/lib/io/test/istream_mem.c
@@ -72,7 +72,6 @@ int main(int argc, char **argv)
}
TEST_EQUAL_UI(in->buffer_used, 0);
- TEST_ASSERT(in->eof);
sqfs_drop(in);
return EXIT_SUCCESS;
}
diff --git a/lib/io/test/istream_read.c b/lib/io/test/istream_read.c
index 7029c38..176832b 100644
--- a/lib/io/test/istream_read.c
+++ b/lib/io/test/istream_read.c
@@ -100,7 +100,6 @@ int main(int argc, char **argv)
TEST_ASSERT(read_off <= end2);
}
- TEST_ASSERT(dummy->eof);
TEST_ASSERT(dummy->buffer_used == 0);
sqfs_drop(dummy);
return EXIT_SUCCESS;
diff --git a/lib/io/test/istream_skip.c b/lib/io/test/istream_skip.c
index c54a9cd..15d7f5d 100644
--- a/lib/io/test/istream_skip.c
+++ b/lib/io/test/istream_skip.c
@@ -89,7 +89,6 @@ int main(int argc, char **argv)
TEST_ASSERT(read_off <= end2);
}
- TEST_ASSERT(dummy->eof);
TEST_ASSERT(dummy->buffer_used == 0);
sqfs_drop(dummy);
return EXIT_SUCCESS;
diff --git a/lib/io/test/stream_splice.c b/lib/io/test/stream_splice.c
index ab8a0e4..223c39d 100644
--- a/lib/io/test/stream_splice.c
+++ b/lib/io/test/stream_splice.c
@@ -91,7 +91,6 @@ int main(int argc, char **argv)
TEST_EQUAL_UI(total, out_offset);
}
- TEST_ASSERT(in->eof);
TEST_ASSERT(in->buffer_used == 0);
TEST_EQUAL_UI(total, end2);
TEST_EQUAL_UI(out_offset, end2);
diff --git a/lib/io/test/xfrm.c b/lib/io/test/xfrm.c
index ffb1f37..95b1f72 100644
--- a/lib/io/test/xfrm.c
+++ b/lib/io/test/xfrm.c
@@ -440,7 +440,6 @@ static void run_unpack_test(const void *blob, size_t size)
TEST_EQUAL_I(ret, 0);
TEST_EQUAL_UI(mem_istream->buffer_used, 0);
- TEST_ASSERT(mem_istream->eof);
sqfs_drop(istream);
TEST_EQUAL_UI(((sqfs_object_t *)mem_istream)->refcount, 1);
diff --git a/lib/tar/src/iterator.c b/lib/tar/src/iterator.c
index 2914e3a..442ddeb 100644
--- a/lib/tar/src/iterator.c
+++ b/lib/tar/src/iterator.c
@@ -39,6 +39,7 @@ typedef struct {
tar_iterator_t *parent;
+ bool eof;
sqfs_u8 buffer[4096];
} tar_istream_t;
@@ -85,7 +86,7 @@ static int strm_precache(istream_t *strm)
tar_istream_t *tar = (tar_istream_t *)strm;
sqfs_u64 diff;
- if (strm->eof)
+ if (tar->eof)
goto out_eof;
if (!tar->parent->last_sparse) {
@@ -146,7 +147,7 @@ fail_io:
tar->parent->state = SQFS_ERROR_IO;
return -1;
out_eof:
- strm->eof = true;
+ tar->eof = true;
strm->buffer_used = 0;
strm->buffer = tar->buffer;
tar->parent->locked = false;