summaryrefslogtreecommitdiff
path: root/lib/sqfs/block_processor/fileapi.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/fileapi.c
parent8e52ed282e16cc0cc984d077377cd79d0f10308d (diff)
Minor cleanup
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs/block_processor/fileapi.c')
-rw-r--r--lib/sqfs/block_processor/fileapi.c28
1 files changed, 13 insertions, 15 deletions
diff --git a/lib/sqfs/block_processor/fileapi.c b/lib/sqfs/block_processor/fileapi.c
index abaf3d2..098f724 100644
--- a/lib/sqfs/block_processor/fileapi.c
+++ b/lib/sqfs/block_processor/fileapi.c
@@ -44,14 +44,14 @@ int sqfs_block_processor_begin_file(sqfs_block_processor_t *proc,
proc->inode = inode;
proc->blk_flags = flags | SQFS_BLK_FIRST_BLOCK;
- proc->blk_current = NULL;
return 0;
}
-static int flush_block(sqfs_block_processor_t *proc, sqfs_block_t *block)
+static int flush_block(sqfs_block_processor_t *proc)
{
- block->flags = proc->blk_flags;
- block->inode = proc->inode;
+ sqfs_block_t *block = proc->blk_current;
+
+ proc->blk_current = NULL;
if (block->size < proc->max_block_size &&
!(block->flags & SQFS_BLK_DONT_FRAGMENT)) {
@@ -66,26 +66,25 @@ static int flush_block(sqfs_block_processor_t *proc, sqfs_block_t *block)
int sqfs_block_processor_append(sqfs_block_processor_t *proc, const void *data,
size_t size)
{
+ sqfs_block_t *new;
size_t diff;
- void *new;
int err;
while (size > 0) {
if (proc->blk_current == NULL) {
- new = alloc_flex(sizeof(*proc->blk_current), 1,
- proc->max_block_size);
-
+ new = alloc_flex(sizeof(*new), 1, proc->max_block_size);
if (new == NULL)
return SQFS_ERROR_ALLOC;
proc->blk_current = new;
+ proc->blk_current->flags = proc->blk_flags;
+ proc->blk_current->inode = proc->inode;
}
diff = proc->max_block_size - proc->blk_current->size;
if (diff == 0) {
- err = flush_block(proc, proc->blk_current);
- proc->blk_current = NULL;
+ err = flush_block(proc);
if (err)
return err;
continue;
@@ -106,9 +105,7 @@ int sqfs_block_processor_append(sqfs_block_processor_t *proc, const void *data,
if (proc->blk_current != NULL &&
proc->blk_current->size == proc->max_block_size) {
- err = flush_block(proc, proc->blk_current);
- proc->blk_current = NULL;
- return err;
+ return flush_block(proc);
}
return 0;
@@ -133,8 +130,9 @@ int sqfs_block_processor_end_file(sqfs_block_processor_t *proc)
}
if (proc->blk_current != NULL) {
- err = flush_block(proc, proc->blk_current);
- proc->blk_current = NULL;
+ err = flush_block(proc);
+ if (err)
+ return err;
}
proc->inode = NULL;