summaryrefslogtreecommitdiff
path: root/lib/sqfshelper
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-07 20:19:05 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-07 20:40:07 +0200
commit60064dd0412a149fe00cfc4e2f2361c22656db57 (patch)
treef4a2aaed857aeca621ee96e46e23858d4025fcf8 /lib/sqfshelper
parente71c56420a8fc3dc7e36eb059304a362b47a1c15 (diff)
Remove printing to stderr in libsquashfs with returning error numbers
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfshelper')
-rw-r--r--lib/sqfshelper/data_reader.c14
-rw-r--r--lib/sqfshelper/deserialize_fstree.c20
-rw-r--r--lib/sqfshelper/xattr_reader.c6
3 files changed, 22 insertions, 18 deletions
diff --git a/lib/sqfshelper/data_reader.c b/lib/sqfshelper/data_reader.c
index f7984b8..fc92e28 100644
--- a/lib/sqfshelper/data_reader.c
+++ b/lib/sqfshelper/data_reader.c
@@ -109,6 +109,8 @@ data_reader_t *data_reader_create(int fd, sqfs_super_t *super,
{
data_reader_t *data = alloc_flex(sizeof(*data), super->block_size, 3);
size_t i, size;
+ void *raw_frag;
+ int ret;
if (data == NULL) {
perror("creating data reader");
@@ -142,15 +144,17 @@ data_reader_t *data_reader_create(int fd, sqfs_super_t *super,
return NULL;
}
- data->frag = sqfs_read_table(fd, cmp, size,
- super->fragment_table_start,
- super->directory_table_start,
- super->fragment_table_start);
- if (data->frag == NULL) {
+ ret = sqfs_read_table(fd, cmp, size, super->fragment_table_start,
+ super->directory_table_start,
+ super->fragment_table_start, &raw_frag);
+
+ if (ret) {
free(data);
return NULL;
}
+ data->frag = raw_frag;
+
for (i = 0; i < data->num_fragments; ++i) {
data->frag[i].size = le32toh(data->frag[i].size);
data->frag[i].start_offset =
diff --git a/lib/sqfshelper/deserialize_fstree.c b/lib/sqfshelper/deserialize_fstree.c
index a3cf44d..1953f9b 100644
--- a/lib/sqfshelper/deserialize_fstree.c
+++ b/lib/sqfshelper/deserialize_fstree.c
@@ -90,6 +90,7 @@ static int fill_dir(sqfs_meta_reader_t *ir, sqfs_meta_reader_t *dr,
uint64_t block_start;
size_t size, diff;
uint32_t i;
+ int err;
size = root->data.dir->size;
if (size <= sizeof(hdr))
@@ -110,8 +111,7 @@ static int fill_dir(sqfs_meta_reader_t *ir, sqfs_meta_reader_t *dr,
size -= sizeof(hdr);
for (i = 0; i <= hdr.count && size > sizeof(*ent); ++i) {
- ent = sqfs_meta_reader_read_dir_ent(dr);
- if (ent == NULL)
+ if (sqfs_meta_reader_read_dir_ent(dr, &ent))
return -1;
diff = sizeof(*ent) + strlen((char *)ent->name);
@@ -126,12 +126,12 @@ static int fill_dir(sqfs_meta_reader_t *ir, sqfs_meta_reader_t *dr,
continue;
}
- inode = sqfs_meta_reader_read_inode(ir, super,
- hdr.start_block,
- ent->offset);
- if (inode == NULL) {
+ err = sqfs_meta_reader_read_inode(ir, super,
+ hdr.start_block,
+ ent->offset, &inode);
+ if (err) {
free(ent);
- return -1;
+ return err;
}
n = tree_node_from_inode(inode, idtbl,
@@ -240,10 +240,12 @@ int deserialize_fstree(fstree_t *out, sqfs_super_t *super,
if (xr == NULL)
goto out_id;
+ if (sqfs_xattr_reader_load_locations(xr))
+ goto out_xr;
+
block_start = super->root_inode_ref >> 16;
offset = super->root_inode_ref & 0xFFFF;
- root = sqfs_meta_reader_read_inode(ir, super, block_start, offset);
- if (root == NULL)
+ if (sqfs_meta_reader_read_inode(ir, super, block_start, offset, &root))
goto out_xr;
if (root->base.type != SQFS_INODE_DIR &&
diff --git a/lib/sqfshelper/xattr_reader.c b/lib/sqfshelper/xattr_reader.c
index a0dc6f6..376fdb2 100644
--- a/lib/sqfshelper/xattr_reader.c
+++ b/lib/sqfshelper/xattr_reader.c
@@ -24,12 +24,10 @@ static int restore_kv_pairs(sqfs_xattr_reader_t *xr, fstree_t *fs,
int ret;
for (i = 0; i < node->xattr->num_attr; ++i) {
- key = sqfs_xattr_reader_read_key(xr);
- if (key == NULL)
+ if (sqfs_xattr_reader_read_key(xr, &key))
return -1;
- val = sqfs_xattr_reader_read_value(xr, key);
- if (val == NULL)
+ if (sqfs_xattr_reader_read_value(xr, key, &val))
goto fail_key;
ret = str_table_get_index(&fs->xattr_keys,