From 81c47bee5b554688aaeaedc9d8453a676b9a9107 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Thu, 13 Feb 2020 23:51:13 +0100 Subject: Cleanup: block processor: remove test_and_set_status Signed-off-by: David Oberhollenzer --- lib/sqfs/block_processor/internal.h | 3 --- lib/sqfs/block_processor/serial.c | 8 -------- lib/sqfs/block_processor/winpthread.c | 26 ++++++++++++-------------- 3 files changed, 12 insertions(+), 25 deletions(-) (limited to 'lib/sqfs') diff --git a/lib/sqfs/block_processor/internal.h b/lib/sqfs/block_processor/internal.h index 4fd2728..a764b2f 100644 --- a/lib/sqfs/block_processor/internal.h +++ b/lib/sqfs/block_processor/internal.h @@ -123,9 +123,6 @@ SQFS_INTERNAL int block_processor_do_block(sqfs_block_t *block, sqfs_compressor_t *cmp, sqfs_u8 *scratch, size_t scratch_size); -SQFS_INTERNAL -int test_and_set_status(sqfs_block_processor_t *proc, int status); - SQFS_INTERNAL int append_to_work_queue(sqfs_block_processor_t *proc, sqfs_block_t *block); diff --git a/lib/sqfs/block_processor/serial.c b/lib/sqfs/block_processor/serial.c index 9c21950..dce7490 100644 --- a/lib/sqfs/block_processor/serial.c +++ b/lib/sqfs/block_processor/serial.c @@ -36,14 +36,6 @@ sqfs_block_processor_t *sqfs_block_processor_create(size_t max_block_size, return proc; } -int test_and_set_status(sqfs_block_processor_t *proc, int status) -{ - if (proc->status == 0) - proc->status = status; - - return proc->status; -} - int append_to_work_queue(sqfs_block_processor_t *proc, sqfs_block_t *block) { sqfs_block_t *fragblk = NULL; diff --git a/lib/sqfs/block_processor/winpthread.c b/lib/sqfs/block_processor/winpthread.c index 6d7c843..ca07718 100644 --- a/lib/sqfs/block_processor/winpthread.c +++ b/lib/sqfs/block_processor/winpthread.c @@ -410,19 +410,6 @@ static int process_done_queue(sqfs_block_processor_t *proc, sqfs_block_t *queue) return status; } -int test_and_set_status(sqfs_block_processor_t *proc, int status) -{ - LOCK(&proc->mtx); - if (proc->status == 0) { - proc->status = status; - } else { - status = proc->status; - } - SIGNAL_ALL(&proc->queue_cond); - UNLOCK(&proc->mtx); - return status; -} - int wait_completed(sqfs_block_processor_t *proc) { sqfs_block_t *queue; @@ -446,5 +433,16 @@ int wait_completed(sqfs_block_processor_t *proc) } status = process_done_queue(proc, queue); - return status ? test_and_set_status(proc, status) : status; + + if (status != 0) { + LOCK(&proc->mtx); + if (proc->status == 0) { + proc->status = status; + } else { + status = proc->status; + } + SIGNAL_ALL(&proc->queue_cond); + UNLOCK(&proc->mtx); + } + return status; } -- cgit v1.2.3