summaryrefslogtreecommitdiff
path: root/lib/sqfs/blk_proc/process_block.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-23 23:33:19 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-23 23:33:19 +0200
commit824423a9d2395514101cb837c2ede5473cf106ce (patch)
treeac28f76ad83db93fac4a2cb2252093cfc3ec5c2f /lib/sqfs/blk_proc/process_block.c
parentc169887cc5d3ab83e7383234f46ad8963bc22b98 (diff)
Cleanup block processor error handling
If an error happpens, immediately stop everything and report only the first error that happened. This also fixes a memory leak in the error paths of the serial and pthread based block processors. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs/blk_proc/process_block.c')
-rw-r--r--lib/sqfs/blk_proc/process_block.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/lib/sqfs/blk_proc/process_block.c b/lib/sqfs/blk_proc/process_block.c
index 5d1fa58..643d964 100644
--- a/lib/sqfs/blk_proc/process_block.c
+++ b/lib/sqfs/blk_proc/process_block.c
@@ -20,11 +20,8 @@ int sqfs_block_process(sqfs_block_t *block, sqfs_compressor_t *cmp,
if (!(block->flags & SQFS_BLK_DONT_COMPRESS)) {
ret = cmp->do_block(cmp, block->data, block->size,
scratch, scratch_size);
-
- if (ret < 0) {
- block->flags |= SQFS_BLK_COMPRESS_ERROR;
+ if (ret < 0)
return ret;
- }
if (ret > 0) {
memcpy(block->data, scratch, ret);
@@ -188,19 +185,24 @@ static int handle_block(sqfs_block_processor_t *proc, sqfs_block_t *blk)
int process_completed_blocks(sqfs_block_processor_t *proc, sqfs_block_t *queue)
{
sqfs_block_t *it;
+ int err;
while (queue != NULL) {
it = queue;
queue = queue->next;
- if (it->flags & SQFS_BLK_COMPRESS_ERROR) {
- proc->status = SQFS_ERROR_COMRPESSOR;
- } else if (proc->status == 0) {
- proc->status = handle_block(proc, it);
- }
-
+ err = handle_block(proc, it);
free(it);
+
+ if (err) {
+ while (queue != NULL) {
+ it = queue;
+ queue = it->next;
+ free(it);
+ }
+ return err;
+ }
}
- return proc->status;
+ return 0;
}