From f675c45459508d058aeda4869e2928be4b7ffd99 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Mon, 12 May 2014 17:22:20 -0500 Subject: [PATCH] chunk compressor: Use u32, not unsigned, for chunk sizes --- include/wimlib/chunk_compressor.h | 2 +- src/compress_parallel.c | 9 ++++----- src/compress_serial.c | 10 ++++++---- src/write.c | 8 ++++---- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/include/wimlib/chunk_compressor.h b/include/wimlib/chunk_compressor.h index 4684a61c..b902038a 100644 --- a/include/wimlib/chunk_compressor.h +++ b/include/wimlib/chunk_compressor.h @@ -53,7 +53,7 @@ struct chunk_compressor { * successfully retrieved, or %false if there are no chunks currently * being compressed. */ bool (*get_chunk)(struct chunk_compressor *, - const void **, unsigned *, unsigned *); + const void **, u32 *, u32 *); }; diff --git a/src/compress_parallel.c b/src/compress_parallel.c index c99c0a86..f339298a 100644 --- a/src/compress_parallel.c +++ b/src/compress_parallel.c @@ -67,8 +67,8 @@ struct compressor_thread_data { struct message { u8 *uncompressed_chunks[MAX_CHUNKS_PER_MSG]; u8 *compressed_chunks[MAX_CHUNKS_PER_MSG]; - unsigned uncompressed_chunk_sizes[MAX_CHUNKS_PER_MSG]; - unsigned compressed_chunk_sizes[MAX_CHUNKS_PER_MSG]; + u32 uncompressed_chunk_sizes[MAX_CHUNKS_PER_MSG]; + u32 compressed_chunk_sizes[MAX_CHUNKS_PER_MSG]; size_t num_filled_chunks; size_t num_alloc_chunks; struct list_head list; @@ -361,8 +361,8 @@ parallel_chunk_compressor_submit_chunk(struct chunk_compressor *_ctx, static bool parallel_chunk_compressor_get_chunk(struct chunk_compressor *_ctx, - const void **cdata_ret, unsigned *csize_ret, - unsigned *usize_ret) + const void **cdata_ret, u32 *csize_ret, + u32 *usize_ret) { struct parallel_chunk_compressor *ctx = (struct parallel_chunk_compressor *)_ctx; struct message *msg; @@ -417,7 +417,6 @@ new_parallel_chunk_compressor(int out_ctype, u32 out_chunk_size, unsigned desired_num_threads; wimlib_assert(out_chunk_size > 0); - wimlib_assert(out_ctype != WIMLIB_COMPRESSION_TYPE_NONE); if (num_threads == 0) num_threads = get_default_num_threads(); diff --git a/src/compress_serial.c b/src/compress_serial.c index 0ae35483..20e069c0 100644 --- a/src/compress_serial.c +++ b/src/compress_serial.c @@ -38,8 +38,8 @@ struct serial_chunk_compressor { struct wimlib_compressor *compressor; u8 *udata; u8 *cdata; - unsigned ulen; - unsigned clen; + u32 ulen; + u32 clen; }; static void @@ -75,8 +75,8 @@ serial_chunk_compressor_submit_chunk(struct chunk_compressor *_ctx, static bool serial_chunk_compressor_get_chunk(struct chunk_compressor *_ctx, - const void **cdata_ret, unsigned *csize_ret, - unsigned *usize_ret) + const void **cdata_ret, u32 *csize_ret, + u32 *usize_ret) { struct serial_chunk_compressor *ctx = (struct serial_chunk_compressor*)_ctx; @@ -107,6 +107,8 @@ new_serial_chunk_compressor(int out_ctype, u32 out_chunk_size, struct serial_chunk_compressor *ctx; int ret; + wimlib_assert(out_chunk_size > 0); + ctx = CALLOC(1, sizeof(*ctx)); if (ctx == NULL) return WIMLIB_ERR_NOMEM; diff --git a/src/write.c b/src/write.c index 92b30da2..f397cbb2 100644 --- a/src/write.c +++ b/src/write.c @@ -896,8 +896,8 @@ submit_chunk_for_compression(struct write_streams_ctx *ctx, * compressed chunk. */ while (!ctx->compressor->submit_chunk(ctx->compressor, chunk, size)) { const void *cchunk; - unsigned csize; - unsigned usize; + u32 csize; + u32 usize; bool bret; int ret; @@ -1180,8 +1180,8 @@ static int finish_remaining_chunks(struct write_streams_ctx *ctx) { const void *cdata; - unsigned csize; - unsigned usize; + u32 csize; + u32 usize; int ret; if (ctx->compressor == NULL) -- 2.43.0