summaryrefslogtreecommitdiff
path: root/lib/sqfs/block_processor/common.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-02-16 01:05:40 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-02-16 01:05:40 +0100
commitd6143ce54787f70eda9ad2492823e6142e8c5652 (patch)
tree361dfa80d0ecdc3ac9e0bb2bcc850705fb032e53 /lib/sqfs/block_processor/common.c
parent8e52ed282e16cc0cc984d077377cd79d0f10308d (diff)
Minor cleanup
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs/block_processor/common.c')
-rw-r--r--lib/sqfs/block_processor/common.c42
1 files changed, 17 insertions, 25 deletions
diff --git a/lib/sqfs/block_processor/common.c b/lib/sqfs/block_processor/common.c
index 3859916..a1e8b6e 100644
--- a/lib/sqfs/block_processor/common.c
+++ b/lib/sqfs/block_processor/common.c
@@ -57,37 +57,31 @@ static bool is_zero_block(unsigned char *ptr, size_t size)
int block_processor_do_block(sqfs_block_t *block, sqfs_compressor_t *cmp,
sqfs_u8 *scratch, size_t scratch_size)
{
- ssize_t ret;
+ sqfs_s32 ret;
- if (block->size == 0) {
- block->checksum = 0;
+ if (block->size == 0)
return 0;
- }
if (is_zero_block(block->data, block->size)) {
block->flags |= SQFS_BLK_IS_SPARSE;
- block->checksum = 0;
return 0;
}
block->checksum = crc32(0, block->data, block->size);
- if (block->flags & SQFS_BLK_IS_FRAGMENT)
+ if (block->flags & (SQFS_BLK_IS_FRAGMENT | SQFS_BLK_DONT_COMPRESS))
return 0;
- if (!(block->flags & SQFS_BLK_DONT_COMPRESS)) {
- ret = cmp->do_block(cmp, block->data, block->size,
- scratch, scratch_size);
- if (ret < 0)
- return ret;
+ ret = cmp->do_block(cmp, block->data, block->size,
+ scratch, scratch_size);
+ if (ret < 0)
+ return ret;
- if (ret > 0) {
- memcpy(block->data, scratch, ret);
- block->size = ret;
- block->flags |= SQFS_BLK_IS_COMPRESSED;
- }
+ if (ret > 0) {
+ memcpy(block->data, scratch, ret);
+ block->size = ret;
+ block->flags |= SQFS_BLK_IS_COMPRESSED;
}
-
return 0;
}
@@ -110,11 +104,12 @@ int process_completed_fragment(sqfs_block_processor_t *proc, sqfs_block_t *frag,
proc->stats.total_frag_count += 1;
- err = sqfs_frag_table_find_tail_end(proc->frag_tbl,
- frag->checksum, frag->size,
- &index, &offset);
- if (err == 0)
- goto out_duplicate;
+ err = sqfs_frag_table_find_tail_end(proc->frag_tbl, frag->checksum,
+ frag->size, &index, &offset);
+ if (err == 0) {
+ sqfs_inode_set_frag_location(frag->inode, index, offset);
+ return 0;
+ }
if (proc->frag_block != NULL) {
size = proc->frag_block->size + frag->size;
@@ -164,9 +159,6 @@ fail:
free(*blk_out);
*blk_out = NULL;
return err;
-out_duplicate:
- sqfs_inode_set_frag_location(frag->inode, index, offset);
- return 0;
}
const sqfs_block_processor_stats_t