summaryrefslogtreecommitdiff
path: root/lib/sqfs/data_reader.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-27 18:43:07 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-27 18:43:07 +0200
commitcdb1c79153b2b1377fa0ca7e1beda2b6b9b2c687 (patch)
tree18217e4bdff2e4e37adccbb7e078623f4fac3e6b /lib/sqfs/data_reader.c
parent40232f4bd4d7e8e001f7d1e8f120606f59b2c147 (diff)
Remove use of ssize_t from library API
ssize_t is only available on POSIX platforms and even there it is only defined to hold at least -1 in the range of negative numbers. This commit replaces ssize_t return types with sqfs_s32 and the coresponding function arguments with sqfs_u32. Because the range of positiv numbers for a signed 32 bit number is only half that of the unsigned version, additional checks have to be added. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs/data_reader.c')
-rw-r--r--lib/sqfs/data_reader.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/sqfs/data_reader.c b/lib/sqfs/data_reader.c
index 0befb9d..12a8feb 100644
--- a/lib/sqfs/data_reader.c
+++ b/lib/sqfs/data_reader.c
@@ -40,8 +40,8 @@ static int get_block(sqfs_data_reader_t *data, sqfs_u64 off, sqfs_u32 size,
size_t unpacked_size, sqfs_block_t **out)
{
sqfs_block_t *blk = alloc_flex(sizeof(*blk), 1, unpacked_size);
- size_t on_disk_size;
- ssize_t ret;
+ sqfs_u32 on_disk_size;
+ sqfs_s32 ret;
int err;
if (blk == NULL)
@@ -264,14 +264,17 @@ int sqfs_data_reader_get_fragment(sqfs_data_reader_t *data,
return 0;
}
-ssize_t sqfs_data_reader_read(sqfs_data_reader_t *data,
- const sqfs_inode_generic_t *inode,
- sqfs_u64 offset, void *buffer, size_t size)
+sqfs_s32 sqfs_data_reader_read(sqfs_data_reader_t *data,
+ const sqfs_inode_generic_t *inode,
+ sqfs_u64 offset, void *buffer, sqfs_u32 size)
{
- sqfs_u32 frag_idx, frag_off;
- size_t i, diff, total = 0;
+ sqfs_u32 frag_idx, frag_off, diff, total = 0;
sqfs_u64 off, filesz;
char *ptr;
+ size_t i;
+
+ if (size >= 0x7FFFFFFF)
+ size = 0x7FFFFFFE;
/* work out file location and size */
sqfs_inode_get_file_size(inode, &filesz);