aboutsummaryrefslogtreecommitdiff
path: root/lib/io
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-06-09 13:53:53 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-06-09 13:53:53 +0200
commit115ba7e0830a00a7b0bce5887c8ffeba78e3ab53 (patch)
treed376e30d5e830fc6292480203e7e39a6f9017243 /lib/io
parent9a4110f3c205107a3a48a0e48b760abf3cd1f3bc (diff)
libio: remove eof flag from istream_t interface
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/io')
-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
9 files changed, 8 insertions, 21 deletions
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);