aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-02-13 23:20:49 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-02-15 18:09:40 +0100
commit5916e87394cc7e3d38102798def727ae233b9997 (patch)
treeccf64e0358a5ee036ab0dc94f9e1731c343a772c
parent943486f573ea5395d8b38735dbe019d2a3dfc5dd (diff)
Don't set error status on block processor for non-fatal errors
If the API is mis-used or allocation fails, return an appropriate error code, but don't permanently break the block processor. It's easy to recover from that. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
-rw-r--r--lib/sqfs/block_processor/fileapi.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/sqfs/block_processor/fileapi.c b/lib/sqfs/block_processor/fileapi.c
index ac73a51..ede94d7 100644
--- a/lib/sqfs/block_processor/fileapi.c
+++ b/lib/sqfs/block_processor/fileapi.c
@@ -30,7 +30,7 @@ static int add_sentinel_block(sqfs_block_processor_t *proc)
sqfs_block_t *blk = calloc(1, sizeof(*blk));
if (blk == NULL)
- return test_and_set_status(proc, SQFS_ERROR_ALLOC);
+ return SQFS_ERROR_ALLOC;
blk->inode = proc->inode;
blk->flags = proc->blk_flags | SQFS_BLK_LAST_BLOCK;
@@ -42,10 +42,10 @@ int sqfs_block_processor_begin_file(sqfs_block_processor_t *proc,
sqfs_inode_generic_t *inode, sqfs_u32 flags)
{
if (proc->inode != NULL)
- return test_and_set_status(proc, SQFS_ERROR_INTERNAL);
+ return SQFS_ERROR_SEQUENCE;
if (flags & ~SQFS_BLK_USER_SETTABLE_FLAGS)
- return test_and_set_status(proc, SQFS_ERROR_UNSUPPORTED);
+ return SQFS_ERROR_UNSUPPORTED;
proc->inode = inode;
proc->blk_flags = flags | SQFS_BLK_FIRST_BLOCK;
@@ -99,8 +99,7 @@ int sqfs_block_processor_append(sqfs_block_processor_t *proc, const void *data,
proc->max_block_size);
if (new == NULL)
- return test_and_set_status(proc,
- SQFS_ERROR_ALLOC);
+ return SQFS_ERROR_ALLOC;
proc->blk_current = new;
}
@@ -143,7 +142,7 @@ int sqfs_block_processor_end_file(sqfs_block_processor_t *proc)
int err;
if (proc->inode == NULL)
- return test_and_set_status(proc, SQFS_ERROR_INTERNAL);
+ return SQFS_ERROR_SEQUENCE;
if (!(proc->blk_flags & SQFS_BLK_FIRST_BLOCK)) {
if (proc->blk_current != NULL &&