From b9d66eaaf5f2e5ce20c55781e072e28d5df44813 Mon Sep 17 00:00:00 2001 From: Evan Nemerson Date: Fri, 15 Jul 2016 20:26:47 -0700 Subject: [PATCH] Use Hedley for lots of platform-specific bits. --- .gitmodules | 3 + plugins/brieflz/squash-brieflz.c | 32 +++++----- plugins/brotli/squash-brotli.c | 28 ++++----- plugins/bsc/squash-bsc.c | 36 +++++------ plugins/bzip2/squash-bzip2.c | 6 +- plugins/copy/squash-copy.c | 16 ++--- plugins/crush/squash-crush.c | 4 +- plugins/csc/squash-csc.cpp | 10 +-- plugins/density/squash-density.c | 14 ++--- plugins/doboz/squash-doboz.cpp | 10 +-- plugins/fari/squash-fari.c | 12 ++-- plugins/fastlz/squash-fastlz.c | 28 ++++----- plugins/gipfeli/squash-gipfeli.cpp | 28 ++++----- plugins/heatshrink/squash-heatshrink.c | 28 ++++----- plugins/libdeflate/squash-libdeflate.c | 14 ++--- plugins/lz4/squash-lz4.c | 38 ++++++------ plugins/lz4/squash-lz4f.c | 20 +++--- plugins/lzf/squash-lzf.c | 22 +++---- plugins/lzfse/squash-lzfse.c | 32 +++++----- plugins/lzg/squash-lzg.c | 36 +++++------ plugins/lzham/squash-lzham.c | 18 +++--- plugins/lzjb/squash-lzjb.c | 14 ++--- plugins/lzma/squash-lzma.c | 14 ++--- plugins/lzo/squash-lzo.c | 26 ++++---- plugins/miniz/squash-miniz.c | 22 +++---- plugins/ms-compress/squash-ms-compress.c | 24 ++++---- plugins/ncompress/squash-ncompress.c | 12 ++-- plugins/quicklz/squash-quicklz.c | 30 ++++----- plugins/snappy/squash-snappy.c | 10 +-- plugins/wflz/squash-wflz.c | 34 +++++------ plugins/yalz77/squash-yalz77.cpp | 12 ++-- plugins/zlib-ng/squash-zlib-ng.c | 22 +++---- plugins/zlib/squash-zlib.c | 22 +++---- plugins/zling/squash-zling.cpp | 6 +- plugins/zpaq/squash-zpaq.cpp | 2 +- plugins/zstd/squash-zstd.c | 12 ++-- squash/CMakeLists.txt | 3 + squash/hedley | 1 + squash/squash-buffer-internal.h | 20 +++--- squash/squash-buffer-stream-internal.h | 10 +-- squash/squash-buffer-stream.c | 22 +++---- squash/squash-buffer.c | 10 +-- squash/squash-charset-internal.h | 18 +++--- squash/squash-codec-internal.h | 18 +++--- squash/squash-codec.c | 68 ++++++++++----------- squash/squash-codec.h | 78 ++++++++++++------------ squash/squash-context-internal.h | 6 +- squash/squash-context.c | 4 +- squash/squash-context.h | 24 ++++---- squash/squash-file.c | 48 +++++++-------- squash/squash-file.h | 60 +++++++++--------- squash/squash-ini-internal.h | 2 +- squash/squash-license.h | 4 +- squash/squash-mapped-file-internal.h | 10 +-- squash/squash-mapped-file.c | 6 +- squash/squash-memory-internal.h | 4 +- squash/squash-memory.c | 4 +- squash/squash-memory.h | 4 +- squash/squash-mtx-internal.h | 4 +- squash/squash-object.c | 2 +- squash/squash-object.h | 8 +-- squash/squash-options.c | 72 +++++++++++----------- squash/squash-options.h | 68 ++++++++++----------- squash/squash-plugin-internal.h | 14 ++--- squash/squash-plugin.c | 8 +-- squash/squash-plugin.h | 14 ++--- squash/squash-slist-internal.h | 4 +- squash/squash-splice.c | 36 +++++------ squash/squash-splice.h | 16 ++--- squash/squash-status.h | 4 +- squash/squash-stream-internal.h | 4 +- squash/squash-stream.c | 14 ++--- squash/squash-stream.h | 24 ++++---- squash/squash-types-internal.h | 4 +- squash/squash-types.h | 4 +- squash/squash-util-internal.h | 4 +- squash/squash-util.c | 6 +- squash/squash-version.c | 35 ----------- squash/squash-version.h.in | 13 ++-- squash/squash.h | 66 ++------------------ tests/buffer.c | 2 +- tests/stream.c | 8 +-- tests/threads.c | 2 +- utils/squash.c | 6 +- 84 files changed, 736 insertions(+), 827 deletions(-) create mode 160000 squash/hedley diff --git a/.gitmodules b/.gitmodules index 7425368..9fc6c5e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -101,3 +101,6 @@ [submodule "plugins/lzfse/lzfse"] path = plugins/lzfse/lzfse url = https://github.com/lzfse/lzfse.git +[submodule "squash/hedley"] + path = squash/hedley + url = https://github.com/nemequ/hedley.git diff --git a/plugins/brieflz/squash-brieflz.c b/plugins/brieflz/squash-brieflz.c index 6ae638b..ec9fbc2 100644 --- a/plugins/brieflz/squash-brieflz.c +++ b/plugins/brieflz/squash-brieflz.c @@ -42,14 +42,14 @@ SquashStatus squash_plugin_init_codec (SquashCodec* codec, SquashCodecImpl* impl static size_t squash_brieflz_get_max_compressed_size (SquashCodec* codec, size_t uncompressed_size) { #if ULONG_MAX < SIZE_MAX - if (SQUASH_UNLIKELY(ULONG_MAX < uncompressed_size)) + if (HEDLEY_UNLIKELY(ULONG_MAX < uncompressed_size)) return (squash_error (SQUASH_RANGE), 0); #endif const unsigned long r = blz_max_packed_size ((unsigned long) uncompressed_size); #if SIZE_MAX < ULONG_MAX - if (SQUASH_UNLIKELY(SIZE_MAX < r)) + if (HEDLEY_UNLIKELY(SIZE_MAX < r)) return (squash_error (SQUASH_RANGE), 0); #endif @@ -59,27 +59,27 @@ squash_brieflz_get_max_compressed_size (SquashCodec* codec, size_t uncompressed_ static SquashStatus squash_brieflz_decompress_buffer (SquashCodec* codec, size_t* decompressed_size, - uint8_t decompressed[SQUASH_ARRAY_PARAM(*decompressed_size)], + uint8_t decompressed[HEDLEY_ARRAY_PARAM(*decompressed_size)], size_t compressed_size, - const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_size)], + const uint8_t compressed[HEDLEY_ARRAY_PARAM(compressed_size)], SquashOptions* options) { const uint8_t *src = compressed; unsigned long size; #if ULONG_MAX < SIZE_MAX - if (SQUASH_UNLIKELY(ULONG_MAX < compressed_size) || - SQUASH_UNLIKELY(ULONG_MAX < *decompressed_size)) + if (HEDLEY_UNLIKELY(ULONG_MAX < compressed_size) || + HEDLEY_UNLIKELY(ULONG_MAX < *decompressed_size)) return squash_error (SQUASH_RANGE); #endif size = blz_depack_safe (src, (unsigned long) compressed_size, decompressed, (unsigned long) *decompressed_size); - if (SQUASH_UNLIKELY(size != *decompressed_size)) + if (HEDLEY_UNLIKELY(size != *decompressed_size)) return squash_error (SQUASH_FAILED); #if SIZE_MAX < ULONG_MAX - if (SQUASH_UNLIKELY(SIZE_MAX < size)) + if (HEDLEY_UNLIKELY(SIZE_MAX < size)) return squash_error (SQUASH_RANGE); #endif @@ -91,28 +91,28 @@ squash_brieflz_decompress_buffer (SquashCodec* codec, static SquashStatus squash_brieflz_compress_buffer (SquashCodec* codec, size_t* compressed_size, - uint8_t compressed[SQUASH_ARRAY_PARAM(*compressed_size)], + uint8_t compressed[HEDLEY_ARRAY_PARAM(*compressed_size)], size_t uncompressed_size, - const uint8_t uncompressed[SQUASH_ARRAY_PARAM(uncompressed_size)], + const uint8_t uncompressed[HEDLEY_ARRAY_PARAM(uncompressed_size)], SquashOptions* options) { uint8_t *dst = compressed; void *workmem = NULL; unsigned long size; #if ULONG_MAX < SIZE_MAX - if (SQUASH_UNLIKELY(ULONG_MAX < uncompressed_size) || - SQUASH_UNLIKELY(ULONG_MAX < *compressed_size)) + if (HEDLEY_UNLIKELY(ULONG_MAX < uncompressed_size) || + HEDLEY_UNLIKELY(ULONG_MAX < *compressed_size)) return squash_error (SQUASH_RANGE); #endif - if (SQUASH_UNLIKELY((unsigned long) *compressed_size + if (HEDLEY_UNLIKELY((unsigned long) *compressed_size < squash_brieflz_get_max_compressed_size (codec, uncompressed_size))) { return squash_error (SQUASH_BUFFER_FULL); } workmem = squash_malloc (blz_workmem_size ((unsigned long) uncompressed_size)); - if (SQUASH_UNLIKELY(workmem == NULL)) { + if (HEDLEY_UNLIKELY(workmem == NULL)) { return squash_error (SQUASH_MEMORY); } @@ -123,7 +123,7 @@ squash_brieflz_compress_buffer (SquashCodec* codec, squash_free (workmem); #if SIZE_MAX < ULONG_MAX - if (SQUASH_UNLIKELY(SIZE_MAX < size)) + if (HEDLEY_UNLIKELY(SIZE_MAX < size)) return squash_error (SQUASH_RANGE); #endif @@ -136,7 +136,7 @@ SquashStatus squash_plugin_init_codec (SquashCodec* codec, SquashCodecImpl* impl) { const char* name = squash_codec_get_name (codec); - if (SQUASH_LIKELY(strcmp ("brieflz", name) == 0)) { + if (HEDLEY_LIKELY(strcmp ("brieflz", name) == 0)) { impl->info = SQUASH_CODEC_INFO_WRAP_SIZE; /* impl->get_uncompressed_size = squash_brieflz_get_uncompressed_size; */ impl->get_max_compressed_size = squash_brieflz_get_max_compressed_size; diff --git a/plugins/brotli/squash-brotli.c b/plugins/brotli/squash-brotli.c index 9083d3f..250b608 100644 --- a/plugins/brotli/squash-brotli.c +++ b/plugins/brotli/squash-brotli.c @@ -137,7 +137,7 @@ squash_brotli_stream_init (SquashBrotliStream* s, } else if (stream_type == SQUASH_STREAM_DECOMPRESS) { s->ctx.decoder = BrotliCreateState(squash_brotli_malloc, squash_brotli_free, NULL); } else { - squash_assert_unreachable(); + HEDLEY_UNREACHABLE(); } } @@ -150,7 +150,7 @@ squash_brotli_stream_destroy (void* stream) { } else if (((SquashStream*) stream)->stream_type == SQUASH_STREAM_DECOMPRESS) { BrotliDestroyState(s->ctx.decoder); } else { - squash_assert_unreachable(); + HEDLEY_UNREACHABLE(); } squash_stream_destroy (stream); @@ -172,7 +172,7 @@ squash_brotli_encoder_operation_from_squash_operation (const SquashOperation ope return BROTLI_OPERATION_FINISH; case SQUASH_OPERATION_TERMINATE: default: - squash_assert_unreachable (); + HEDLEY_UNREACHABLE (); } } @@ -188,7 +188,7 @@ squash_brotli_process_stream (SquashStream* stream, SquashOperation operation) { &(stream->avail_out), &(stream->next_out), NULL); - if (SQUASH_UNLIKELY(be_ret != 1)) + if (HEDLEY_UNLIKELY(be_ret != 1)) return squash_error (SQUASH_FAILED); else if (stream->avail_in != 0 || BrotliEncoderHasMoreOutput(s->ctx.encoder)) return SQUASH_PROCESSING; @@ -212,13 +212,13 @@ squash_brotli_process_stream (SquashStream* stream, SquashOperation operation) { return SQUASH_FAILED; } - if (SQUASH_UNLIKELY(bd_ret != BROTLI_RESULT_SUCCESS)) + if (HEDLEY_UNLIKELY(bd_ret != BROTLI_RESULT_SUCCESS)) return squash_error (SQUASH_FAILED); } else { - squash_assert_unreachable (); + HEDLEY_UNREACHABLE (); } - squash_assert_unreachable (); + HEDLEY_UNREACHABLE (); } static size_t @@ -229,9 +229,9 @@ squash_brotli_get_max_compressed_size (SquashCodec* codec, size_t uncompressed_s static SquashStatus squash_brotli_compress_buffer (SquashCodec* codec, size_t* compressed_size, - uint8_t compressed[SQUASH_ARRAY_PARAM(*compressed_size)], + uint8_t compressed[HEDLEY_ARRAY_PARAM(*compressed_size)], size_t uncompressed_size, - const uint8_t uncompressed[SQUASH_ARRAY_PARAM(uncompressed_size)], + const uint8_t uncompressed[HEDLEY_ARRAY_PARAM(uncompressed_size)], SquashOptions* options) { const int quality = squash_options_get_int_at (options, codec, SQUASH_BROTLI_OPT_LEVEL); const int lgwin = squash_options_get_int_at (options, codec, SQUASH_BROTLI_OPT_WINDOW_SIZE); @@ -240,26 +240,26 @@ squash_brotli_compress_buffer (SquashCodec* codec, const int res = BrotliEncoderCompress (quality, lgwin, mode, uncompressed_size, uncompressed, compressed_size, compressed); - return SQUASH_LIKELY(res == 1) ? SQUASH_OK : squash_error (SQUASH_BUFFER_FULL); + return HEDLEY_LIKELY(res == 1) ? SQUASH_OK : squash_error (SQUASH_BUFFER_FULL); } static SquashStatus squash_brotli_decompress_buffer (SquashCodec* codec, size_t* decompressed_size, - uint8_t decompressed[SQUASH_ARRAY_PARAM(*decompressed_size)], + uint8_t decompressed[HEDLEY_ARRAY_PARAM(*decompressed_size)], size_t compressed_size, - const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_size)], + const uint8_t compressed[HEDLEY_ARRAY_PARAM(compressed_size)], SquashOptions* options) { const BrotliResult res = BrotliDecompressBuffer(compressed_size, compressed, decompressed_size, decompressed); - return SQUASH_LIKELY(res == BROTLI_RESULT_SUCCESS) ? SQUASH_OK : squash_error (SQUASH_BUFFER_FULL); + return HEDLEY_LIKELY(res == BROTLI_RESULT_SUCCESS) ? SQUASH_OK : squash_error (SQUASH_BUFFER_FULL); } SquashStatus squash_plugin_init_codec (SquashCodec* codec, SquashCodecImpl* impl) { const char* name = squash_codec_get_name (codec); - if (SQUASH_LIKELY(strcmp ("brotli", name) == 0)) { + if (HEDLEY_LIKELY(strcmp ("brotli", name) == 0)) { impl->info = SQUASH_CODEC_INFO_CAN_FLUSH; impl->options = squash_brotli_options; impl->get_max_compressed_size = squash_brotli_get_max_compressed_size; diff --git a/plugins/bsc/squash-bsc.c b/plugins/bsc/squash-bsc.c index 983031e..800c084 100644 --- a/plugins/bsc/squash-bsc.c +++ b/plugins/bsc/squash-bsc.c @@ -112,11 +112,11 @@ squash_bsc_get_max_compressed_size (SquashCodec* codec, size_t uncompressed_size static size_t squash_bsc_get_uncompressed_size (SquashCodec* codec, size_t compressed_size, - const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_size)]) { + const uint8_t compressed[HEDLEY_ARRAY_PARAM(compressed_size)]) { int p_block_size, p_data_size; #if INT_MAX < SIZE_MAX - if (SQUASH_UNLIKELY(INT_MAX < compressed_size)) + if (HEDLEY_UNLIKELY(INT_MAX < compressed_size)) return (squash_error (SQUASH_RANGE), 0); #endif @@ -126,7 +126,7 @@ squash_bsc_get_uncompressed_size (SquashCodec* codec, return 0; } else { #if SIZE_MAX < INT_MAX - if (SQUASH_UNLIKELY(SIZE_MAX < p_data_size)) + if (HEDLEY_UNLIKELY(SIZE_MAX < p_data_size)) return (squash_error (SQUASH_RANGE), 0); #endif return (size_t) p_data_size; @@ -146,9 +146,9 @@ squash_bsc_options_get_features (SquashCodec* codec, static SquashStatus squash_bsc_compress_buffer_unsafe (SquashCodec* codec, size_t* compressed_size, - uint8_t compressed[SQUASH_ARRAY_PARAM(*compressed_size)], + uint8_t compressed[HEDLEY_ARRAY_PARAM(*compressed_size)], size_t uncompressed_size, - const uint8_t uncompressed[SQUASH_ARRAY_PARAM(uncompressed_size)], + const uint8_t uncompressed[HEDLEY_ARRAY_PARAM(uncompressed_size)], SquashOptions* options) { const int lzp_hash_size = squash_options_get_int_at (options, codec, SQUASH_BSC_OPT_LZP_HASH_SIZE); const int lzp_min_len = squash_options_get_int_at (options, codec, SQUASH_BSC_OPT_LZP_MIN_LEN); @@ -157,22 +157,22 @@ squash_bsc_compress_buffer_unsafe (SquashCodec* codec, const int features = squash_bsc_options_get_features (codec, options); #if INT_MAX < SIZE_MAX - if (SQUASH_UNLIKELY(INT_MAX < uncompressed_size)) + if (HEDLEY_UNLIKELY(INT_MAX < uncompressed_size)) return squash_error (SQUASH_RANGE); #endif - if (SQUASH_UNLIKELY(*compressed_size < (uncompressed_size + LIBBSC_HEADER_SIZE))) + if (HEDLEY_UNLIKELY(*compressed_size < (uncompressed_size + LIBBSC_HEADER_SIZE))) return squash_error (SQUASH_BUFFER_FULL); const int res = bsc_compress (uncompressed, compressed, (int) uncompressed_size, lzp_hash_size, lzp_min_len, block_sorter, coder, features); - if (SQUASH_UNLIKELY(res < 0)) { + if (HEDLEY_UNLIKELY(res < 0)) { return squash_error (SQUASH_FAILED); } #if SIZE_MAX < INT_MAX - if (SQUASH_UNLIKELY(SIZE_MAX < res)) + if (HEDLEY_UNLIKELY(SIZE_MAX < res)) return squash_error (SQUASH_RANGE); #endif @@ -184,13 +184,13 @@ squash_bsc_compress_buffer_unsafe (SquashCodec* codec, static SquashStatus squash_bsc_decompress_buffer (SquashCodec* codec, size_t* decompressed_size, - uint8_t decompressed[SQUASH_ARRAY_PARAM(*decompressed_size)], + uint8_t decompressed[HEDLEY_ARRAY_PARAM(*decompressed_size)], size_t compressed_size, - const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_size)], + const uint8_t compressed[HEDLEY_ARRAY_PARAM(compressed_size)], SquashOptions* options) { #if INT_MAX < SIZE_MAX - if (SQUASH_UNLIKELY(INT_MAX < compressed_size) || - SQUASH_UNLIKELY(INT_MAX < *decompressed_size)) + if (HEDLEY_UNLIKELY(INT_MAX < compressed_size) || + HEDLEY_UNLIKELY(INT_MAX < *decompressed_size)) return squash_error (SQUASH_RANGE); #endif @@ -200,18 +200,18 @@ squash_bsc_decompress_buffer (SquashCodec* codec, int res = bsc_block_info (compressed, (int) compressed_size, &p_block_size, &p_data_size, LIBBSC_DEFAULT_FEATURES); - if (SQUASH_UNLIKELY(p_block_size != (int) compressed_size)) + if (HEDLEY_UNLIKELY(p_block_size != (int) compressed_size)) return squash_error (SQUASH_FAILED); - if (SQUASH_UNLIKELY(p_data_size > (int) *decompressed_size)) + if (HEDLEY_UNLIKELY(p_data_size > (int) *decompressed_size)) return squash_error (SQUASH_BUFFER_FULL); res = bsc_decompress (compressed, p_block_size, decompressed, p_data_size, features); - if (SQUASH_UNLIKELY(res < 0)) + if (HEDLEY_UNLIKELY(res < 0)) return squash_error (SQUASH_FAILED); #if SIZE_MAX < INT_MAX - if (SQUASH_UNLIKELY(SIZE_MAX < p_data_size)) + if (HEDLEY_UNLIKELY(SIZE_MAX < p_data_size)) return squash_error (SQUASH_RANGE); #endif @@ -226,7 +226,7 @@ squash_plugin_init_codec (SquashCodec* codec, SquashCodecImpl* impl) { const char* name = squash_codec_get_name (codec); - if (SQUASH_LIKELY(strcmp ("bsc", name) == 0)) { + if (HEDLEY_LIKELY(strcmp ("bsc", name) == 0)) { impl->options = squash_bsc_options; impl->get_uncompressed_size = squash_bsc_get_uncompressed_size; impl->get_max_compressed_size = squash_bsc_get_max_compressed_size; diff --git a/plugins/bzip2/squash-bzip2.c b/plugins/bzip2/squash-bzip2.c index d33ff34..a9d5944 100644 --- a/plugins/bzip2/squash-bzip2.c +++ b/plugins/bzip2/squash-bzip2.c @@ -105,7 +105,7 @@ squash_bz2_stream_new (SquashCodec* codec, SquashStreamType stream_type, SquashO 0, squash_options_get_bool_at (options, codec, SQUASH_BZ2_OPT_SMALL)); } else { - squash_assert_unreachable(); + HEDLEY_UNREACHABLE(); } if (bz2_e != BZ_OK) { @@ -266,11 +266,11 @@ squash_bz2_process_stream (SquashStream* stream, SquashOperation operation) { case SQUASH_OPERATION_FINISH: return squash_bz2_finish_stream (stream); case SQUASH_OPERATION_TERMINATE: - squash_assert_unreachable (); + HEDLEY_UNREACHABLE (); break; } - squash_assert_unreachable(); + HEDLEY_UNREACHABLE(); } static size_t diff --git a/plugins/copy/squash-copy.c b/plugins/copy/squash-copy.c index 60e7205..d4c1a2e 100644 --- a/plugins/copy/squash-copy.c +++ b/plugins/copy/squash-copy.c @@ -54,7 +54,7 @@ squash_copy_get_max_compressed_size (SquashCodec* codec, size_t uncompressed_siz static size_t squash_copy_get_uncompressed_size (SquashCodec* codec, size_t compressed_size, - const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_size)]) { + const uint8_t compressed[HEDLEY_ARRAY_PARAM(compressed_size)]) { return compressed_size; } @@ -108,11 +108,11 @@ squash_copy_process_stream (SquashStream* stream, SquashOperation operation) { static SquashStatus squash_copy_compress_buffer (SquashCodec* codec, size_t* compressed_size, - uint8_t compressed[SQUASH_ARRAY_PARAM(*compressed_size)], + uint8_t compressed[HEDLEY_ARRAY_PARAM(*compressed_size)], size_t uncompressed_size, - const uint8_t uncompressed[SQUASH_ARRAY_PARAM(uncompressed_size)], + const uint8_t uncompressed[HEDLEY_ARRAY_PARAM(uncompressed_size)], SquashOptions* options) { - if (SQUASH_UNLIKELY(*compressed_size < uncompressed_size)) + if (HEDLEY_UNLIKELY(*compressed_size < uncompressed_size)) return squash_error (SQUASH_BUFFER_FULL); memcpy (compressed, uncompressed, uncompressed_size); @@ -124,11 +124,11 @@ squash_copy_compress_buffer (SquashCodec* codec, static SquashStatus squash_copy_decompress_buffer (SquashCodec* codec, size_t* decompressed_size, - uint8_t decompressed[SQUASH_ARRAY_PARAM(*decompressed_size)], + uint8_t decompressed[HEDLEY_ARRAY_PARAM(*decompressed_size)], size_t compressed_size, - const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_size)], + const uint8_t compressed[HEDLEY_ARRAY_PARAM(compressed_size)], SquashOptions* options) { - if (SQUASH_UNLIKELY(*decompressed_size < compressed_size)) + if (HEDLEY_UNLIKELY(*decompressed_size < compressed_size)) return squash_error (SQUASH_BUFFER_FULL); memcpy (decompressed, compressed, compressed_size); @@ -141,7 +141,7 @@ SquashStatus squash_plugin_init_codec (SquashCodec* codec, SquashCodecImpl* impl) { const char* name = squash_codec_get_name (codec); - if (SQUASH_LIKELY(strcmp ("copy", name) == 0)) { + if (HEDLEY_LIKELY(strcmp ("copy", name) == 0)) { impl->info = SQUASH_CODEC_INFO_CAN_FLUSH; impl->get_uncompressed_size = squash_copy_get_uncompressed_size; impl->get_max_compressed_size = squash_copy_get_max_compressed_size; diff --git a/plugins/crush/squash-crush.c b/plugins/crush/squash-crush.c index 209a15d..347648e 100644 --- a/plugins/crush/squash-crush.c +++ b/plugins/crush/squash-crush.c @@ -129,7 +129,7 @@ squash_crush_splice (SquashCodec* codec, if (data.last_res < 0) return data.last_res; - else if (SQUASH_UNLIKELY(res != 0)) + else if (HEDLEY_UNLIKELY(res != 0)) return squash_error (SQUASH_FAILED); else return SQUASH_OK; @@ -145,7 +145,7 @@ SquashStatus squash_plugin_init_codec (SquashCodec* codec, SquashCodecImpl* impl) { const char* name = squash_codec_get_name (codec); - if (SQUASH_LIKELY(strcmp ("crush", name) == 0)) { + if (HEDLEY_LIKELY(strcmp ("crush", name) == 0)) { impl->options = squash_crush_options; impl->splice = squash_crush_splice; impl->get_max_compressed_size = squash_crush_get_max_compressed_size; diff --git a/plugins/csc/squash-csc.cpp b/plugins/csc/squash-csc.cpp index 56143ac..942f028 100644 --- a/plugins/csc/squash-csc.cpp +++ b/plugins/csc/squash-csc.cpp @@ -144,16 +144,16 @@ squash_csc_splice (SquashCodec* codec, CSCEnc_WriteProperties (&props, props_buf, 0); size_t bytes_written = squash_csc_writer ((void*) &out_stream, props_buf, CSC_PROP_SIZE); - if (SQUASH_UNLIKELY(bytes_written != CSC_PROP_SIZE)) + if (HEDLEY_UNLIKELY(bytes_written != CSC_PROP_SIZE)) return squash_error (SQUASH_FAILED); CSCEncHandle comp = CSCEnc_Create (&props, (ISeqOutStream*) &out_stream, (ISzAlloc*) &squash_csc_allocator); csc_res = CSCEnc_Encode (comp, (ISeqInStream*) &in_stream, NULL); - if (SQUASH_UNLIKELY(csc_res != 0)) { + if (HEDLEY_UNLIKELY(csc_res != 0)) { res = squash_error (SQUASH_FAILED); } else { csc_res = CSCEnc_Encode_Flush (comp); - if (SQUASH_UNLIKELY(csc_res != 0)) { + if (HEDLEY_UNLIKELY(csc_res != 0)) { res = squash_error (SQUASH_FAILED); } } @@ -161,7 +161,7 @@ squash_csc_splice (SquashCodec* codec, } else { size_t prop_l = CSC_PROP_SIZE; squash_csc_reader ((void*) &in_stream, props_buf, &prop_l); - if (SQUASH_UNLIKELY(prop_l != CSC_PROP_SIZE)) + if (HEDLEY_UNLIKELY(prop_l != CSC_PROP_SIZE)) return squash_error (SQUASH_FAILED); CSCDec_ReadProperties (&props, props_buf); @@ -204,7 +204,7 @@ extern "C" SquashStatus squash_plugin_init_codec (SquashCodec* codec, SquashCodecImpl* impl) { const char* name = squash_codec_get_name (codec); - if (SQUASH_LIKELY(strcmp ("csc", name) == 0)) { + if (HEDLEY_LIKELY(strcmp ("csc", name) == 0)) { impl->options = squash_csc_options; impl->splice = squash_csc_splice; impl->get_max_compressed_size = squash_csc_get_max_compressed_size; diff --git a/plugins/density/squash-density.c b/plugins/density/squash-density.c index 5d1f238..493f311 100644 --- a/plugins/density/squash-density.c +++ b/plugins/density/squash-density.c @@ -170,7 +170,7 @@ squash_density_level_to_mode (int level) { case 9: return DENSITY_COMPRESSION_MODE_LION_ALGORITHM; default: - squash_assert_unreachable (); + HEDLEY_UNREACHABLE (); } } @@ -195,7 +195,7 @@ squash_density_flush_internal_buffer (SquashStream* stream) { } } - squash_assert_unreachable(); + HEDLEY_UNREACHABLE(); } static size_t total_bytes_written = 0; @@ -220,7 +220,7 @@ squash_density_process_stream (SquashStream* stream, SquashOperation operation) s->buffer_active = false; s->state = density_stream_prepare (s->stream, (uint8_t*) stream->next_in, s->active_input_size, stream->next_out, stream->avail_out); } - if (SQUASH_UNLIKELY(s->state != DENSITY_STREAM_STATE_READY)) { + if (HEDLEY_UNLIKELY(s->state != DENSITY_STREAM_STATE_READY)) { res = squash_error (SQUASH_FAILED); goto finish; } @@ -325,7 +325,7 @@ squash_density_process_stream (SquashStream* stream, SquashOperation operation) } else { s->state = density_stream_decompress_init (s->stream, NULL); } - if (SQUASH_UNLIKELY(s->state != DENSITY_STREAM_STATE_READY)) { + if (HEDLEY_UNLIKELY(s->state != DENSITY_STREAM_STATE_READY)) { res = squash_error (SQUASH_FAILED); goto finish; } @@ -359,7 +359,7 @@ squash_density_process_stream (SquashStream* stream, SquashOperation operation) break; case SQUASH_DENSITY_ACTION_FINISHED: default: - squash_assert_unreachable(); + HEDLEY_UNREACHABLE(); break; } } @@ -404,7 +404,7 @@ squash_density_process_stream (SquashStream* stream, SquashOperation operation) res = SQUASH_PROCESSING; goto finish; } else { - squash_assert_unreachable(); + HEDLEY_UNREACHABLE(); } } } @@ -422,7 +422,7 @@ SquashStatus squash_plugin_init_codec (SquashCodec* codec, SquashCodecImpl* impl) { const char* name = squash_codec_get_name (codec); - if (SQUASH_LIKELY(strcmp ("density", name) == 0)) { + if (HEDLEY_LIKELY(strcmp ("density", name) == 0)) { impl->info = SQUASH_CODEC_INFO_DECOMPRESS_UNSAFE; impl->options = squash_density_options; impl->create_stream = squash_density_create_stream; diff --git a/plugins/doboz/squash-doboz.cpp b/plugins/doboz/squash-doboz.cpp index 2c8d8ff..e503bce 100644 --- a/plugins/doboz/squash-doboz.cpp +++ b/plugins/doboz/squash-doboz.cpp @@ -45,7 +45,7 @@ squash_doboz_get_max_compressed_size (SquashCodec* codec, size_t uncompressed_si static size_t squash_doboz_get_uncompressed_size (SquashCodec* codec, size_t compressed_size, - const uint8_t compressed[SQUASH_ARRAY_PARAM(*compressed_size)]) { + const uint8_t compressed[HEDLEY_ARRAY_PARAM(*compressed_size)]) { doboz::Decompressor decompressor; doboz::CompressionInfo compression_info; doboz::Result e; @@ -80,9 +80,9 @@ squash_doboz_status (doboz::Result status) { static SquashStatus squash_doboz_compress_buffer (SquashCodec* codec, size_t* compressed_size, - uint8_t compressed[SQUASH_ARRAY_PARAM(*compressed_size)], + uint8_t compressed[HEDLEY_ARRAY_PARAM(*compressed_size)], size_t uncompressed_size, - const uint8_t uncompressed[SQUASH_ARRAY_PARAM(uncompressed_size)], + const uint8_t uncompressed[HEDLEY_ARRAY_PARAM(uncompressed_size)], SquashOptions* options) { doboz::Result doboz_e; doboz::Compressor compressor; @@ -107,9 +107,9 @@ squash_doboz_compress_buffer (SquashCodec* codec, static SquashStatus squash_doboz_decompress_buffer (SquashCodec* codec, size_t* decompressed_size, - uint8_t decompressed[SQUASH_ARRAY_PARAM(*decompressed_size)], + uint8_t decompressed[HEDLEY_ARRAY_PARAM(*decompressed_size)], size_t compressed_size, - const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_size)], + const uint8_t compressed[HEDLEY_ARRAY_PARAM(compressed_size)], SquashOptions* options) { doboz::Result doboz_e; doboz::Decompressor decompressor; diff --git a/plugins/fari/squash-fari.c b/plugins/fari/squash-fari.c index cef4d3e..1237255 100644 --- a/plugins/fari/squash-fari.c +++ b/plugins/fari/squash-fari.c @@ -44,9 +44,9 @@ squash_fari_get_max_compressed_size (SquashCodec* codec, size_t uncompressed_siz static SquashStatus squash_fari_decompress_buffer (SquashCodec* codec, size_t* decompressed_size, - uint8_t decompressed[SQUASH_ARRAY_PARAM(*decompressed_size)], + uint8_t decompressed[HEDLEY_ARRAY_PARAM(*decompressed_size)], size_t compressed_size, - const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_size)], + const uint8_t compressed[HEDLEY_ARRAY_PARAM(compressed_size)], SquashOptions* options) { void* workmem = squash_malloc (FA_WORKMEM); int fari_e = (size_t) fa_decompress ((const unsigned char*) compressed, (unsigned char*) decompressed, @@ -72,23 +72,23 @@ squash_fari_decompress_buffer (SquashCodec* codec, static SquashStatus squash_fari_compress_buffer (SquashCodec* codec, size_t* compressed_size, - uint8_t compressed[SQUASH_ARRAY_PARAM(*compressed_size)], + uint8_t compressed[HEDLEY_ARRAY_PARAM(*compressed_size)], size_t uncompressed_size, - const uint8_t uncompressed[SQUASH_ARRAY_PARAM(uncompressed_size)], + const uint8_t uncompressed[HEDLEY_ARRAY_PARAM(uncompressed_size)], SquashOptions* options) { void* workmem = squash_malloc (FA_WORKMEM); int fari_e = fa_compress ((const unsigned char*) uncompressed, (unsigned char*) compressed, uncompressed_size, compressed_size, workmem); squash_free (workmem); - return SQUASH_LIKELY(fari_e == 0) ? SQUASH_OK : SQUASH_FAILED; + return HEDLEY_LIKELY(fari_e == 0) ? SQUASH_OK : SQUASH_FAILED; } SquashStatus squash_plugin_init_codec (SquashCodec* codec, SquashCodecImpl* impl) { const char* name = squash_codec_get_name (codec); - if (SQUASH_LIKELY(strcmp ("fari", name) == 0)) { + if (HEDLEY_LIKELY(strcmp ("fari", name) == 0)) { impl->get_max_compressed_size = squash_fari_get_max_compressed_size; impl->decompress_buffer = squash_fari_decompress_buffer; impl->compress_buffer_unsafe = squash_fari_compress_buffer; diff --git a/plugins/fastlz/squash-fastlz.c b/plugins/fastlz/squash-fastlz.c index ffabc58..a8c6269 100644 --- a/plugins/fastlz/squash-fastlz.c +++ b/plugins/fastlz/squash-fastlz.c @@ -61,13 +61,13 @@ squash_fastlz_get_max_compressed_size (SquashCodec* codec, size_t uncompressed_s static SquashStatus squash_fastlz_decompress_buffer (SquashCodec* codec, size_t* decompressed_size, - uint8_t decompressed[SQUASH_ARRAY_PARAM(*decompressed_size)], + uint8_t decompressed[HEDLEY_ARRAY_PARAM(*decompressed_size)], size_t compressed_size, - const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_size)], + const uint8_t compressed[HEDLEY_ARRAY_PARAM(compressed_size)], SquashOptions* options) { #if INT_MAX < SIZE_MAX - if (SQUASH_UNLIKELY(INT_MAX < compressed_size) || - SQUASH_UNLIKELY(INT_MAX < *decompressed_size)) + if (HEDLEY_UNLIKELY(INT_MAX < compressed_size) || + HEDLEY_UNLIKELY(INT_MAX < *decompressed_size)) return squash_error (SQUASH_RANGE); #endif @@ -76,13 +76,13 @@ squash_fastlz_decompress_buffer (SquashCodec* codec, (void*) decompressed, (int) *decompressed_size); - if (SQUASH_UNLIKELY(fastlz_e < 0)) { + if (HEDLEY_UNLIKELY(fastlz_e < 0)) { return squash_error (SQUASH_FAILED); - } else if (SQUASH_UNLIKELY(fastlz_e == 0)) { + } else if (HEDLEY_UNLIKELY(fastlz_e == 0)) { return SQUASH_BUFFER_FULL; } else { #if SIZE_MAX < INT_MAX - if (SQUASH_UNLIKELY(SIZE_MAX < fastlz_e)) + if (HEDLEY_UNLIKELY(SIZE_MAX < fastlz_e)) return squash_error (SQUASH_RANGE); #endif *decompressed_size = (size_t) fastlz_e; @@ -93,13 +93,13 @@ squash_fastlz_decompress_buffer (SquashCodec* codec, static SquashStatus squash_fastlz_compress_buffer (SquashCodec* codec, size_t* compressed_size, - uint8_t compressed[SQUASH_ARRAY_PARAM(*compressed_size)], + uint8_t compressed[HEDLEY_ARRAY_PARAM(*compressed_size)], size_t uncompressed_size, - const uint8_t uncompressed[SQUASH_ARRAY_PARAM(uncompressed_size)], + const uint8_t uncompressed[HEDLEY_ARRAY_PARAM(uncompressed_size)], SquashOptions* options) { #if INT_MAX < SIZE_MAX - if (SQUASH_UNLIKELY(INT_MAX < uncompressed_size) || - SQUASH_UNLIKELY(INT_MAX < *compressed_size)) + if (HEDLEY_UNLIKELY(INT_MAX < uncompressed_size) || + HEDLEY_UNLIKELY(INT_MAX < *compressed_size)) return squash_error (SQUASH_RANGE); #endif @@ -110,20 +110,20 @@ squash_fastlz_compress_buffer (SquashCodec* codec, (void*) compressed); #if SIZE_MAX < INT_MAX - if (SQUASH_UNLIKELY(SIZE_MAX < fastlz_e)) + if (HEDLEY_UNLIKELY(SIZE_MAX < fastlz_e)) return squash_error (SQUASH_RANGE); #endif *compressed_size = (size_t) fastlz_e; - return SQUASH_UNLIKELY(fastlz_e == 0) ? squash_error (SQUASH_FAILED) : SQUASH_OK; + return HEDLEY_UNLIKELY(fastlz_e == 0) ? squash_error (SQUASH_FAILED) : SQUASH_OK; } SquashStatus squash_plugin_init_codec (SquashCodec* codec, SquashCodecImpl* impl) { const char* name = squash_codec_get_name (codec); - if (SQUASH_LIKELY(strcmp ("fastlz", name) == 0)) { + if (HEDLEY_LIKELY(strcmp ("fastlz", name) == 0)) { impl->options = squash_fastlz_options; impl->get_max_compressed_size = squash_fastlz_get_max_compressed_size; impl->decompress_buffer = squash_fastlz_decompress_buffer; diff --git a/plugins/gipfeli/squash-gipfeli.cpp b/plugins/gipfeli/squash-gipfeli.cpp index 01f8740..2627a97 100644 --- a/plugins/gipfeli/squash-gipfeli.cpp +++ b/plugins/gipfeli/squash-gipfeli.cpp @@ -52,7 +52,7 @@ squash_gipfeli_get_max_compressed_size (SquashCodec* codec, size_t uncompressed_ static size_t squash_gipfeli_get_uncompressed_size (SquashCodec* codec, size_t compressed_size, - const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_size)]) { + const uint8_t compressed[HEDLEY_ARRAY_PARAM(compressed_size)]) { util::compression::Compressor* compressor = util::compression::NewGipfeliCompressor(); std::string compressed_str((const char*) compressed, compressed_size); @@ -96,9 +96,9 @@ class CheckedByteArraySink : public util::compression::Sink { static SquashStatus squash_gipfeli_decompress_buffer (SquashCodec* codec, size_t* decompressed_size, - uint8_t decompressed[SQUASH_ARRAY_PARAM(*decompressed_size)], + uint8_t decompressed[HEDLEY_ARRAY_PARAM(*decompressed_size)], size_t compressed_size, - const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_size)], + const uint8_t compressed[HEDLEY_ARRAY_PARAM(compressed_size)], SquashOptions* options) { util::compression::Compressor* compressor = util::compression::NewGipfeliCompressor(); @@ -106,24 +106,24 @@ squash_gipfeli_decompress_buffer (SquashCodec* codec, util::compression::ByteArraySource source((const char*) compressed, compressed_size); SquashStatus res = SQUASH_OK; - if (SQUASH_UNLIKELY(compressor == NULL)) + if (HEDLEY_UNLIKELY(compressor == NULL)) return squash_error (SQUASH_MEMORY); std::string compressed_str((const char*) compressed, compressed_size); size_t uncompressed_size; - if (SQUASH_UNLIKELY(!compressor->GetUncompressedLength (compressed_str, &uncompressed_size))) { + if (HEDLEY_UNLIKELY(!compressor->GetUncompressedLength (compressed_str, &uncompressed_size))) { res = squash_error (SQUASH_FAILED); goto cleanup; } - if (SQUASH_UNLIKELY(uncompressed_size > *decompressed_size)) { + if (HEDLEY_UNLIKELY(uncompressed_size > *decompressed_size)) { res = squash_error (SQUASH_BUFFER_FULL); goto cleanup; } else { *decompressed_size = uncompressed_size; } - if (SQUASH_UNLIKELY(!compressor->UncompressStream (&source, &sink))) { + if (HEDLEY_UNLIKELY(!compressor->UncompressStream (&source, &sink))) { res = squash_error (SQUASH_FAILED); } @@ -137,9 +137,9 @@ squash_gipfeli_decompress_buffer (SquashCodec* codec, static SquashStatus squash_gipfeli_compress_buffer (SquashCodec* codec, size_t* compressed_size, - uint8_t compressed[SQUASH_ARRAY_PARAM(*compressed_size)], + uint8_t compressed[HEDLEY_ARRAY_PARAM(*compressed_size)], size_t uncompressed_size, - const uint8_t uncompressed[SQUASH_ARRAY_PARAM(uncompressed_size)], + const uint8_t uncompressed[HEDLEY_ARRAY_PARAM(uncompressed_size)], SquashOptions* options) { util::compression::Compressor* compressor = util::compression::NewGipfeliCompressor(); CheckedByteArraySink sink((char*) compressed, *compressed_size); @@ -159,7 +159,7 @@ squash_gipfeli_compress_buffer (SquashCodec* codec, delete compressor; - if (SQUASH_UNLIKELY(res == SQUASH_OK && *compressed_size == 0)) + if (HEDLEY_UNLIKELY(res == SQUASH_OK && *compressed_size == 0)) res = squash_error (SQUASH_FAILED); return res; @@ -168,9 +168,9 @@ squash_gipfeli_compress_buffer (SquashCodec* codec, static SquashStatus squash_gipfeli_compress_buffer_unsafe (SquashCodec* codec, size_t* compressed_size, - uint8_t compressed[SQUASH_ARRAY_PARAM(*compressed_size)], + uint8_t compressed[HEDLEY_ARRAY_PARAM(*compressed_size)], size_t uncompressed_size, - const uint8_t uncompressed[SQUASH_ARRAY_PARAM(uncompressed_size)], + const uint8_t uncompressed[HEDLEY_ARRAY_PARAM(uncompressed_size)], SquashOptions* options) { util::compression::Compressor* compressor = util::compression::NewGipfeliCompressor(); util::compression::UncheckedByteArraySink sink((char*) compressed); @@ -190,7 +190,7 @@ squash_gipfeli_compress_buffer_unsafe (SquashCodec* codec, delete compressor; - if (SQUASH_UNLIKELY(res == SQUASH_OK && *compressed_size == 0)) + if (HEDLEY_UNLIKELY(res == SQUASH_OK && *compressed_size == 0)) res = squash_error (SQUASH_FAILED); return res; @@ -200,7 +200,7 @@ extern "C" SquashStatus squash_plugin_init_codec (SquashCodec* codec, SquashCodecImpl* impl) { const char* name = squash_codec_get_name (codec); - if (SQUASH_LIKELY(strcmp ("gipfeli", name) == 0)) { + if (HEDLEY_LIKELY(strcmp ("gipfeli", name) == 0)) { impl->get_uncompressed_size = squash_gipfeli_get_uncompressed_size; impl->get_max_compressed_size = squash_gipfeli_get_max_compressed_size; impl->decompress_buffer = squash_gipfeli_decompress_buffer; diff --git a/plugins/heatshrink/squash-heatshrink.c b/plugins/heatshrink/squash-heatshrink.c index becb97e..76e46d2 100644 --- a/plugins/heatshrink/squash-heatshrink.c +++ b/plugins/heatshrink/squash-heatshrink.c @@ -82,7 +82,7 @@ squash_heatshrink_stream_new (SquashCodec* codec, SquashStreamType stream_type, assert (stream_type == SQUASH_STREAM_COMPRESS || stream_type == SQUASH_STREAM_DECOMPRESS); stream = squash_malloc (sizeof (SquashHeatshrinkStream)); - if (SQUASH_UNLIKELY(stream == NULL)) + if (HEDLEY_UNLIKELY(stream == NULL)) return (squash_error (SQUASH_MEMORY), NULL); squash_heatshrink_stream_init (stream, codec, stream_type, options, squash_heatshrink_stream_destroy); @@ -92,13 +92,13 @@ squash_heatshrink_stream_new (SquashCodec* codec, SquashStreamType stream_type, if (stream_type == SQUASH_STREAM_COMPRESS) { stream->ctx.comp = heatshrink_encoder_alloc (window_size, lookahead_size); - if (SQUASH_UNLIKELY(stream->ctx.comp == NULL)) { + if (HEDLEY_UNLIKELY(stream->ctx.comp == NULL)) { squash_object_unref (stream); return (squash_error (SQUASH_MEMORY), NULL); } } else { stream->ctx.decomp = heatshrink_decoder_alloc (256, window_size, lookahead_size); - if (SQUASH_UNLIKELY(stream->ctx.decomp == NULL)) { + if (HEDLEY_UNLIKELY(stream->ctx.decomp == NULL)) { squash_object_unref (stream); return (squash_error (SQUASH_MEMORY), NULL); } @@ -145,7 +145,7 @@ squash_heatshrink_process_stream (SquashStream* stream, SquashOperation operatio assert (stream->avail_out != 0); hsp = heatshrink_encoder_poll (s->ctx.comp, stream->next_out, stream->avail_out, &processed); - if (SQUASH_UNLIKELY(0 > hsp)) + if (HEDLEY_UNLIKELY(0 > hsp)) return squash_error (SQUASH_FAILED); if (0 != processed) { @@ -157,7 +157,7 @@ squash_heatshrink_process_stream (SquashStream* stream, SquashOperation operatio return SQUASH_PROCESSING; } else if (SQUASH_OPERATION_FINISH == operation) { HSE_finish_res hsf = heatshrink_encoder_finish (s->ctx.comp); - if (SQUASH_UNLIKELY(hsf < 0)) + if (HEDLEY_UNLIKELY(hsf < 0)) return squash_error (SQUASH_FAILED); return (HSER_FINISH_MORE == hsf) ? SQUASH_PROCESSING : SQUASH_OK; @@ -166,14 +166,14 @@ squash_heatshrink_process_stream (SquashStream* stream, SquashOperation operatio { if (stream->avail_in != 0) { hss = heatshrink_encoder_sink (s->ctx.comp, (uint8_t*) stream->next_in, stream->avail_in, &processed); - if (SQUASH_UNLIKELY(0 > hss)) + if (HEDLEY_UNLIKELY(0 > hss)) return squash_error (SQUASH_FAILED); stream->next_in += processed; stream->avail_in -= processed; } hsp = heatshrink_encoder_poll (s->ctx.comp, stream->next_out, stream->avail_out, &processed); - if (SQUASH_UNLIKELY(0 > hsp)) + if (HEDLEY_UNLIKELY(0 > hsp)) return squash_error (SQUASH_FAILED); if (0 != processed) { @@ -181,7 +181,7 @@ squash_heatshrink_process_stream (SquashStream* stream, SquashOperation operatio stream->avail_out -= processed; } else if (SQUASH_OPERATION_FINISH == operation) { HSE_finish_res hsf = heatshrink_encoder_finish (s->ctx.comp); - if (SQUASH_UNLIKELY(hsf < 0)) + if (HEDLEY_UNLIKELY(hsf < 0)) return squash_error (SQUASH_FAILED); return (HSER_FINISH_MORE == hsf) ? SQUASH_PROCESSING : SQUASH_OK; @@ -204,7 +204,7 @@ squash_heatshrink_process_stream (SquashStream* stream, SquashOperation operatio assert (stream->avail_out != 0); hsp = heatshrink_decoder_poll (s->ctx.decomp, stream->next_out, stream->avail_out, &processed); - if (SQUASH_UNLIKELY(0 > hsp)) + if (HEDLEY_UNLIKELY(0 > hsp)) return squash_error (SQUASH_FAILED); if (0 != processed) { @@ -216,7 +216,7 @@ squash_heatshrink_process_stream (SquashStream* stream, SquashOperation operatio return SQUASH_PROCESSING; } else if (SQUASH_OPERATION_FINISH == operation) { HSD_finish_res hsf = heatshrink_decoder_finish (s->ctx.decomp); - if (SQUASH_UNLIKELY(hsf < 0)) + if (HEDLEY_UNLIKELY(hsf < 0)) return squash_error (SQUASH_FAILED); return (HSDR_FINISH_MORE == hsf) ? SQUASH_PROCESSING : SQUASH_OK; @@ -225,14 +225,14 @@ squash_heatshrink_process_stream (SquashStream* stream, SquashOperation operatio { if (stream->avail_in != 0) { hss = heatshrink_decoder_sink (s->ctx.decomp, (uint8_t*) stream->next_in, stream->avail_in, &processed); - if (SQUASH_UNLIKELY(0 > hss)) + if (HEDLEY_UNLIKELY(0 > hss)) return squash_error (SQUASH_FAILED); stream->next_in += processed; stream->avail_in -= processed; } hsp = heatshrink_decoder_poll (s->ctx.decomp, stream->next_out, stream->avail_out, &processed); - if (SQUASH_UNLIKELY(0 > hsp)) + if (HEDLEY_UNLIKELY(0 > hsp)) return squash_error (SQUASH_FAILED); if (0 != processed) { @@ -251,7 +251,7 @@ squash_heatshrink_process_stream (SquashStream* stream, SquashOperation operatio } } - squash_assert_unreachable (); + HEDLEY_UNREACHABLE (); } static size_t @@ -261,7 +261,7 @@ squash_heatshrink_get_max_compressed_size (SquashCodec* codec, size_t uncompress SquashStatus squash_plugin_init_codec (SquashCodec* codec, SquashCodecImpl* impl) { - if (SQUASH_LIKELY(strcmp ("heatshrink", squash_codec_get_name (codec)) == 0)) { + if (HEDLEY_LIKELY(strcmp ("heatshrink", squash_codec_get_name (codec)) == 0)) { impl->options = squash_heatshrink_options; impl->create_stream = squash_heatshrink_create_stream; impl->process_stream = squash_heatshrink_process_stream; diff --git a/plugins/libdeflate/squash-libdeflate.c b/plugins/libdeflate/squash-libdeflate.c index 1286e96..5949eff 100644 --- a/plugins/libdeflate/squash-libdeflate.c +++ b/plugins/libdeflate/squash-libdeflate.c @@ -61,23 +61,23 @@ squash_libdeflate_get_max_compressed_size (SquashCodec* codec, size_t uncompress static SquashStatus squash_libdeflate_compress_buffer (SquashCodec* codec, size_t* compressed_size, - uint8_t compressed[SQUASH_ARRAY_PARAM(*compressed_size)], + uint8_t compressed[HEDLEY_ARRAY_PARAM(*compressed_size)], size_t uncompressed_size, - const uint8_t uncompressed[SQUASH_ARRAY_PARAM(uncompressed_size)], + const uint8_t uncompressed[HEDLEY_ARRAY_PARAM(uncompressed_size)], SquashOptions* options) { const int level = squash_options_get_int_at (options, codec, SQUASH_LIBDEFLATE_OPT_LEVEL); struct deflate_compressor *compressor = deflate_alloc_compressor(level); *compressed_size = deflate_compress(compressor, uncompressed, uncompressed_size, compressed, *compressed_size); deflate_free_compressor(compressor); - return SQUASH_LIKELY(*compressed_size != 0) ? SQUASH_OK : squash_error (SQUASH_BUFFER_FULL); + return HEDLEY_LIKELY(*compressed_size != 0) ? SQUASH_OK : squash_error (SQUASH_BUFFER_FULL); } static SquashStatus squash_libdeflate_decompress_buffer (SquashCodec* codec, size_t* decompressed_size, - uint8_t decompressed[SQUASH_ARRAY_PARAM(*decompressed_size)], + uint8_t decompressed[HEDLEY_ARRAY_PARAM(*decompressed_size)], size_t compressed_size, - const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_size)], + const uint8_t compressed[HEDLEY_ARRAY_PARAM(compressed_size)], SquashOptions* options) { struct deflate_decompressor *decompressor = deflate_alloc_decompressor(); size_t actual_out_nbytes; @@ -96,14 +96,14 @@ squash_libdeflate_decompress_buffer (SquashCodec* codec, return squash_error (SQUASH_BUFFER_FULL); } - squash_assert_unreachable (); + HEDLEY_UNREACHABLE (); } SquashStatus squash_plugin_init_codec (SquashCodec* codec, SquashCodecImpl* impl) { const char* name = squash_codec_get_name (codec); - if (SQUASH_LIKELY(strcmp ("deflate", name) == 0)) { + if (HEDLEY_LIKELY(strcmp ("deflate", name) == 0)) { impl->options = squash_libdeflate_options; impl->get_max_compressed_size = squash_libdeflate_get_max_compressed_size; impl->decompress_buffer = squash_libdeflate_decompress_buffer; diff --git a/plugins/lz4/squash-lz4.c b/plugins/lz4/squash-lz4.c index 649473c..a31782a 100644 --- a/plugins/lz4/squash-lz4.c +++ b/plugins/lz4/squash-lz4.c @@ -61,13 +61,13 @@ squash_lz4_get_max_compressed_size (SquashCodec* codec, size_t uncompressed_size static SquashStatus squash_lz4_decompress_buffer (SquashCodec* codec, size_t* decompressed_size, - uint8_t decompressed[SQUASH_ARRAY_PARAM(*decompressed_size)], + uint8_t decompressed[HEDLEY_ARRAY_PARAM(*decompressed_size)], size_t compressed_size, - const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_size)], + const uint8_t compressed[HEDLEY_ARRAY_PARAM(compressed_size)], SquashOptions* options) { #if INT_MAX < SIZE_MAX - if (SQUASH_UNLIKELY(INT_MAX < compressed_size) || - SQUASH_UNLIKELY(INT_MAX < *decompressed_size)) + if (HEDLEY_UNLIKELY(INT_MAX < compressed_size) || + HEDLEY_UNLIKELY(INT_MAX < *decompressed_size)) return squash_error (SQUASH_RANGE); #endif @@ -80,7 +80,7 @@ squash_lz4_decompress_buffer (SquashCodec* codec, return SQUASH_FAILED; } else { #if SIZE_MAX < INT_MAX - if (SQUASH_UNLIKELY(SIZE_MAX < lz4_e)) + if (HEDLEY_UNLIKELY(SIZE_MAX < lz4_e)) return squash_error (SQUASH_RANGE); #endif *decompressed_size = (size_t) lz4_e; @@ -104,7 +104,7 @@ squash_lz4_level_to_fast_mode (const int level) { case 6: return 2; default: - squash_assert_unreachable(); + HEDLEY_UNREACHABLE(); } } @@ -126,22 +126,22 @@ squash_lz4_level_to_hc_level (const int level) { case 14: return 16; default: - squash_assert_unreachable(); + HEDLEY_UNREACHABLE(); } } static SquashStatus squash_lz4_compress_buffer (SquashCodec* codec, size_t* compressed_size, - uint8_t compressed[SQUASH_ARRAY_PARAM(*compressed_size)], + uint8_t compressed[HEDLEY_ARRAY_PARAM(*compressed_size)], size_t uncompressed_size, - const uint8_t uncompressed[SQUASH_ARRAY_PARAM(uncompressed_size)], + const uint8_t uncompressed[HEDLEY_ARRAY_PARAM(uncompressed_size)], SquashOptions* options) { int level = squash_options_get_int_at (options, codec, SQUASH_LZ4_OPT_LEVEL); #if INT_MAX < SIZE_MAX - if (SQUASH_UNLIKELY(INT_MAX < uncompressed_size) || - SQUASH_UNLIKELY(INT_MAX < *compressed_size)) + if (HEDLEY_UNLIKELY(INT_MAX < uncompressed_size) || + HEDLEY_UNLIKELY(INT_MAX < *compressed_size)) return squash_error (SQUASH_RANGE); #endif @@ -165,31 +165,31 @@ squash_lz4_compress_buffer (SquashCodec* codec, (int) *compressed_size, squash_lz4_level_to_hc_level (level)); } else { - squash_assert_unreachable(); + HEDLEY_UNREACHABLE(); } #if SIZE_MAX < INT_MAX - if (SQUASH_UNLIKELY(SIZE_MAX < lz4_r)) + if (HEDLEY_UNLIKELY(SIZE_MAX < lz4_r)) return squash_error (SQUASH_RANGE); #endif *compressed_size = lz4_r; - return SQUASH_UNLIKELY(lz4_r == 0) ? squash_error (SQUASH_BUFFER_FULL) : SQUASH_OK; + return HEDLEY_UNLIKELY(lz4_r == 0) ? squash_error (SQUASH_BUFFER_FULL) : SQUASH_OK; } static SquashStatus squash_lz4_compress_buffer_unsafe (SquashCodec* codec, size_t* compressed_size, - uint8_t compressed[SQUASH_ARRAY_PARAM(*compressed_size)], + uint8_t compressed[HEDLEY_ARRAY_PARAM(*compressed_size)], size_t uncompressed_size, - const uint8_t uncompressed[SQUASH_ARRAY_PARAM(uncompressed_size)], + const uint8_t uncompressed[HEDLEY_ARRAY_PARAM(uncompressed_size)], SquashOptions* options) { int level = squash_options_get_int_at (options, codec, SQUASH_LZ4_OPT_LEVEL); #if INT_MAX < SIZE_MAX - if (SQUASH_UNLIKELY(INT_MAX < uncompressed_size) || - SQUASH_UNLIKELY(INT_MAX < *compressed_size)) + if (HEDLEY_UNLIKELY(INT_MAX < uncompressed_size) || + HEDLEY_UNLIKELY(INT_MAX < *compressed_size)) return squash_error (SQUASH_RANGE); #endif @@ -215,7 +215,7 @@ squash_lz4_compress_buffer_unsafe (SquashCodec* codec, } #if SIZE_MAX < INT_MAX - if (SQUASH_UNLIKELY(SIZE_MAX < lz4_r)) + if (HEDLEY_UNLIKELY(SIZE_MAX < lz4_r)) return squash_error (SQUASH_RANGE); #endif diff --git a/plugins/lz4/squash-lz4f.c b/plugins/lz4/squash-lz4f.c index 7724bfb..7be75f1 100644 --- a/plugins/lz4/squash-lz4f.c +++ b/plugins/lz4/squash-lz4f.c @@ -137,7 +137,7 @@ squash_lz4f_get_status (size_t res) { case LZ4F_ERROR_maxCode: return squash_error (SQUASH_FAILED); default: - squash_assert_unreachable (); + HEDLEY_UNREACHABLE (); } } @@ -149,7 +149,7 @@ squash_lz4f_stream_new (SquashCodec* codec, SquashStreamType stream_type, Squash assert (codec != NULL); stream = (SquashLZ4FStream*) squash_malloc (sizeof (SquashLZ4FStream)); - if (SQUASH_UNLIKELY(stream == NULL)) + if (HEDLEY_UNLIKELY(stream == NULL)) return (squash_error (SQUASH_MEMORY), NULL); squash_lz4f_stream_init (stream, codec, stream_type, options, squash_lz4f_stream_destroy); @@ -179,7 +179,7 @@ squash_lz4f_stream_new (SquashCodec* codec, SquashStreamType stream_type, Squash ec = LZ4F_createDecompressionContext(&(stream->data.decomp.ctx), LZ4F_VERSION); } - if (SQUASH_UNLIKELY(LZ4F_isError (ec))) { + if (HEDLEY_UNLIKELY(LZ4F_isError (ec))) { squash_object_unref (stream); return (squash_error (SQUASH_FAILED), NULL); } @@ -233,7 +233,7 @@ squash_lz4f_block_size_id_to_size (LZ4F_blockSizeID_t blkid) { return 4 * 1024 * 1024; case LZ4F_default: default: - squash_assert_unreachable(); + HEDLEY_UNREACHABLE(); break; } } @@ -331,7 +331,7 @@ squash_lz4f_compress_stream (SquashStream* stream, SquashOperation operation) { stream->next_in += input_size; stream->avail_in -= input_size; } else { - squash_assert_unreachable(); + HEDLEY_UNREACHABLE(); } } else if (operation == SQUASH_OPERATION_FLUSH) { assert (stream->avail_in == 0); @@ -350,11 +350,11 @@ squash_lz4f_compress_stream (SquashStream* stream, SquashOperation operation) { } else if (progress) { break; } else { - squash_assert_unreachable(); + HEDLEY_UNREACHABLE(); } - if (SQUASH_UNLIKELY(LZ4F_isError (olen))) { - squash_assert_unreachable(); + if (HEDLEY_UNLIKELY(LZ4F_isError (olen))) { + HEDLEY_UNREACHABLE(); return squash_error (SQUASH_FAILED); } else { if (olen != 0) { @@ -430,7 +430,7 @@ squash_lz4f_process_stream (SquashStream* stream, SquashOperation operation) { case SQUASH_STREAM_DECOMPRESS: return squash_lz4f_decompress_stream (stream, operation); default: - squash_assert_unreachable(); + HEDLEY_UNREACHABLE(); } } @@ -458,7 +458,7 @@ SquashStatus squash_plugin_init_lz4f (SquashCodec* codec, SquashCodecImpl* impl) { const char* name = squash_codec_get_name (codec); - if (SQUASH_LIKELY(strcmp ("lz4", name) == 0)) { + if (HEDLEY_LIKELY(strcmp ("lz4", name) == 0)) { impl->info = SQUASH_CODEC_INFO_CAN_FLUSH; impl->options = squash_lz4f_options; impl->get_max_compressed_size = squash_lz4f_get_max_compressed_size; diff --git a/plugins/lzf/squash-lzf.c b/plugins/lzf/squash-lzf.c index 2e902cf..9ba51dd 100644 --- a/plugins/lzf/squash-lzf.c +++ b/plugins/lzf/squash-lzf.c @@ -65,16 +65,16 @@ squash_lzf_get_max_compressed_size (SquashCodec* codec, size_t uncompressed_size static SquashStatus squash_lzf_decompress_buffer (SquashCodec* codec, size_t* decompressed_size, - uint8_t decompressed[SQUASH_ARRAY_PARAM(*decompressed_size)], + uint8_t decompressed[HEDLEY_ARRAY_PARAM(*decompressed_size)], size_t compressed_size, - const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_size)], + const uint8_t compressed[HEDLEY_ARRAY_PARAM(compressed_size)], SquashOptions* options) { SquashStatus res = SQUASH_OK; unsigned int lzf_e; #if UINT_MAX < SIZE_MAX - if (SQUASH_UNLIKELY(UINT_MAX < compressed_size) || - SQUASH_UNLIKELY(UINT_MAX < *decompressed_size)) + if (HEDLEY_UNLIKELY(UINT_MAX < compressed_size) || + HEDLEY_UNLIKELY(UINT_MAX < *decompressed_size)) return squash_error (SQUASH_RANGE); #endif @@ -95,7 +95,7 @@ squash_lzf_decompress_buffer (SquashCodec* codec, } } else { #if SIZE_MAX < UINT_MAX - if (SQUASH_UNLIKELY(SIZE_MAX < lzf_e)) + if (HEDLEY_UNLIKELY(SIZE_MAX < lzf_e)) return squash_error (SQUASH_RANGE); #endif *decompressed_size = (size_t) lzf_e; @@ -107,16 +107,16 @@ squash_lzf_decompress_buffer (SquashCodec* codec, static SquashStatus squash_lzf_compress_buffer (SquashCodec* codec, size_t* compressed_size, - uint8_t compressed[SQUASH_ARRAY_PARAM(*compressed_size)], + uint8_t compressed[HEDLEY_ARRAY_PARAM(*compressed_size)], size_t uncompressed_size, - const uint8_t uncompressed[SQUASH_ARRAY_PARAM(uncompressed_size)], + const uint8_t uncompressed[HEDLEY_ARRAY_PARAM(uncompressed_size)], SquashOptions* options) { unsigned int lzf_e; const int level = squash_options_get_int_at (options, codec, SQUASH_LZF_OPT_LEVEL); #if UINT_MAX < SIZE_MAX - if (SQUASH_UNLIKELY(UINT_MAX < uncompressed_size) || - SQUASH_UNLIKELY(UINT_MAX < *compressed_size)) + if (HEDLEY_UNLIKELY(UINT_MAX < uncompressed_size) || + HEDLEY_UNLIKELY(UINT_MAX < *compressed_size)) return squash_error (SQUASH_RANGE); #endif @@ -143,7 +143,7 @@ squash_lzf_compress_buffer (SquashCodec* codec, return SQUASH_BUFFER_FULL; } else { #if SIZE_MAX < UINT_MAX - if (SQUASH_UNLIKELY(SIZE_MAX < lzf_e)) + if (HEDLEY_UNLIKELY(SIZE_MAX < lzf_e)) return squash_error (SQUASH_RANGE); #endif *compressed_size = (size_t) lzf_e; @@ -156,7 +156,7 @@ SquashStatus squash_plugin_init_codec (SquashCodec* codec, SquashCodecImpl* impl) { const char* name = squash_codec_get_name (codec); - if (SQUASH_LIKELY(strcmp ("lzf", name) == 0)) { + if (HEDLEY_LIKELY(strcmp ("lzf", name) == 0)) { impl->options = squash_lzf_options; impl->get_max_compressed_size = squash_lzf_get_max_compressed_size; impl->decompress_buffer = squash_lzf_decompress_buffer; diff --git a/plugins/lzfse/squash-lzfse.c b/plugins/lzfse/squash-lzfse.c index f06503f..ac661cc 100644 --- a/plugins/lzfse/squash-lzfse.c +++ b/plugins/lzfse/squash-lzfse.c @@ -48,13 +48,13 @@ squash_lzfse_get_max_compressed_size (SquashCodec* codec, size_t uncompressed_si static SquashStatus squash_lzfse_decompress_buffer (SquashCodec* codec, size_t* decompressed_size, - uint8_t decompressed[SQUASH_ARRAY_PARAM(*decompressed_size)], + uint8_t decompressed[HEDLEY_ARRAY_PARAM(*decompressed_size)], size_t compressed_size, - const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_size)], + const uint8_t compressed[HEDLEY_ARRAY_PARAM(compressed_size)], SquashOptions* options) { const size_t workmem_size = lzfse_decode_scratch_size (); lzfse_decoder_state* ctx = squash_calloc (workmem_size, 1); - if (SQUASH_UNLIKELY(ctx == NULL)) + if (HEDLEY_UNLIKELY(ctx == NULL)) return squash_error (SQUASH_FAILED); ctx->src_begin = ctx->src = compressed; @@ -82,12 +82,12 @@ squash_lzfse_decompress_buffer (SquashCodec* codec, static SquashStatus squash_lzfse_compress_buffer (SquashCodec* codec, size_t* compressed_size, - uint8_t compressed[SQUASH_ARRAY_PARAM(*compressed_size)], + uint8_t compressed[HEDLEY_ARRAY_PARAM(*compressed_size)], size_t uncompressed_size, - const uint8_t uncompressed[SQUASH_ARRAY_PARAM(uncompressed_size)], + const uint8_t uncompressed[HEDLEY_ARRAY_PARAM(uncompressed_size)], SquashOptions* options) { void* workmem = squash_malloc (lzfse_encode_scratch_size ()); - if (SQUASH_UNLIKELY(workmem == NULL)) + if (HEDLEY_UNLIKELY(workmem == NULL)) return squash_error (SQUASH_FAILED); const size_t r = lzfse_encode_buffer (compressed, *compressed_size, @@ -96,7 +96,7 @@ squash_lzfse_compress_buffer (SquashCodec* codec, squash_free (workmem); - if (SQUASH_UNLIKELY(r == 0)) + if (HEDLEY_UNLIKELY(r == 0)) return squash_error (SQUASH_BUFFER_FULL); *compressed_size = r; @@ -111,9 +111,9 @@ squash_lzvn_get_max_compressed_size (SquashCodec* codec, size_t uncompressed_siz static SquashStatus squash_lzvn_decompress_buffer (SquashCodec* codec, size_t* decompressed_size, - uint8_t decompressed[SQUASH_ARRAY_PARAM(*decompressed_size)], + uint8_t decompressed[HEDLEY_ARRAY_PARAM(*decompressed_size)], size_t compressed_size, - const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_size)], + const uint8_t compressed[HEDLEY_ARRAY_PARAM(compressed_size)], SquashOptions* options) { lzvn_decoder_state decoder = { 0, }; @@ -130,7 +130,7 @@ squash_lzvn_decompress_buffer (SquashCodec* codec, const size_t bytes_read = decoder.src - compressed; const size_t bytes_written = decoder.dst - decoder.dst_begin; - if (SQUASH_UNLIKELY(bytes_read != compressed_size)) { + if (HEDLEY_UNLIKELY(bytes_read != compressed_size)) { if (bytes_written == *decompressed_size) return SQUASH_BUFFER_FULL; else @@ -145,15 +145,15 @@ squash_lzvn_decompress_buffer (SquashCodec* codec, static SquashStatus squash_lzvn_compress_buffer (SquashCodec* codec, size_t* compressed_size, - uint8_t compressed[SQUASH_ARRAY_PARAM(*compressed_size)], + uint8_t compressed[HEDLEY_ARRAY_PARAM(*compressed_size)], size_t uncompressed_size, - const uint8_t uncompressed[SQUASH_ARRAY_PARAM(uncompressed_size)], + const uint8_t uncompressed[HEDLEY_ARRAY_PARAM(uncompressed_size)], SquashOptions* options) { uint8_t outbuf[LZVN_ENCODE_MIN_DST_SIZE]; uint8_t* dest; size_t dest_l; - if (SQUASH_UNLIKELY(*compressed_size < sizeof(outbuf))) { + if (HEDLEY_UNLIKELY(*compressed_size < sizeof(outbuf))) { dest = outbuf; dest_l = sizeof(outbuf); } else { @@ -162,7 +162,7 @@ squash_lzvn_compress_buffer (SquashCodec* codec, } void* workmem = squash_malloc (LZVN_ENCODE_WORK_SIZE); - if (SQUASH_UNLIKELY(workmem == NULL)) + if (HEDLEY_UNLIKELY(workmem == NULL)) return squash_error (SQUASH_MEMORY); dest_l = @@ -172,10 +172,10 @@ squash_lzvn_compress_buffer (SquashCodec* codec, squash_free (workmem); - if (SQUASH_UNLIKELY(dest_l == 0)) + if (HEDLEY_UNLIKELY(dest_l == 0)) return squash_error (SQUASH_BUFFER_FULL); - if (SQUASH_UNLIKELY(dest == outbuf)) { + if (HEDLEY_UNLIKELY(dest == outbuf)) { if (*compressed_size < dest_l) return squash_error (SQUASH_BUFFER_FULL); diff --git a/plugins/lzg/squash-lzg.c b/plugins/lzg/squash-lzg.c index 61c2ac7..a5273b1 100644 --- a/plugins/lzg/squash-lzg.c +++ b/plugins/lzg/squash-lzg.c @@ -63,14 +63,14 @@ SquashStatus squash_plugin_init_codec (SquashCodec* codec, SquashC static size_t squash_lzg_get_max_compressed_size (SquashCodec* codec, size_t uncompressed_size) { #if UINT32_MAX < SIZE_MAX - if (SQUASH_UNLIKELY(UINT32_MAX < uncompressed_size)) + if (HEDLEY_UNLIKELY(UINT32_MAX < uncompressed_size)) return (squash_error (SQUASH_RANGE), 0); #endif const lzg_uint32_t res = LZG_MaxEncodedSize ((lzg_uint32_t) uncompressed_size); #if SIZE_MAX < UINT32_MAX - if (SQUASH_UNLIKELY(SIZE_MAX < res)) + if (HEDLEY_UNLIKELY(SIZE_MAX < res)) return (squash_error (SQUASH_RANGE), 0); #endif @@ -80,16 +80,16 @@ squash_lzg_get_max_compressed_size (SquashCodec* codec, size_t uncompressed_size static size_t squash_lzg_get_uncompressed_size (SquashCodec* codec, size_t compressed_size, - const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_size)]) { + const uint8_t compressed[HEDLEY_ARRAY_PARAM(compressed_size)]) { #if UINT32_MAX < SIZE_MAX - if (SQUASH_UNLIKELY(UINT32_MAX < compressed_size)) + if (HEDLEY_UNLIKELY(UINT32_MAX < compressed_size)) return (squash_error (SQUASH_RANGE), 0); #endif const lzg_uint32_t res = LZG_DecodedSize ((const unsigned char*) compressed, (lzg_uint32_t) compressed_size); #if SIZE_MAX < UINT32_MAX - if (SQUASH_UNLIKELY(SIZE_MAX < res)) + if (HEDLEY_UNLIKELY(SIZE_MAX < res)) return (squash_error (SQUASH_RANGE), 0); #endif @@ -99,9 +99,9 @@ squash_lzg_get_uncompressed_size (SquashCodec* codec, static SquashStatus squash_lzg_compress_buffer (SquashCodec* codec, size_t* compressed_size, - uint8_t compressed[SQUASH_ARRAY_PARAM(*compressed_size)], + uint8_t compressed[HEDLEY_ARRAY_PARAM(*compressed_size)], size_t uncompressed_size, - const uint8_t uncompressed[SQUASH_ARRAY_PARAM(uncompressed_size)], + const uint8_t uncompressed[HEDLEY_ARRAY_PARAM(uncompressed_size)], SquashOptions* options) { lzg_encoder_config_t cfg = { squash_options_get_int_at (options, codec, SQUASH_LZG_OPT_LEVEL), @@ -111,13 +111,13 @@ squash_lzg_compress_buffer (SquashCodec* codec, }; #if UINT32_MAX < SIZE_MAX - if (SQUASH_UNLIKELY(UINT32_MAX < uncompressed_size) || - SQUASH_UNLIKELY(UINT32_MAX < *compressed_size)) + if (HEDLEY_UNLIKELY(UINT32_MAX < uncompressed_size) || + HEDLEY_UNLIKELY(UINT32_MAX < *compressed_size)) return squash_error (SQUASH_RANGE); #endif uint8_t* workmem = squash_calloc (LZG_WorkMemSize (&cfg), 1); - if (SQUASH_UNLIKELY(workmem == NULL)) + if (HEDLEY_UNLIKELY(workmem == NULL)) return squash_error (SQUASH_MEMORY); lzg_uint32_t res = LZG_EncodeFull ((const unsigned char*) uncompressed, (lzg_uint32_t) uncompressed_size, (unsigned char*) compressed, (lzg_uint32_t) *compressed_size, @@ -128,7 +128,7 @@ squash_lzg_compress_buffer (SquashCodec* codec, return squash_error (SQUASH_FAILED); } else { #if SIZE_MAX < UINT32_MAX - if (SQUASH_UNLIKELY(SIZE_MAX < res)) + if (HEDLEY_UNLIKELY(SIZE_MAX < res)) return squash_error (SQUASH_RANGE); #endif *compressed_size = (size_t) res; @@ -139,15 +139,15 @@ squash_lzg_compress_buffer (SquashCodec* codec, static SquashStatus squash_lzg_decompress_buffer (SquashCodec* codec, size_t* decompressed_size, - uint8_t decompressed[SQUASH_ARRAY_PARAM(*decompressed_size)], + uint8_t decompressed[HEDLEY_ARRAY_PARAM(*decompressed_size)], size_t compressed_size, - const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_size)], + const uint8_t compressed[HEDLEY_ARRAY_PARAM(compressed_size)], SquashOptions* options) { lzg_uint32_t res; #if UINT32_MAX < SIZE_MAX - if (SQUASH_UNLIKELY(UINT32_MAX < compressed_size) || - SQUASH_UNLIKELY(UINT32_MAX < *decompressed_size)) + if (HEDLEY_UNLIKELY(UINT32_MAX < compressed_size) || + HEDLEY_UNLIKELY(UINT32_MAX < *decompressed_size)) return squash_error (SQUASH_RANGE); #endif @@ -157,11 +157,11 @@ squash_lzg_decompress_buffer (SquashCodec* codec, res = LZG_Decode ((const unsigned char*) compressed, (lzg_uint32_t) compressed_size, (unsigned char*) decompressed, (lzg_uint32_t) *decompressed_size); - if (SQUASH_UNLIKELY(res == 0)) { + if (HEDLEY_UNLIKELY(res == 0)) { return squash_error (SQUASH_FAILED); } else { #if SIZE_MAX < UINT32_MAX - if (SQUASH_UNLIKELY(SIZE_MAX < res)) + if (HEDLEY_UNLIKELY(SIZE_MAX < res)) return squash_error (SQUASH_RANGE); #endif *decompressed_size = (size_t) res; @@ -173,7 +173,7 @@ SquashStatus squash_plugin_init_codec (SquashCodec* codec, SquashCodecImpl* impl) { const char* name = squash_codec_get_name (codec); - if (SQUASH_LIKELY(strcmp ("lzg", name) == 0)) { + if (HEDLEY_LIKELY(strcmp ("lzg", name) == 0)) { impl->options = squash_lzg_options; impl->get_uncompressed_size = squash_lzg_get_uncompressed_size; impl->get_max_compressed_size = squash_lzg_get_max_compressed_size; diff --git a/plugins/lzham/squash-lzham.c b/plugins/lzham/squash-lzham.c index fc38a86..a323248 100644 --- a/plugins/lzham/squash-lzham.c +++ b/plugins/lzham/squash-lzham.c @@ -219,11 +219,11 @@ squash_operation_to_lzham (SquashOperation operation) { case SQUASH_OPERATION_FINISH: return LZHAM_FINISH; case SQUASH_OPERATION_TERMINATE: - squash_assert_unreachable (); + HEDLEY_UNREACHABLE (); break; } - squash_assert_unreachable(); + HEDLEY_UNREACHABLE(); } static SquashStatus @@ -300,9 +300,9 @@ squash_lzham_get_max_compressed_size (SquashCodec* codec, size_t uncompressed_si static SquashStatus squash_lzham_compress_buffer (SquashCodec* codec, size_t* compressed_size, - uint8_t compressed[SQUASH_ARRAY_PARAM(*compressed_size)], + uint8_t compressed[HEDLEY_ARRAY_PARAM(*compressed_size)], size_t uncompressed_size, - const uint8_t uncompressed[SQUASH_ARRAY_PARAM(uncompressed_size)], + const uint8_t uncompressed[HEDLEY_ARRAY_PARAM(uncompressed_size)], SquashOptions* options) { lzham_compress_status_t status; lzham_compress_params params; @@ -314,7 +314,7 @@ squash_lzham_compress_buffer (SquashCodec* codec, uncompressed, uncompressed_size, NULL); - if (SQUASH_UNLIKELY(status != LZHAM_COMP_STATUS_SUCCESS)) { + if (HEDLEY_UNLIKELY(status != LZHAM_COMP_STATUS_SUCCESS)) { switch ((int) status) { case LZHAM_COMP_STATUS_INVALID_PARAMETER: return squash_error (SQUASH_BAD_VALUE); @@ -331,9 +331,9 @@ squash_lzham_compress_buffer (SquashCodec* codec, static SquashStatus squash_lzham_decompress_buffer (SquashCodec* codec, size_t* decompressed_size, - uint8_t decompressed[SQUASH_ARRAY_PARAM(*decompressed_size)], + uint8_t decompressed[HEDLEY_ARRAY_PARAM(*decompressed_size)], size_t compressed_size, - const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_size)], + const uint8_t compressed[HEDLEY_ARRAY_PARAM(compressed_size)], SquashOptions* options) { lzham_decompress_status_t status; lzham_decompress_params params; @@ -356,12 +356,12 @@ squash_lzham_decompress_buffer (SquashCodec* codec, return squash_error (SQUASH_FAILED); } - squash_assert_unreachable (); + HEDLEY_UNREACHABLE (); } SquashStatus squash_plugin_init_codec (SquashCodec* codec, SquashCodecImpl* impl) { - if (SQUASH_LIKELY(strcmp ("lzham", squash_codec_get_name (codec)) == 0)) { + if (HEDLEY_LIKELY(strcmp ("lzham", squash_codec_get_name (codec)) == 0)) { impl->info = SQUASH_CODEC_INFO_CAN_FLUSH; impl->options = squash_lzham_options; impl->create_stream = squash_lzham_create_stream; diff --git a/plugins/lzjb/squash-lzjb.c b/plugins/lzjb/squash-lzjb.c index 4c6365d..c6b7cc8 100644 --- a/plugins/lzjb/squash-lzjb.c +++ b/plugins/lzjb/squash-lzjb.c @@ -44,20 +44,20 @@ squash_lzjb_get_max_compressed_size (SquashCodec* codec, size_t uncompressed_siz static SquashStatus squash_lzjb_compress_buffer (SquashCodec* codec, size_t* compressed_size, - uint8_t compressed[SQUASH_ARRAY_PARAM(*compressed_size)], + uint8_t compressed[HEDLEY_ARRAY_PARAM(*compressed_size)], size_t uncompressed_size, - const uint8_t uncompressed[SQUASH_ARRAY_PARAM(uncompressed_size)], + const uint8_t uncompressed[HEDLEY_ARRAY_PARAM(uncompressed_size)], SquashOptions* options) { *compressed_size = lzjb_compress (uncompressed, compressed, uncompressed_size, *compressed_size); - return SQUASH_LIKELY(*compressed_size != 0) ? SQUASH_OK : squash_error (SQUASH_FAILED); + return HEDLEY_LIKELY(*compressed_size != 0) ? SQUASH_OK : squash_error (SQUASH_FAILED); } static SquashStatus squash_lzjb_decompress_buffer (SquashCodec* codec, size_t* decompressed_size, - uint8_t decompressed[SQUASH_ARRAY_PARAM(*decompressed_size)], + uint8_t decompressed[HEDLEY_ARRAY_PARAM(*decompressed_size)], size_t compressed_size, - const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_size)], + const uint8_t compressed[HEDLEY_ARRAY_PARAM(compressed_size)], SquashOptions* options) { LZJBResult res = lzjb_decompress (compressed, decompressed, compressed_size, decompressed_size); switch (res) { @@ -68,14 +68,14 @@ squash_lzjb_decompress_buffer (SquashCodec* codec, case LZJB_WOULD_OVERFLOW: return SQUASH_BUFFER_FULL; } - squash_assert_unreachable (); + HEDLEY_UNREACHABLE (); } SquashStatus squash_plugin_init_codec (SquashCodec* codec, SquashCodecImpl* impl) { const char* name = squash_codec_get_name (codec); - if (SQUASH_LIKELY(strcmp ("lzjb", name) == 0)) { + if (HEDLEY_LIKELY(strcmp ("lzjb", name) == 0)) { impl->get_max_compressed_size = squash_lzjb_get_max_compressed_size; impl->decompress_buffer = squash_lzjb_decompress_buffer; impl->compress_buffer = squash_lzjb_compress_buffer; diff --git a/plugins/lzma/squash-lzma.c b/plugins/lzma/squash-lzma.c index 3712d07..cb34175 100644 --- a/plugins/lzma/squash-lzma.c +++ b/plugins/lzma/squash-lzma.c @@ -212,7 +212,7 @@ static SquashLZMAType squash_lzma_codec_to_type (SquashCodec* codec) { static void* squash_lzma_calloc (void *opaque, size_t nmemb, size_t size) { void* ptr = squash_malloc (nmemb * size); - if (SQUASH_UNLIKELY(ptr == NULL)) + if (HEDLEY_UNLIKELY(ptr == NULL)) return ptr; return memset (ptr, 0, nmemb * size); } @@ -292,7 +292,7 @@ squash_lzma_stream_new (SquashCodec* codec, SquashStreamType stream_type, Squash lzma_type == SQUASH_LZMA_TYPE_LZMA2) { lzma_e = lzma_raw_encoder(&(stream->stream), filters); } else { - squash_assert_unreachable(); + HEDLEY_UNREACHABLE(); } } else if (stream_type == SQUASH_STREAM_DECOMPRESS) { if (lzma_type == SQUASH_LZMA_TYPE_XZ) { @@ -306,10 +306,10 @@ squash_lzma_stream_new (SquashCodec* codec, SquashStreamType stream_type, Squash lzma_type == SQUASH_LZMA_TYPE_LZMA2) { lzma_e = lzma_raw_decoder(&(stream->stream), filters); } else { - squash_assert_unreachable(); + HEDLEY_UNREACHABLE(); } } else { - squash_assert_unreachable(); + HEDLEY_UNREACHABLE(); } if (lzma_e != LZMA_OK) { @@ -356,7 +356,7 @@ squash_lzma_process_stream (SquashStream* stream, SquashOperation operation) { lzma_e = lzma_code (s, LZMA_FINISH); break; case SQUASH_OPERATION_TERMINATE: - squash_assert_unreachable (); + HEDLEY_UNREACHABLE (); } SQUASH_LZMA_STREAM_COPY_FROM_LZMA_STREAM(stream, s); @@ -372,7 +372,7 @@ squash_lzma_process_stream (SquashStream* stream, SquashOperation operation) { return SQUASH_PROCESSING; break; case SQUASH_OPERATION_TERMINATE: - squash_assert_unreachable (); + HEDLEY_UNREACHABLE (); break; } } else if (lzma_e == LZMA_STREAM_END) { @@ -399,7 +399,7 @@ squash_lzma_get_max_compressed_size (SquashCodec* codec, size_t uncompressed_siz break; } - squash_assert_unreachable (); + HEDLEY_UNREACHABLE (); } SquashStatus diff --git a/plugins/lzo/squash-lzo.c b/plugins/lzo/squash-lzo.c index 9885558..70e827c 100644 --- a/plugins/lzo/squash-lzo.c +++ b/plugins/lzo/squash-lzo.c @@ -288,9 +288,9 @@ squash_lzo_get_max_compressed_size (SquashCodec* codec, size_t uncompressed_size static SquashStatus squash_lzo_decompress_buffer (SquashCodec* codec, size_t* decompressed_size, - uint8_t decompressed[SQUASH_ARRAY_PARAM(*decompressed_size)], + uint8_t decompressed[HEDLEY_ARRAY_PARAM(*decompressed_size)], size_t compressed_size, - const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_size)], + const uint8_t compressed[HEDLEY_ARRAY_PARAM(compressed_size)], SquashOptions* options) { const SquashLZOCodec* lzo_codec; const char* codec_name; @@ -304,8 +304,8 @@ squash_lzo_decompress_buffer (SquashCodec* codec, lzo_codec = squash_lzo_codec_from_name (codec_name); #if UINT_MAX < SIZE_MAX - if (SQUASH_UNLIKELY(UINT_MAX < compressed_size) || - SQUASH_UNLIKELY(UINT_MAX < *decompressed_size)) + if (HEDLEY_UNLIKELY(UINT_MAX < compressed_size) || + HEDLEY_UNLIKELY(UINT_MAX < *decompressed_size)) return squash_error (SQUASH_RANGE); #endif compressed_len = (lzo_uint) compressed_size; @@ -313,7 +313,7 @@ squash_lzo_decompress_buffer (SquashCodec* codec, if (lzo_codec->work_mem > 0) { work_mem = squash_malloc (lzo_codec->work_mem); - if (SQUASH_UNLIKELY(work_mem == NULL)) { + if (HEDLEY_UNLIKELY(work_mem == NULL)) { return squash_error (SQUASH_MEMORY); } } @@ -327,7 +327,7 @@ squash_lzo_decompress_buffer (SquashCodec* codec, return squash_lzo_status_to_squash_status (lzo_e); #if SIZE_MAX < UINT_MAX - if (SQUASH_UNLIKELY(SIZE_MAX < decompressed_len)) + if (HEDLEY_UNLIKELY(SIZE_MAX < decompressed_len)) return squash_error (SQUASH_RANGE); #endif @@ -339,9 +339,9 @@ squash_lzo_decompress_buffer (SquashCodec* codec, static SquashStatus squash_lzo_compress_buffer (SquashCodec* codec, size_t* compressed_size, - uint8_t compressed[SQUASH_ARRAY_PARAM(*compressed_size)], + uint8_t compressed[HEDLEY_ARRAY_PARAM(*compressed_size)], size_t uncompressed_size, - const uint8_t uncompressed[SQUASH_ARRAY_PARAM(uncompressed_size)], + const uint8_t uncompressed[HEDLEY_ARRAY_PARAM(uncompressed_size)], SquashOptions* options) { const SquashLZOCodec* lzo_codec; const SquashLZOCompressor* compressor; @@ -359,8 +359,8 @@ squash_lzo_compress_buffer (SquashCodec* codec, compressor = squash_lzo_codec_get_compressor (lzo_codec, squash_options_get_int_at (options, codec, SQUASH_LZO_OPT_LEVEL)); #if UINT_MAX < SIZE_MAX - if (SQUASH_UNLIKELY(UINT_MAX < uncompressed_size) || - SQUASH_UNLIKELY(UINT_MAX < *compressed_size)) + if (HEDLEY_UNLIKELY(UINT_MAX < uncompressed_size) || + HEDLEY_UNLIKELY(UINT_MAX < *compressed_size)) return squash_error (SQUASH_RANGE); #endif uncompressed_len = (lzo_uint) uncompressed_size; @@ -368,7 +368,7 @@ squash_lzo_compress_buffer (SquashCodec* codec, if (compressor->work_mem > 0) { work_mem = squash_malloc (compressor->work_mem); - if (SQUASH_UNLIKELY(work_mem == NULL)) { + if (HEDLEY_UNLIKELY(work_mem == NULL)) { return squash_error (SQUASH_MEMORY); } } @@ -383,7 +383,7 @@ squash_lzo_compress_buffer (SquashCodec* codec, return squash_lzo_status_to_squash_status (lzo_e); #if SIZE_MAX < UINT_MAX - if (SQUASH_UNLIKELY(SIZE_MAX < decompressed_len)) + if (HEDLEY_UNLIKELY(SIZE_MAX < decompressed_len)) return squash_error (SQUASH_RANGE); #endif @@ -401,7 +401,7 @@ SquashStatus squash_plugin_init_codec (SquashCodec* codec, SquashCodecImpl* impl) { const char* codec_name = squash_codec_get_name (codec); - if (SQUASH_UNLIKELY(strncmp ("lzo1", codec_name, 3) != 0)) + if (HEDLEY_UNLIKELY(strncmp ("lzo1", codec_name, 3) != 0)) return squash_error (SQUASH_UNABLE_TO_LOAD); switch (codec_name[4]) { diff --git a/plugins/miniz/squash-miniz.c b/plugins/miniz/squash-miniz.c index 43eb8e6..397d257 100644 --- a/plugins/miniz/squash-miniz.c +++ b/plugins/miniz/squash-miniz.c @@ -129,7 +129,7 @@ static SquashMinizType squash_miniz_codec_to_type (SquashCodec* codec) { } else if (strcmp ("deflate", name) == 0) { return SQUASH_MINIZ_TYPE_DEFLATE; } else { - squash_assert_unreachable(); + HEDLEY_UNREACHABLE(); } } @@ -192,7 +192,7 @@ squash_miniz_stream_new (SquashCodec* codec, SquashStreamType stream_type, Squas } else if (stream_type == SQUASH_STREAM_DECOMPRESS) { miniz_e = mz_inflateInit2 (&(stream->stream), window_bits); } else { - squash_assert_unreachable(); + HEDLEY_UNREACHABLE(); } if (miniz_e != MZ_OK) { @@ -229,11 +229,11 @@ squash_operation_to_miniz (SquashOperation operation) { case SQUASH_OPERATION_FINISH: return MZ_FINISH; case SQUASH_OPERATION_TERMINATE: - squash_assert_unreachable(); + HEDLEY_UNREACHABLE(); break; } - squash_assert_unreachable (); + HEDLEY_UNREACHABLE (); } static SquashStatus @@ -247,8 +247,8 @@ squash_miniz_process_stream (SquashStream* stream, SquashOperation operation) { miniz_stream = &(((SquashMinizStream*) stream)->stream); #if UINT_MAX < SIZE_MAX - if (SQUASH_UNLIKELY(UINT_MAX < stream->avail_in) || - SQUASH_UNLIKELY(UINT_MAX < stream->avail_out)) + if (HEDLEY_UNLIKELY(UINT_MAX < stream->avail_in) || + HEDLEY_UNLIKELY(UINT_MAX < stream->avail_out)) return squash_error (SQUASH_RANGE); #endif SQUASH_MINIZ_STREAM_COPY_TO_MINIZ_STREAM(stream, miniz_stream); @@ -260,8 +260,8 @@ squash_miniz_process_stream (SquashStream* stream, SquashOperation operation) { } #if SIZE_MAX < UINT_MAX - if (SQUASH_UNLIKELY(SIZE_MAX < miniz_stream->avail_out) || - SQUASH_UNLIKELY(SIZE_MAX < miniz_stream->avail_out)) + if (HEDLEY_UNLIKELY(SIZE_MAX < miniz_stream->avail_out) || + HEDLEY_UNLIKELY(SIZE_MAX < miniz_stream->avail_out)) return squash_error (SQUASH_RANGE); #endif SQUASH_MINIZ_STREAM_COPY_FROM_MINIZ_STREAM(stream, miniz_stream); @@ -277,7 +277,7 @@ squash_miniz_process_stream (SquashStream* stream, SquashOperation operation) { res = SQUASH_PROCESSING; break; case SQUASH_OPERATION_TERMINATE: - squash_assert_unreachable (); + HEDLEY_UNREACHABLE (); break; } break; @@ -299,7 +299,7 @@ squash_miniz_process_stream (SquashStream* stream, SquashOperation operation) { } break; case SQUASH_OPERATION_TERMINATE: - squash_assert_unreachable (); + HEDLEY_UNREACHABLE (); break; } break; @@ -322,7 +322,7 @@ squash_miniz_get_max_compressed_size (SquashCodec* codec, size_t uncompressed_si SquashMinizType type = squash_miniz_codec_to_type (codec); #if SIZE_MAX < ULONG_MAX - if (SQUASH_UNLIKELY(uncompressed_size > ULONG_MAX)) { + if (HEDLEY_UNLIKELY(uncompressed_size > ULONG_MAX)) { squash_error (SQUASH_BUFFER_TOO_LARGE); return 0; } diff --git a/plugins/ms-compress/squash-ms-compress.c b/plugins/ms-compress/squash-ms-compress.c index c3fb93b..e0bd265 100644 --- a/plugins/ms-compress/squash-ms-compress.c +++ b/plugins/ms-compress/squash-ms-compress.c @@ -62,7 +62,7 @@ squash_ms_format_from_codec (SquashCodec* codec) { else if (name[14] == 0) return MSCOMP_XPRESS_HUFF; else - squash_assert_unreachable(); + HEDLEY_UNREACHABLE(); } static SquashStatus @@ -93,7 +93,7 @@ squash_ms_stream_new (SquashCodec* codec, SquashStreamType stream_type, SquashOp assert (stream_type == SQUASH_STREAM_COMPRESS || stream_type == SQUASH_STREAM_DECOMPRESS); stream = squash_malloc (sizeof (SquashMSCompStream)); - if (SQUASH_UNLIKELY(stream == NULL)) + if (HEDLEY_UNLIKELY(stream == NULL)) return (squash_error (SQUASH_MEMORY), NULL); squash_ms_stream_init (stream, codec, stream_type, options, squash_ms_stream_destroy); @@ -106,7 +106,7 @@ squash_ms_stream_new (SquashCodec* codec, SquashStreamType stream_type, SquashOp status = ms_inflate_init (format, &(stream->mscomp)); } - if (SQUASH_UNLIKELY(status != MSCOMP_OK)) { + if (HEDLEY_UNLIKELY(status != MSCOMP_OK)) { squash_object_unref (stream); return (squash_error (squash_ms_status_to_squash_status (status)), NULL); } @@ -151,9 +151,9 @@ squash_ms_comp_flush_from_operation (SquashOperation operation) { case SQUASH_OPERATION_FINISH: return MSCOMP_FINISH; case SQUASH_OPERATION_TERMINATE: - squash_assert_unreachable (); + HEDLEY_UNREACHABLE (); } - squash_assert_unreachable(); + HEDLEY_UNREACHABLE(); } static SquashStatus @@ -215,7 +215,7 @@ squash_ms_process_stream (SquashStream* stream, SquashOperation operation) { } break; case SQUASH_OPERATION_TERMINATE: - squash_assert_unreachable (); + HEDLEY_UNREACHABLE (); break; } break; @@ -235,7 +235,7 @@ squash_ms_process_stream (SquashStream* stream, SquashOperation operation) { } break; case SQUASH_OPERATION_TERMINATE: - squash_assert_unreachable (); + HEDLEY_UNREACHABLE (); } break; } @@ -251,9 +251,9 @@ squash_ms_get_max_compressed_size (SquashCodec* codec, size_t uncompressed_size) static SquashStatus squash_ms_compress_buffer (SquashCodec* codec, size_t* compressed_size, - uint8_t compressed[SQUASH_ARRAY_PARAM(*compressed_size)], + uint8_t compressed[HEDLEY_ARRAY_PARAM(*compressed_size)], size_t uncompressed_size, - const uint8_t uncompressed[SQUASH_ARRAY_PARAM(uncompressed_size)], + const uint8_t uncompressed[HEDLEY_ARRAY_PARAM(uncompressed_size)], SquashOptions* options) { MSCompStatus status = ms_compress (squash_ms_format_from_codec (codec), uncompressed, uncompressed_size, compressed, compressed_size); @@ -263,9 +263,9 @@ squash_ms_compress_buffer (SquashCodec* codec, static SquashStatus squash_ms_decompress_buffer (SquashCodec* codec, size_t* decompressed_size, - uint8_t decompressed[SQUASH_ARRAY_PARAM(*decompressed_size)], + uint8_t decompressed[HEDLEY_ARRAY_PARAM(*decompressed_size)], size_t compressed_size, - const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_size)], + const uint8_t compressed[HEDLEY_ARRAY_PARAM(compressed_size)], SquashOptions* options) { MSCompStatus status = ms_decompress (squash_ms_format_from_codec (codec), compressed, compressed_size, decompressed, decompressed_size); @@ -276,7 +276,7 @@ SquashStatus squash_plugin_init_codec (SquashCodec* codec, SquashCodecImpl* impl) { const char* name = squash_codec_get_name (codec); - if (SQUASH_LIKELY(strcmp ("lznt1", name) == 0 || + if (HEDLEY_LIKELY(strcmp ("lznt1", name) == 0 || strcmp ("xpress", name) == 0 || strcmp ("xpress-huffman", name) == 0)) { impl->get_max_compressed_size = squash_ms_get_max_compressed_size; diff --git a/plugins/ncompress/squash-ncompress.c b/plugins/ncompress/squash-ncompress.c index 515c1bf..e2874c3 100644 --- a/plugins/ncompress/squash-ncompress.c +++ b/plugins/ncompress/squash-ncompress.c @@ -52,15 +52,15 @@ squash_ncompress_status_to_squash_status (enum CompressStatus status) { case COMPRESS_FAILED: return SQUASH_FAILED; } - squash_assert_unreachable(); + HEDLEY_UNREACHABLE(); } static SquashStatus squash_ncompress_decompress_buffer (SquashCodec* codec, size_t* decompressed_size, - uint8_t decompressed[SQUASH_ARRAY_PARAM(*decompressed_size)], + uint8_t decompressed[HEDLEY_ARRAY_PARAM(*decompressed_size)], size_t compressed_size, - const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_size)], + const uint8_t compressed[HEDLEY_ARRAY_PARAM(compressed_size)], SquashOptions* options) { enum CompressStatus res = decompress (decompressed, decompressed_size, compressed, compressed_size); @@ -70,9 +70,9 @@ squash_ncompress_decompress_buffer (SquashCodec* codec, static SquashStatus squash_ncompress_compress_buffer (SquashCodec* codec, size_t* compressed_size, - uint8_t compressed[SQUASH_ARRAY_PARAM(*compressed_size)], + uint8_t compressed[HEDLEY_ARRAY_PARAM(*compressed_size)], size_t uncompressed_size, - const uint8_t uncompressed[SQUASH_ARRAY_PARAM(uncompressed_size)], + const uint8_t uncompressed[HEDLEY_ARRAY_PARAM(uncompressed_size)], SquashOptions* options) { enum CompressStatus res = compress (compressed, compressed_size, uncompressed, uncompressed_size); @@ -83,7 +83,7 @@ SquashStatus squash_plugin_init_codec (SquashCodec* codec, SquashCodecImpl* impl) { const char* name = squash_codec_get_name (codec); - if (SQUASH_LIKELY(strcmp ("compress", name) == 0)) { + if (HEDLEY_LIKELY(strcmp ("compress", name) == 0)) { impl->get_max_compressed_size = squash_ncompress_get_max_compressed_size; impl->decompress_buffer = squash_ncompress_decompress_buffer; impl->compress_buffer = squash_ncompress_compress_buffer; diff --git a/plugins/quicklz/squash-quicklz.c b/plugins/quicklz/squash-quicklz.c index 366d470..6089dfd 100644 --- a/plugins/quicklz/squash-quicklz.c +++ b/plugins/quicklz/squash-quicklz.c @@ -49,10 +49,10 @@ squash_quicklz_get_max_compressed_size (SquashCodec* codec, size_t uncompressed_ /* We use this because qlz_size_decompressed and qlz_size_compressed can read outside the provided source buffer. */ -static bool squash_qlz_sizes(size_t source_length, const uint8_t source[SQUASH_ARRAY_PARAM(source_length)], +static bool squash_qlz_sizes(size_t source_length, const uint8_t source[HEDLEY_ARRAY_PARAM(source_length)], size_t* decompressed_size, size_t* compressed_size) { uint32_t n = (((*source) & 2) == 2) ? 4 : 1; - if (SQUASH_UNLIKELY(source_length < ((2 * n) + 1))) + if (HEDLEY_UNLIKELY(source_length < ((2 * n) + 1))) return false; if(n == 4) { @@ -69,10 +69,10 @@ static bool squash_qlz_sizes(size_t source_length, const uint8_t source[SQUASH_A static size_t squash_quicklz_get_uncompressed_size (SquashCodec* codec, size_t compressed_size, - const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_size)]) { + const uint8_t compressed[HEDLEY_ARRAY_PARAM(compressed_size)]) { size_t compressed_l, decompressed_l; - if (!SQUASH_LIKELY(squash_qlz_sizes(compressed_size, compressed, &decompressed_l, &compressed_l))) + if (!HEDLEY_LIKELY(squash_qlz_sizes(compressed_size, compressed, &decompressed_l, &compressed_l))) return (squash_error (SQUASH_BUFFER_EMPTY)), 0; return decompressed_l; @@ -81,38 +81,38 @@ squash_quicklz_get_uncompressed_size (SquashCodec* codec, static SquashStatus squash_quicklz_decompress_buffer (SquashCodec* codec, size_t* decompressed_size, - uint8_t decompressed[SQUASH_ARRAY_PARAM(*decompressed_size)], + uint8_t decompressed[HEDLEY_ARRAY_PARAM(*decompressed_size)], size_t compressed_size, - const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_size)], + const uint8_t compressed[HEDLEY_ARRAY_PARAM(compressed_size)], SquashOptions* options) { size_t decompressed_l, compressed_l; qlz_state_decompress qlz_s; - if (!SQUASH_LIKELY(squash_qlz_sizes(compressed_size, compressed, &decompressed_l, &compressed_l))) + if (!HEDLEY_LIKELY(squash_qlz_sizes(compressed_size, compressed, &decompressed_l, &compressed_l))) return squash_error (SQUASH_BUFFER_EMPTY); - if (SQUASH_UNLIKELY(compressed_size < compressed_l)) + if (HEDLEY_UNLIKELY(compressed_size < compressed_l)) return squash_error (SQUASH_BUFFER_EMPTY); - if (SQUASH_UNLIKELY(*decompressed_size < decompressed_l)) + if (HEDLEY_UNLIKELY(*decompressed_size < decompressed_l)) return squash_error (SQUASH_BUFFER_FULL); *decompressed_size = qlz_decompress ((const char*) compressed, (void*) decompressed, &qlz_s); - return SQUASH_LIKELY(decompressed_l == *decompressed_size) ? SQUASH_OK : squash_error (SQUASH_FAILED); + return HEDLEY_LIKELY(decompressed_l == *decompressed_size) ? SQUASH_OK : squash_error (SQUASH_FAILED); } static SquashStatus squash_quicklz_compress_buffer (SquashCodec* codec, size_t* compressed_size, - uint8_t compressed[SQUASH_ARRAY_PARAM(*compressed_size)], + uint8_t compressed[HEDLEY_ARRAY_PARAM(*compressed_size)], size_t uncompressed_size, - const uint8_t uncompressed[SQUASH_ARRAY_PARAM(uncompressed_size)], + const uint8_t uncompressed[HEDLEY_ARRAY_PARAM(uncompressed_size)], SquashOptions* options) { qlz_state_compress qlz_s; - if (SQUASH_UNLIKELY(*compressed_size < squash_quicklz_get_max_compressed_size (codec, uncompressed_size))) { + if (HEDLEY_UNLIKELY(*compressed_size < squash_quicklz_get_max_compressed_size (codec, uncompressed_size))) { return squash_error (SQUASH_BUFFER_FULL); } @@ -121,14 +121,14 @@ squash_quicklz_compress_buffer (SquashCodec* codec, uncompressed_size, &qlz_s); - return SQUASH_UNLIKELY(*compressed_size == 0) ? squash_error (SQUASH_FAILED) : SQUASH_OK; + return HEDLEY_UNLIKELY(*compressed_size == 0) ? squash_error (SQUASH_FAILED) : SQUASH_OK; } SquashStatus squash_plugin_init_codec (SquashCodec* codec, SquashCodecImpl* impl) { const char* name = squash_codec_get_name (codec); - if (SQUASH_LIKELY(strcmp ("quicklz", name) == 0)) { + if (HEDLEY_LIKELY(strcmp ("quicklz", name) == 0)) { impl->get_uncompressed_size = squash_quicklz_get_uncompressed_size; impl->get_max_compressed_size = squash_quicklz_get_max_compressed_size; impl->decompress_buffer = squash_quicklz_decompress_buffer; diff --git a/plugins/snappy/squash-snappy.c b/plugins/snappy/squash-snappy.c index 47ee11a..e28f0c4 100644 --- a/plugins/snappy/squash-snappy.c +++ b/plugins/snappy/squash-snappy.c @@ -49,7 +49,7 @@ squash_snappy_get_max_compressed_size (SquashCodec* codec, size_t uncompressed_l static size_t squash_snappy_get_uncompressed_size (SquashCodec* codec, size_t compressed_length, - const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_length)]) { + const uint8_t compressed[HEDLEY_ARRAY_PARAM(compressed_length)]) { size_t uncompressed_size = 0; snappy_uncompressed_length ((const char*) compressed, compressed_length, &uncompressed_size); @@ -79,9 +79,9 @@ squash_snappy_status (snappy_status status) { static SquashStatus squash_snappy_decompress_buffer (SquashCodec* codec, size_t* decompressed_length, - uint8_t decompressed[SQUASH_ARRAY_PARAM(*decompressed_length)], + uint8_t decompressed[HEDLEY_ARRAY_PARAM(*decompressed_length)], size_t compressed_length, - const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_length)], + const uint8_t compressed[HEDLEY_ARRAY_PARAM(compressed_length)], SquashOptions* options) { snappy_status e; @@ -94,9 +94,9 @@ squash_snappy_decompress_buffer (SquashCodec* codec, static SquashStatus squash_snappy_compress_buffer (SquashCodec* codec, size_t* compressed_length, - uint8_t compressed[SQUASH_ARRAY_PARAM(*compressed_length)], + uint8_t compressed[HEDLEY_ARRAY_PARAM(*compressed_length)], size_t uncompressed_length, - const uint8_t uncompressed[SQUASH_ARRAY_PARAM(uncompressed_length)], + const uint8_t uncompressed[HEDLEY_ARRAY_PARAM(uncompressed_length)], SquashOptions* options) { snappy_status e; diff --git a/plugins/wflz/squash-wflz.c b/plugins/wflz/squash-wflz.c index b09c74e..7b31a58 100644 --- a/plugins/wflz/squash-wflz.c +++ b/plugins/wflz/squash-wflz.c @@ -89,7 +89,7 @@ squash_wflz_get_max_compressed_size (SquashCodec* codec, size_t uncompressed_siz const char* codec_name = squash_codec_get_name (codec); #if UINT32_MAX < SIZE_MAX - if (SQUASH_UNLIKELY(UINT32_MAX < uncompressed_size)) + if (HEDLEY_UNLIKELY(UINT32_MAX < uncompressed_size)) return (squash_error (SQUASH_RANGE), 0); #endif @@ -98,7 +98,7 @@ squash_wflz_get_max_compressed_size (SquashCodec* codec, size_t uncompressed_siz wfLZ_GetMaxChunkCompressedSize ((uint32_t) uncompressed_size, SQUASH_WFLZ_MIN_CHUNK_SIZE); #if SIZE_MAX < UINT32_MAX - if (SQUASH_UNLIKELY(SIZE_MAX < res)) + if (HEDLEY_UNLIKELY(SIZE_MAX < res)) return (squash_error (SQUASH_RANGE)); #endif @@ -108,14 +108,14 @@ squash_wflz_get_max_compressed_size (SquashCodec* codec, size_t uncompressed_siz static size_t squash_wflz_get_uncompressed_size (SquashCodec* codec, size_t compressed_size, - const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_size)]) { + const uint8_t compressed[HEDLEY_ARRAY_PARAM(compressed_size)]) { if (compressed_size < 12) return 0; const uint32_t res = wfLZ_GetDecompressedSize (compressed); #if SIZE_MAX < UINT32_MAX - if (SQUASH_UNLIKELY(SIZE_MAX < res)) + if (HEDLEY_UNLIKELY(SIZE_MAX < res)) return (squash_error (SQUASH_RANGE), 0); #endif @@ -125,9 +125,9 @@ squash_wflz_get_uncompressed_size (SquashCodec* codec, static SquashStatus squash_wflz_compress_buffer (SquashCodec* codec, size_t* compressed_size, - uint8_t compressed[SQUASH_ARRAY_PARAM(*compressed_size)], + uint8_t compressed[HEDLEY_ARRAY_PARAM(*compressed_size)], size_t uncompressed_size, - const uint8_t uncompressed[SQUASH_ARRAY_PARAM(uncompressed_size)], + const uint8_t uncompressed[HEDLEY_ARRAY_PARAM(uncompressed_size)], SquashOptions* options) { assert (codec != NULL); @@ -136,7 +136,7 @@ squash_wflz_compress_buffer (SquashCodec* codec, const int level = squash_options_get_int_at (options, codec, SQUASH_WFLZ_OPT_LEVEL); #if UINT32_MAX < SIZE_MAX - if (SQUASH_UNLIKELY(UINT32_MAX < uncompressed_size)) + if (HEDLEY_UNLIKELY(UINT32_MAX < uncompressed_size)) return squash_error (SQUASH_RANGE); #endif @@ -163,7 +163,7 @@ squash_wflz_compress_buffer (SquashCodec* codec, } #if SIZE_MAX < UINT32_MAX - if (SQUASH_UNLIKELY(SIZE_MAX < wres)) { + if (HEDLEY_UNLIKELY(SIZE_MAX < wres)) { free (work_mem); return squash_error (SQUASH_RANGE); } @@ -173,33 +173,33 @@ squash_wflz_compress_buffer (SquashCodec* codec, free (work_mem); - return SQUASH_LIKELY(*compressed_size > 0) ? SQUASH_OK : squash_error (SQUASH_FAILED); + return HEDLEY_LIKELY(*compressed_size > 0) ? SQUASH_OK : squash_error (SQUASH_FAILED); } static SquashStatus squash_wflz_decompress_buffer (SquashCodec* codec, size_t* decompressed_size, - uint8_t decompressed[SQUASH_ARRAY_PARAM(*decompressed_size)], + uint8_t decompressed[HEDLEY_ARRAY_PARAM(*decompressed_size)], size_t compressed_size, - const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_size)], + const uint8_t compressed[HEDLEY_ARRAY_PARAM(compressed_size)], SquashOptions* options) { const char* codec_name = squash_codec_get_name (codec); uint32_t decompressed_s; - if (SQUASH_UNLIKELY(compressed_size < 12)) + if (HEDLEY_UNLIKELY(compressed_size < 12)) return squash_error (SQUASH_BUFFER_EMPTY); decompressed_s = wfLZ_GetDecompressedSize (compressed); #if SIZE_MAX < UINT32_MAX - if (SQUASH_UNLIKELY(SIZE_MAX < decompressed_s)) + if (HEDLEY_UNLIKELY(SIZE_MAX < decompressed_s)) return squash_error (SQUASH_RANGE); #endif - if (SQUASH_UNLIKELY(decompressed_s == 0)) + if (HEDLEY_UNLIKELY(decompressed_s == 0)) return squash_error (SQUASH_INVALID_BUFFER); - if (SQUASH_UNLIKELY(decompressed_s > *decompressed_size)) + if (HEDLEY_UNLIKELY(decompressed_s > *decompressed_size)) return squash_error (SQUASH_BUFFER_FULL); if (codec_name[4] == '\0') { @@ -212,7 +212,7 @@ squash_wflz_decompress_buffer (SquashCodec* codec, while ( (compressed_block = wfLZ_ChunkDecompressLoop ((uint8_t*) compressed, &chunk)) != NULL ) { const uint32_t chunk_size = wfLZ_GetDecompressedSize (compressed_block); - if (SQUASH_UNLIKELY((dest + chunk_size) > (decompressed + *decompressed_size))) + if (HEDLEY_UNLIKELY((dest + chunk_size) > (decompressed + *decompressed_size))) return squash_error (SQUASH_BUFFER_FULL); wfLZ_Decompress (compressed_block, dest); @@ -229,7 +229,7 @@ SquashStatus squash_plugin_init_codec (SquashCodec* codec, SquashCodecImpl* impl) { const char* name = squash_codec_get_name (codec); - if (SQUASH_LIKELY(strcmp ("wflz", name) == 0 || + if (HEDLEY_LIKELY(strcmp ("wflz", name) == 0 || strcmp ("wflz-chunked", name) == 0)) { impl->options = squash_wflz_options; impl->get_uncompressed_size = squash_wflz_get_uncompressed_size; diff --git a/plugins/yalz77/squash-yalz77.cpp b/plugins/yalz77/squash-yalz77.cpp index cfbdb90..fa7fb51 100644 --- a/plugins/yalz77/squash-yalz77.cpp +++ b/plugins/yalz77/squash-yalz77.cpp @@ -59,9 +59,9 @@ squash_yalz77_get_max_compressed_size (SquashCodec* codec, size_t uncompressed_s static SquashStatus squash_yalz77_compress_buffer (SquashCodec* codec, size_t* compressed_size, - uint8_t compressed[SQUASH_ARRAY_PARAM(*compressed_size)], + uint8_t compressed[HEDLEY_ARRAY_PARAM(*compressed_size)], size_t uncompressed_size, - const uint8_t uncompressed[SQUASH_ARRAY_PARAM(uncompressed_size)], + const uint8_t uncompressed[HEDLEY_ARRAY_PARAM(uncompressed_size)], SquashOptions* options) { const size_t searchlen = squash_options_get_size_at (options, codec, SQUASH_YALZ77_OPT_SEARCH_LENGTH); @@ -71,7 +71,7 @@ squash_yalz77_compress_buffer (SquashCodec* codec, lz77::compress_t compress(searchlen, blocksize); std::string res = compress.feed(uncompressed, uncompressed + uncompressed_size); - if (SQUASH_UNLIKELY(res.size() > *compressed_size)) + if (HEDLEY_UNLIKELY(res.size() > *compressed_size)) return squash_error (SQUASH_BUFFER_FULL); memcpy(compressed, res.c_str(), res.size()); @@ -88,9 +88,9 @@ squash_yalz77_compress_buffer (SquashCodec* codec, static SquashStatus squash_yalz77_decompress_buffer (SquashCodec* codec, size_t* decompressed_size, - uint8_t decompressed[SQUASH_ARRAY_PARAM(*decompressed_size)], + uint8_t decompressed[HEDLEY_ARRAY_PARAM(*decompressed_size)], size_t compressed_size, - const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_size)], + const uint8_t compressed[HEDLEY_ARRAY_PARAM(compressed_size)], SquashOptions* options) { try { lz77::decompress_t decompress(*decompressed_size); @@ -124,7 +124,7 @@ extern "C" SquashStatus squash_plugin_init_codec (SquashCodec* codec, SquashCodecImpl* impl) { const char* name = squash_codec_get_name (codec); - if (SQUASH_LIKELY(strcmp ("yalz77", name) == 0)) { + if (HEDLEY_LIKELY(strcmp ("yalz77", name) == 0)) { impl->options = squash_yalz77_options; impl->get_max_compressed_size = squash_yalz77_get_max_compressed_size; impl->decompress_buffer = squash_yalz77_decompress_buffer; diff --git a/plugins/zlib-ng/squash-zlib-ng.c b/plugins/zlib-ng/squash-zlib-ng.c index 1b9e4ab..3b53769 100644 --- a/plugins/zlib-ng/squash-zlib-ng.c +++ b/plugins/zlib-ng/squash-zlib-ng.c @@ -123,7 +123,7 @@ static SquashZlibType squash_zlib_codec_to_type (SquashCodec* codec) { } else if (strcmp ("deflate", name) == 0) { return SQUASH_ZLIB_TYPE_DEFLATE; } else { - squash_assert_unreachable(); + HEDLEY_UNREACHABLE(); } } @@ -186,7 +186,7 @@ squash_zlib_stream_new (SquashCodec* codec, SquashStreamType stream_type, Squash } else if (stream_type == SQUASH_STREAM_DECOMPRESS) { zlib_e = inflateInit2 (&(stream->stream), window_bits); } else { - squash_assert_unreachable(); + HEDLEY_UNREACHABLE(); } if (zlib_e != Z_OK) { @@ -223,11 +223,11 @@ squash_operation_to_zlib (SquashOperation operation) { case SQUASH_OPERATION_FINISH: return Z_FINISH; case SQUASH_OPERATION_TERMINATE: - squash_assert_unreachable(); + HEDLEY_UNREACHABLE(); break; } - squash_assert_unreachable (); + HEDLEY_UNREACHABLE (); } static SquashStatus @@ -241,8 +241,8 @@ squash_zlib_process_stream (SquashStream* stream, SquashOperation operation) { zlib_stream = &(((SquashZlibStream*) stream)->stream); #if UINT_MAX < SIZE_MAX - if (SQUASH_UNLIKELY(UINT_MAX < stream->avail_in) || - SQUASH_UNLIKELY(UINT_MAX < stream->avail_out)) + if (HEDLEY_UNLIKELY(UINT_MAX < stream->avail_in) || + HEDLEY_UNLIKELY(UINT_MAX < stream->avail_out)) return squash_error (SQUASH_RANGE); #endif SQUASH_ZLIB_STREAM_COPY_TO_ZLIB_STREAM(stream, zlib_stream); @@ -254,8 +254,8 @@ squash_zlib_process_stream (SquashStream* stream, SquashOperation operation) { } #if SIZE_MAX < UINT_MAX - if (SQUASH_UNLIKELY(SIZE_MAX < zlib_stream->avail_out) || - SQUASH_UNLIKELY(SIZE_MAX < zlib_stream->avail_out)) + if (HEDLEY_UNLIKELY(SIZE_MAX < zlib_stream->avail_out) || + HEDLEY_UNLIKELY(SIZE_MAX < zlib_stream->avail_out)) return squash_error (SQUASH_RANGE); #endif SQUASH_ZLIB_STREAM_COPY_FROM_ZLIB_STREAM(stream, zlib_stream); @@ -271,7 +271,7 @@ squash_zlib_process_stream (SquashStream* stream, SquashOperation operation) { res = SQUASH_PROCESSING; break; case SQUASH_OPERATION_TERMINATE: - squash_assert_unreachable (); + HEDLEY_UNREACHABLE (); break; } break; @@ -293,7 +293,7 @@ squash_zlib_process_stream (SquashStream* stream, SquashOperation operation) { } break; case SQUASH_OPERATION_TERMINATE: - squash_assert_unreachable (); + HEDLEY_UNREACHABLE (); break; } break; @@ -316,7 +316,7 @@ squash_zlib_get_max_compressed_size (SquashCodec* codec, size_t uncompressed_siz SquashZlibType type = squash_zlib_codec_to_type (codec); #if SIZE_MAX < ULONG_MAX - if (SQUASH_UNLIKELY(uncompressed_size > ULONG_MAX)) { + if (HEDLEY_UNLIKELY(uncompressed_size > ULONG_MAX)) { squash_error (SQUASH_BUFFER_TOO_LARGE); return 0; } diff --git a/plugins/zlib/squash-zlib.c b/plugins/zlib/squash-zlib.c index 1b9e4ab..3b53769 100644 --- a/plugins/zlib/squash-zlib.c +++ b/plugins/zlib/squash-zlib.c @@ -123,7 +123,7 @@ static SquashZlibType squash_zlib_codec_to_type (SquashCodec* codec) { } else if (strcmp ("deflate", name) == 0) { return SQUASH_ZLIB_TYPE_DEFLATE; } else { - squash_assert_unreachable(); + HEDLEY_UNREACHABLE(); } } @@ -186,7 +186,7 @@ squash_zlib_stream_new (SquashCodec* codec, SquashStreamType stream_type, Squash } else if (stream_type == SQUASH_STREAM_DECOMPRESS) { zlib_e = inflateInit2 (&(stream->stream), window_bits); } else { - squash_assert_unreachable(); + HEDLEY_UNREACHABLE(); } if (zlib_e != Z_OK) { @@ -223,11 +223,11 @@ squash_operation_to_zlib (SquashOperation operation) { case SQUASH_OPERATION_FINISH: return Z_FINISH; case SQUASH_OPERATION_TERMINATE: - squash_assert_unreachable(); + HEDLEY_UNREACHABLE(); break; } - squash_assert_unreachable (); + HEDLEY_UNREACHABLE (); } static SquashStatus @@ -241,8 +241,8 @@ squash_zlib_process_stream (SquashStream* stream, SquashOperation operation) { zlib_stream = &(((SquashZlibStream*) stream)->stream); #if UINT_MAX < SIZE_MAX - if (SQUASH_UNLIKELY(UINT_MAX < stream->avail_in) || - SQUASH_UNLIKELY(UINT_MAX < stream->avail_out)) + if (HEDLEY_UNLIKELY(UINT_MAX < stream->avail_in) || + HEDLEY_UNLIKELY(UINT_MAX < stream->avail_out)) return squash_error (SQUASH_RANGE); #endif SQUASH_ZLIB_STREAM_COPY_TO_ZLIB_STREAM(stream, zlib_stream); @@ -254,8 +254,8 @@ squash_zlib_process_stream (SquashStream* stream, SquashOperation operation) { } #if SIZE_MAX < UINT_MAX - if (SQUASH_UNLIKELY(SIZE_MAX < zlib_stream->avail_out) || - SQUASH_UNLIKELY(SIZE_MAX < zlib_stream->avail_out)) + if (HEDLEY_UNLIKELY(SIZE_MAX < zlib_stream->avail_out) || + HEDLEY_UNLIKELY(SIZE_MAX < zlib_stream->avail_out)) return squash_error (SQUASH_RANGE); #endif SQUASH_ZLIB_STREAM_COPY_FROM_ZLIB_STREAM(stream, zlib_stream); @@ -271,7 +271,7 @@ squash_zlib_process_stream (SquashStream* stream, SquashOperation operation) { res = SQUASH_PROCESSING; break; case SQUASH_OPERATION_TERMINATE: - squash_assert_unreachable (); + HEDLEY_UNREACHABLE (); break; } break; @@ -293,7 +293,7 @@ squash_zlib_process_stream (SquashStream* stream, SquashOperation operation) { } break; case SQUASH_OPERATION_TERMINATE: - squash_assert_unreachable (); + HEDLEY_UNREACHABLE (); break; } break; @@ -316,7 +316,7 @@ squash_zlib_get_max_compressed_size (SquashCodec* codec, size_t uncompressed_siz SquashZlibType type = squash_zlib_codec_to_type (codec); #if SIZE_MAX < ULONG_MAX - if (SQUASH_UNLIKELY(uncompressed_size > ULONG_MAX)) { + if (HEDLEY_UNLIKELY(uncompressed_size > ULONG_MAX)) { squash_error (SQUASH_BUFFER_TOO_LARGE); return 0; } diff --git a/plugins/zling/squash-zling.cpp b/plugins/zling/squash-zling.cpp index 2c916d2..23194cd 100644 --- a/plugins/zling/squash-zling.cpp +++ b/plugins/zling/squash-zling.cpp @@ -175,7 +175,7 @@ squash_zling_splice (SquashCodec* codec, if (zres == 0) return SQUASH_OK; - else if (SQUASH_LIKELY(stream.last_res < 0)) + else if (HEDLEY_LIKELY(stream.last_res < 0)) return stream.last_res; else return squash_error (SQUASH_FAILED); @@ -187,7 +187,7 @@ squash_zling_splice (SquashCodec* codec, return squash_error (SQUASH_FAILED); } - squash_assert_unreachable (); + HEDLEY_UNREACHABLE (); } static size_t @@ -210,7 +210,7 @@ extern "C" SquashStatus squash_plugin_init_codec (SquashCodec* codec, SquashCodecImpl* impl) { const char* name = squash_codec_get_name (codec); - if (SQUASH_LIKELY(strcmp ("zling", name) == 0)) { + if (HEDLEY_LIKELY(strcmp ("zling", name) == 0)) { impl->options = squash_zling_options; impl->splice = squash_zling_splice; impl->get_max_compressed_size = squash_zling_get_max_compressed_size; diff --git a/plugins/zpaq/squash-zpaq.cpp b/plugins/zpaq/squash-zpaq.cpp index 02258a9..7bab20c 100644 --- a/plugins/zpaq/squash-zpaq.cpp +++ b/plugins/zpaq/squash-zpaq.cpp @@ -82,7 +82,7 @@ __attribute__((__noreturn__)) #endif void libzpaq::error (const char* msg) { - if (SQUASH_UNLIKELY(strcmp (msg, "Out of memory") == 0)) + if (HEDLEY_UNLIKELY(strcmp (msg, "Out of memory") == 0)) throw squash_error (SQUASH_MEMORY); else throw squash_error (SQUASH_FAILED); diff --git a/plugins/zstd/squash-zstd.c b/plugins/zstd/squash-zstd.c index 5613b59..d607d14 100644 --- a/plugins/zstd/squash-zstd.c +++ b/plugins/zstd/squash-zstd.c @@ -88,15 +88,15 @@ squash_zstd_status_from_zstd_error (size_t res) { return squash_error (SQUASH_FAILED); } - squash_assert_unreachable (); + HEDLEY_UNREACHABLE (); } static SquashStatus squash_zstd_decompress_buffer (SquashCodec* codec, size_t* decompressed_size, - uint8_t decompressed[SQUASH_ARRAY_PARAM(*decompressed_size)], + uint8_t decompressed[HEDLEY_ARRAY_PARAM(*decompressed_size)], size_t compressed_size, - const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_size)], + const uint8_t compressed[HEDLEY_ARRAY_PARAM(compressed_size)], SquashOptions* options) { *decompressed_size = ZSTD_decompress (decompressed, *decompressed_size, compressed, compressed_size); @@ -106,9 +106,9 @@ squash_zstd_decompress_buffer (SquashCodec* codec, static SquashStatus squash_zstd_compress_buffer (SquashCodec* codec, size_t* compressed_size, - uint8_t compressed[SQUASH_ARRAY_PARAM(*compressed_size)], + uint8_t compressed[HEDLEY_ARRAY_PARAM(*compressed_size)], size_t uncompressed_size, - const uint8_t uncompressed[SQUASH_ARRAY_PARAM(uncompressed_size)], + const uint8_t uncompressed[HEDLEY_ARRAY_PARAM(uncompressed_size)], SquashOptions* options) { const int level = squash_options_get_int_at (options, codec, SQUASH_ZSTD_OPT_LEVEL); @@ -121,7 +121,7 @@ SquashStatus squash_plugin_init_codec (SquashCodec* codec, SquashCodecImpl* impl) { const char* name = squash_codec_get_name (codec); - if (SQUASH_LIKELY(strcmp ("zstd", name) == 0)) { + if (HEDLEY_LIKELY(strcmp ("zstd", name) == 0)) { impl->options = squash_zstd_options; impl->get_max_compressed_size = squash_zstd_get_max_compressed_size; impl->decompress_buffer = squash_zstd_decompress_buffer; diff --git a/squash/CMakeLists.txt b/squash/CMakeLists.txt index 11607f8..491d2cd 100644 --- a/squash/CMakeLists.txt +++ b/squash/CMakeLists.txt @@ -143,6 +143,9 @@ install(FILES squash-types.h "${CMAKE_CURRENT_BINARY_DIR}/squash-version.h" DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR}/squash-${SQUASH_VERSION_API}/squash) +install(FILES + hedley/hedley.h + DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR}/squash-${SQUASH_VERSION_API}/squash/hedley) configure_file ( "${CMAKE_CURRENT_SOURCE_DIR}/SquashConfig.cmake.in" diff --git a/squash/hedley b/squash/hedley new file mode 160000 index 0000000..e0580df --- /dev/null +++ b/squash/hedley @@ -0,0 +1 @@ +Subproject commit e0580df2fbdc3bf00e209c8ffaa14a4bae1b6264 diff --git a/squash/squash-buffer-internal.h b/squash/squash-buffer-internal.h index 4a50d98..ab48aa8 100644 --- a/squash/squash-buffer-internal.h +++ b/squash/squash-buffer-internal.h @@ -32,29 +32,29 @@ #error "This is internal API; you cannot use it." #endif -SQUASH_BEGIN_DECLS +HEDLEY_BEGIN_C_DECLS SQUASH_INTERNAL SquashBuffer* squash_buffer_new (size_t preallocated_len); -SQUASH_NONNULL(1) SQUASH_INTERNAL -bool squash_buffer_append (SquashBuffer* buffer, size_t data_size, const uint8_t data[SQUASH_ARRAY_PARAM(data_size)]); -SQUASH_NONNULL(1) SQUASH_INTERNAL +HEDLEY_NON_NULL(1) SQUASH_INTERNAL +bool squash_buffer_append (SquashBuffer* buffer, size_t data_size, const uint8_t data[HEDLEY_ARRAY_PARAM(data_size)]); +HEDLEY_NON_NULL(1) SQUASH_INTERNAL bool squash_buffer_append_c (SquashBuffer* buffer, char c); -SQUASH_NONNULL(1) SQUASH_INTERNAL +HEDLEY_NON_NULL(1) SQUASH_INTERNAL void squash_buffer_clear (SquashBuffer* buffer); SQUASH_INTERNAL void squash_buffer_free (SquashBuffer* buffer); -SQUASH_NONNULL(1) SQUASH_INTERNAL +HEDLEY_NON_NULL(1) SQUASH_INTERNAL bool squash_buffer_set_size (SquashBuffer* buffer, size_t size); -SQUASH_NONNULL(1) SQUASH_INTERNAL +HEDLEY_NON_NULL(1) SQUASH_INTERNAL void squash_buffer_steal (SquashBuffer* buffer, size_t data_size, size_t data_allocated, - uint8_t data[SQUASH_ARRAY_PARAM(data_allocated)]); -SQUASH_NONNULL(1) SQUASH_INTERNAL + uint8_t data[HEDLEY_ARRAY_PARAM(data_allocated)]); +HEDLEY_NON_NULL(1) SQUASH_INTERNAL uint8_t* squash_buffer_release (SquashBuffer* buffer, size_t* size); -SQUASH_END_DECLS +HEDLEY_END_C_DECLS #endif /* SQUASH_SLIST_INTERNAL_H */ diff --git a/squash/squash-buffer-stream-internal.h b/squash/squash-buffer-stream-internal.h index d08d3a4..dac0abf 100644 --- a/squash/squash-buffer-stream-internal.h +++ b/squash/squash-buffer-stream-internal.h @@ -32,7 +32,7 @@ #error "This is internal API; you cannot use it." #endif -SQUASH_BEGIN_DECLS +HEDLEY_BEGIN_C_DECLS #ifndef SQUASH_BUFFER_STREAM_BUFFER_SIZE # define SQUASH_BUFFER_STREAM_BUFFER_SIZE (4096 - sizeof (SquashSList)) @@ -51,13 +51,13 @@ typedef struct SquashBufferStream_ { size_t output_pos; } SquashBufferStream; -SQUASH_NONNULL(1) SQUASH_INTERNAL +HEDLEY_NON_NULL(1) SQUASH_INTERNAL SquashBufferStream* squash_buffer_stream_new (SquashCodec* codec, SquashStreamType stream_type, SquashOptions* options); -SQUASH_NONNULL(1) SQUASH_INTERNAL +HEDLEY_NON_NULL(1) SQUASH_INTERNAL SquashStatus squash_buffer_stream_process (SquashBufferStream* stream); -SQUASH_NONNULL(1) SQUASH_INTERNAL +HEDLEY_NON_NULL(1) SQUASH_INTERNAL SquashStatus squash_buffer_stream_finish (SquashBufferStream* stream); -SQUASH_END_DECLS +HEDLEY_END_C_DECLS #endif /* SQUASH_BUFFER_STREAM_INTERNAL_H */ diff --git a/squash/squash-buffer-stream.c b/squash/squash-buffer-stream.c index b359e2d..6eb4558 100644 --- a/squash/squash-buffer-stream.c +++ b/squash/squash-buffer-stream.c @@ -77,7 +77,7 @@ squash_buffer_stream_process (SquashBufferStream* stream) { return SQUASH_OK; const bool s = squash_buffer_append (stream->input, stream->base_object.avail_in, stream->base_object.next_in); - if (SQUASH_LIKELY(s)) { + if (HEDLEY_LIKELY(s)) { stream->base_object.next_in += stream->base_object.avail_in; stream->base_object.avail_in = 0; } else { @@ -95,7 +95,7 @@ squash_buffer_stream_finish (SquashBufferStream* stream) { SquashBuffer* input = stream->input; SquashBuffer* output = stream->output; - if (SQUASH_UNLIKELY(input->size == 0)) + if (HEDLEY_UNLIKELY(input->size == 0)) return squash_error (SQUASH_FAILED); /* Squash should handle making sure process is called until the @@ -114,7 +114,7 @@ squash_buffer_stream_finish (SquashBufferStream* stream) { contents of the compressed data, so write directly to it. */ res = squash_codec_compress_with_options(codec, &compressed_size, s->next_out, input->size, input->data, s->options); - if (SQUASH_UNLIKELY(res != SQUASH_OK)) + if (HEDLEY_UNLIKELY(res != SQUASH_OK)) return res; s->next_out += compressed_size; @@ -124,11 +124,11 @@ squash_buffer_stream_finish (SquashBufferStream* stream) { } else { /* Write the compressed data into an internal buffer. */ stream->output = output = squash_buffer_new (compressed_size); - if (SQUASH_UNLIKELY(output == NULL)) + if (HEDLEY_UNLIKELY(output == NULL)) return squash_error (SQUASH_MEMORY); res = squash_codec_compress_with_options (codec, &compressed_size, output->data, input->size, input->data, s->options); - if (SQUASH_UNLIKELY(res != SQUASH_OK)) + if (HEDLEY_UNLIKELY(res != SQUASH_OK)) return res; output->size = compressed_size; @@ -140,7 +140,7 @@ squash_buffer_stream_finish (SquashBufferStream* stream) { if (s->avail_out >= decompressed_size) { /* And there is enough room in next_out to hold it, so write directly to next_out */ res = squash_codec_decompress_with_options (codec, &decompressed_size, s->next_out, input->size, input->data, s->options); - if (SQUASH_UNLIKELY(res != SQUASH_OK)) + if (HEDLEY_UNLIKELY(res != SQUASH_OK)) return res; s->next_out += decompressed_size; @@ -150,11 +150,11 @@ squash_buffer_stream_finish (SquashBufferStream* stream) { } else { /* But there isn't enough room in next_out, so we have to buffer. */ stream->output = output = squash_buffer_new (decompressed_size); - if (SQUASH_UNLIKELY(output == NULL)) + if (HEDLEY_UNLIKELY(output == NULL)) return squash_error (SQUASH_MEMORY); res = squash_codec_decompress_with_options (codec, &decompressed_size, output->data, input->size, input->data, s->options); - if (SQUASH_UNLIKELY(res != SQUASH_OK)) + if (HEDLEY_UNLIKELY(res != SQUASH_OK)) return res; output->size = decompressed_size; @@ -176,11 +176,11 @@ squash_buffer_stream_finish (SquashBufferStream* stream) { } stream->output = output = squash_buffer_new (0); - if (SQUASH_UNLIKELY(output == NULL)) + if (HEDLEY_UNLIKELY(output == NULL)) return squash_error (SQUASH_MEMORY); res = squash_codec_decompress_to_buffer(codec, output, input->size, input->data, s->options); - if (SQUASH_UNLIKELY(res != SQUASH_OK)) + if (HEDLEY_UNLIKELY(res != SQUASH_OK)) return res; } } @@ -190,7 +190,7 @@ squash_buffer_stream_finish (SquashBufferStream* stream) { const size_t remaining = output->size - stream->output_pos; const size_t cp_size = (remaining < s->avail_out) ? remaining : s->avail_out; - if (SQUASH_LIKELY(cp_size != 0)) { + if (HEDLEY_LIKELY(cp_size != 0)) { memcpy (s->next_out, output->data + stream->output_pos, cp_size); s->next_out += cp_size; s->avail_out -= cp_size; diff --git a/squash/squash-buffer.c b/squash/squash-buffer.c index 907eb45..ccf840b 100644 --- a/squash/squash-buffer.c +++ b/squash/squash-buffer.c @@ -50,7 +50,7 @@ squash_buffer_ensure_allocation (SquashBuffer* buffer, size_t allocation) { if (allocation > buffer->allocated) { const size_t next_allocation = squash_buffer_npot_page (allocation); /* To catch very very large requests */ - if (SQUASH_LIKELY(next_allocation > allocation)) + if (HEDLEY_LIKELY(next_allocation > allocation)) allocation = next_allocation; uint8_t* mem = (uint8_t*) squash_realloc (buffer->data, allocation); if (mem == NULL) @@ -73,14 +73,14 @@ squash_buffer_ensure_allocation (SquashBuffer* buffer, size_t allocation) { SquashBuffer* squash_buffer_new (size_t preallocated_len) { SquashBuffer* buffer = (SquashBuffer*) squash_malloc (sizeof (SquashBuffer)); - if (SQUASH_UNLIKELY(buffer == NULL)) + if (HEDLEY_UNLIKELY(buffer == NULL)) return NULL; buffer->data = NULL; buffer->size = 0; buffer->allocated = 0; const bool allocated = squash_buffer_ensure_allocation (buffer, preallocated_len); - if (SQUASH_UNLIKELY(!allocated)) + if (HEDLEY_UNLIKELY(!allocated)) return (free (buffer), NULL); return buffer; @@ -110,7 +110,7 @@ squash_buffer_clear (SquashBuffer* buffer) { } bool -squash_buffer_append (SquashBuffer* buffer, size_t data_size, const uint8_t data[SQUASH_ARRAY_PARAM(data_size)]) { +squash_buffer_append (SquashBuffer* buffer, size_t data_size, const uint8_t data[HEDLEY_ARRAY_PARAM(data_size)]) { assert (buffer != NULL); if (data_size == 0) @@ -158,7 +158,7 @@ void squash_buffer_steal (SquashBuffer* buffer, size_t data_size, size_t data_allocated, - uint8_t data[SQUASH_ARRAY_PARAM(data_allocated)]) { + uint8_t data[HEDLEY_ARRAY_PARAM(data_allocated)]) { squash_buffer_clear (buffer); buffer->data = data; diff --git a/squash/squash-charset-internal.h b/squash/squash-charset-internal.h index 688393c..d89fa19 100644 --- a/squash/squash-charset-internal.h +++ b/squash/squash-charset-internal.h @@ -34,28 +34,28 @@ #include -SQUASH_BEGIN_DECLS +HEDLEY_BEGIN_C_DECLS SQUASH_INTERNAL const char* squash_charset_get_locale (void); SQUASH_INTERNAL const char* squash_charset_get_wide (void); -SQUASH_NONNULL(2, 3, 5, 6) SQUASH_INTERNAL +HEDLEY_NON_NULL(2, 3, 5, 6) SQUASH_INTERNAL bool squash_charset_convert (size_t* output_size, char** output, const char* output_charset, size_t input_size, const char* input, const char* input_charset); -SQUASH_NONNULL(1) SQUASH_INTERNAL +HEDLEY_NON_NULL(1) SQUASH_INTERNAL char* squash_charset_utf8_to_locale (const char* input); -SQUASH_NONNULL(1) SQUASH_INTERNAL +HEDLEY_NON_NULL(1) SQUASH_INTERNAL char* squash_charset_locale_to_utf8 (const char* input); -SQUASH_NONNULL(1) SQUASH_INTERNAL +HEDLEY_NON_NULL(1) SQUASH_INTERNAL wchar_t* squash_charset_locale_to_wide (const char* input); -SQUASH_NONNULL(1) SQUASH_INTERNAL +HEDLEY_NON_NULL(1) SQUASH_INTERNAL char* squash_charset_wide_to_locale (const wchar_t* input); -SQUASH_NONNULL(1) SQUASH_INTERNAL +HEDLEY_NON_NULL(1) SQUASH_INTERNAL char* squash_charset_wide_to_utf8 (const wchar_t* input); -SQUASH_NONNULL(1) SQUASH_INTERNAL +HEDLEY_NON_NULL(1) SQUASH_INTERNAL wchar_t* squash_charset_utf8_to_wide (const char* input); -SQUASH_END_DECLS +HEDLEY_END_C_DECLS #endif /* SQUASH_CHARSET_INTERNAL_H */ diff --git a/squash/squash-codec-internal.h b/squash/squash-codec-internal.h index d1f151d..4ce79b7 100644 --- a/squash/squash-codec-internal.h +++ b/squash/squash-codec-internal.h @@ -32,30 +32,30 @@ #error "This is internal API; you cannot use it." #endif -SQUASH_BEGIN_DECLS +HEDLEY_BEGIN_C_DECLS SQUASH_INTERNAL SquashCodec* squash_codec_new (SquashPlugin* plugin, const char* name); -SQUASH_NONNULL(1) SQUASH_INTERNAL +HEDLEY_NON_NULL(1) SQUASH_INTERNAL void squash_codec_set_extension (SquashCodec* codec, const char* extension); -SQUASH_NONNULL(1) SQUASH_INTERNAL +HEDLEY_NON_NULL(1) SQUASH_INTERNAL void squash_codec_set_priority (SquashCodec* codec, unsigned int priority); -SQUASH_NONNULL(1, 2) SQUASH_INTERNAL +HEDLEY_NON_NULL(1, 2) SQUASH_INTERNAL int squash_codec_compare (SquashCodec* a, SquashCodec* b); -SQUASH_NONNULL(1, 2) SQUASH_INTERNAL +HEDLEY_NON_NULL(1, 2) SQUASH_INTERNAL int squash_codec_extension_compare (SquashCodec* a, SquashCodec* b); -SQUASH_NONNULL(1) SQUASH_INTERNAL +HEDLEY_NON_NULL(1) SQUASH_INTERNAL SquashCodecImpl* squash_codec_get_impl (SquashCodec* codec); -SQUASH_NONNULL(1, 2, 4) SQUASH_INTERNAL +HEDLEY_NON_NULL(1, 2, 4) SQUASH_INTERNAL SquashStatus squash_codec_decompress_to_buffer (SquashCodec* codec, SquashBuffer* decompressed, size_t compressed_size, - uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_size)], + uint8_t compressed[HEDLEY_ARRAY_PARAM(compressed_size)], SquashOptions* options); SQUASH_TREE_PROTOTYPES(SquashCodec_, tree) SQUASH_TREE_DEFINE(SquashCodec_, tree) -SQUASH_END_DECLS +HEDLEY_END_C_DECLS #endif /* SQUASH_CODEC_INTERNAL_H */ diff --git a/squash/squash-codec.c b/squash/squash-codec.c index a49c4ea..3a55ade 100644 --- a/squash/squash-codec.c +++ b/squash/squash-codec.c @@ -514,7 +514,7 @@ squash_size_varuint64 (const uint64_t value) { size_t squash_codec_get_uncompressed_size (SquashCodec* codec, size_t compressed_size, - const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_size)]) { + const uint8_t compressed[HEDLEY_ARRAY_PARAM(compressed_size)]) { SquashCodecImpl* impl = NULL; assert (codec != NULL); @@ -530,7 +530,7 @@ squash_codec_get_uncompressed_size (SquashCodec* codec, uint64_t v = 0; squash_read_varuint64 (compressed, compressed_size, &v); #if SIZE_MAX < UINT64_MAX - if (SQUASH_UNLIKELY(SIZE_MAX < v)) + if (HEDLEY_UNLIKELY(SIZE_MAX < v)) return (squash_error (SQUASH_RANGE), 0); #endif return (size_t) v; @@ -642,7 +642,7 @@ struct SquashBufferSpliceData { static SquashStatus squash_buffer_splice_read (size_t* data_size, - uint8_t data[SQUASH_ARRAY_PARAM(*data_size)], + uint8_t data[HEDLEY_ARRAY_PARAM(*data_size)], void* user_data) { struct SquashBufferSpliceData* ctx = (struct SquashBufferSpliceData*) user_data; @@ -664,7 +664,7 @@ squash_buffer_splice_read (size_t* data_size, static SquashStatus squash_buffer_splice_write (size_t* data_size, - const uint8_t data[SQUASH_ARRAY_PARAM(*data_size)], + const uint8_t data[HEDLEY_ARRAY_PARAM(*data_size)], void* user_data) { struct SquashBufferSpliceData* ctx = (struct SquashBufferSpliceData*) user_data; @@ -691,9 +691,9 @@ static SquashStatus squash_buffer_splice (SquashCodec* codec, SquashStreamType stream_type, size_t* output_size, - uint8_t output[SQUASH_ARRAY_PARAM(*output_size)], + uint8_t output[HEDLEY_ARRAY_PARAM(*output_size)], size_t input_size, - const uint8_t input[SQUASH_ARRAY_PARAM(input_size)], + const uint8_t input[HEDLEY_ARRAY_PARAM(input_size)], SquashOptions* options) { assert (codec != NULL); assert (output_size != NULL); @@ -729,9 +729,9 @@ squash_buffer_splice (SquashCodec* codec, SquashStatus squash_codec_compress_with_options (SquashCodec* codec, size_t* compressed_size, - uint8_t compressed[SQUASH_ARRAY_PARAM(*compressed_size)], + uint8_t compressed[HEDLEY_ARRAY_PARAM(*compressed_size)], size_t uncompressed_size, - const uint8_t uncompressed[SQUASH_ARRAY_PARAM(uncompressed_size)], + const uint8_t uncompressed[HEDLEY_ARRAY_PARAM(uncompressed_size)], SquashOptions* options) { SquashStatus res = SQUASH_OK; SquashCodecImpl* impl = NULL; @@ -744,12 +744,12 @@ squash_codec_compress_with_options (SquashCodec* codec, squash_object_ref (options); impl = squash_codec_get_impl (codec); - if (SQUASH_UNLIKELY(impl == NULL)) { + if (HEDLEY_UNLIKELY(impl == NULL)) { res = squash_error (SQUASH_UNABLE_TO_LOAD); goto cleanup; } - if (SQUASH_UNLIKELY(compressed == uncompressed)) { + if (HEDLEY_UNLIKELY(compressed == uncompressed)) { res = squash_error (SQUASH_INVALID_BUFFER); goto cleanup; } @@ -762,7 +762,7 @@ squash_codec_compress_with_options (SquashCodec* codec, if (impl->info & SQUASH_CODEC_INFO_WRAP_SIZE) { const size_t encoded_size_length = squash_write_varuint64 (compressed, *compressed_size, uncompressed_size); - if (SQUASH_UNLIKELY(encoded_size_length == 0)) { + if (HEDLEY_UNLIKELY(encoded_size_length == 0)) { res = squash_error (SQUASH_BUFFER_FULL); goto cleanup; } @@ -793,7 +793,7 @@ squash_codec_compress_with_options (SquashCodec* codec, options); } else { uint8_t* tmp_buf = squash_malloc (internal_max_compressed_size); - if (SQUASH_UNLIKELY(tmp_buf == NULL)) { + if (HEDLEY_UNLIKELY(tmp_buf == NULL)) { res = squash_error (SQUASH_MEMORY); } else { size_t tmp_buf_size = internal_max_compressed_size; @@ -803,7 +803,7 @@ squash_codec_compress_with_options (SquashCodec* codec, uncompressed_size, uncompressed, options); - if (SQUASH_LIKELY(res == SQUASH_OK)) { + if (HEDLEY_LIKELY(res == SQUASH_OK)) { if (tmp_buf_size <= internal_compressed_size) { memcpy (internal_compressed, tmp_buf, tmp_buf_size); internal_compressed_size = tmp_buf_size; @@ -825,7 +825,7 @@ squash_codec_compress_with_options (SquashCodec* codec, SquashStream* stream; stream = squash_codec_create_stream_with_options (codec, SQUASH_STREAM_COMPRESS, options); - if (SQUASH_UNLIKELY(stream == NULL)) { + if (HEDLEY_UNLIKELY(stream == NULL)) { res = squash_error (SQUASH_FAILED); goto cleanup; } @@ -880,9 +880,9 @@ squash_codec_compress_with_options (SquashCodec* codec, */ SquashStatus squash_codec_compress (SquashCodec* codec, size_t* compressed_size, - uint8_t compressed[SQUASH_ARRAY_PARAM(*compressed_size)], + uint8_t compressed[HEDLEY_ARRAY_PARAM(*compressed_size)], size_t uncompressed_size, - const uint8_t uncompressed[SQUASH_ARRAY_PARAM(uncompressed_size)], + const uint8_t uncompressed[HEDLEY_ARRAY_PARAM(uncompressed_size)], ...) { SquashOptions* options; va_list ap; @@ -915,22 +915,22 @@ SquashStatus squash_codec_compress (SquashCodec* codec, SquashStatus squash_codec_decompress_with_options (SquashCodec* codec, size_t* decompressed_size, - uint8_t decompressed[SQUASH_ARRAY_PARAM(*decompressed_size)], + uint8_t decompressed[HEDLEY_ARRAY_PARAM(*decompressed_size)], size_t compressed_size, - const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_size)], + const uint8_t compressed[HEDLEY_ARRAY_PARAM(compressed_size)], SquashOptions* options) { SquashCodecImpl* impl = NULL; assert (codec != NULL); impl = squash_codec_get_impl (codec); - if (SQUASH_UNLIKELY(impl == NULL)) + if (HEDLEY_UNLIKELY(impl == NULL)) return squash_error (SQUASH_UNABLE_TO_LOAD); - if (SQUASH_UNLIKELY(decompressed == compressed)) + if (HEDLEY_UNLIKELY(decompressed == compressed)) return squash_error (SQUASH_INVALID_BUFFER); - if (SQUASH_UNLIKELY(*decompressed_size == 0)) + if (HEDLEY_UNLIKELY(*decompressed_size == 0)) return squash_error (SQUASH_INVALID_BUFFER); if (impl->decompress_buffer != NULL) { @@ -944,7 +944,7 @@ squash_codec_decompress_with_options (SquashCodec* codec, uint64_t encoded_decompressed_size = 0; const size_t encoded_decompressed_size_length = squash_read_varuint64(compressed, compressed_size, &encoded_decompressed_size); #if SIZE_MAX < UINT64_MAX - if (SQUASH_UNLIKELY(SIZE_MAX < encoded_decompressed_size)) + if (HEDLEY_UNLIKELY(SIZE_MAX < encoded_decompressed_size)) return squash_error (SQUASH_RANGE); #endif @@ -962,8 +962,8 @@ squash_codec_decompress_with_options (SquashCodec* codec, squash_object_ref (options)); squash_object_unref (options); - if (SQUASH_LIKELY(res == SQUASH_OK) && - SQUASH_UNLIKELY(internal_decompressed_size != encoded_decompressed_size)) { + if (HEDLEY_LIKELY(res == SQUASH_OK) && + HEDLEY_UNLIKELY(internal_decompressed_size != encoded_decompressed_size)) { res = squash_error (SQUASH_INVALID_BUFFER); } } else { @@ -982,7 +982,7 @@ squash_codec_decompress_with_options (SquashCodec* codec, stream = squash_codec_create_stream_with_options (codec, SQUASH_STREAM_DECOMPRESS, options); if (stream == NULL) exit(EXIT_FAILURE); - if (SQUASH_UNLIKELY(stream == NULL)) + if (HEDLEY_UNLIKELY(stream == NULL)) return squash_error (SQUASH_FAILED); stream->next_in = compressed; stream->avail_in = compressed_size; @@ -1030,9 +1030,9 @@ squash_codec_decompress_with_options (SquashCodec* codec, SquashStatus squash_codec_decompress (SquashCodec* codec, size_t* decompressed_size, - uint8_t decompressed[SQUASH_ARRAY_PARAM(*decompressed_size)], + uint8_t decompressed[HEDLEY_ARRAY_PARAM(*decompressed_size)], size_t compressed_size, - const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_size)], + const uint8_t compressed[HEDLEY_ARRAY_PARAM(compressed_size)], ...) { SquashOptions* options; va_list ap; @@ -1134,14 +1134,14 @@ squash_codec_get_info (SquashCodec* codec) { const SquashOptionInfo* squash_codec_get_option_info (SquashCodec* codec) { SquashCodecImpl* impl = squash_codec_get_impl (codec); - return SQUASH_LIKELY(impl != NULL) ? impl->options : NULL; + return HEDLEY_LIKELY(impl != NULL) ? impl->options : NULL; } SquashStatus squash_codec_decompress_to_buffer (SquashCodec* codec, SquashBuffer* decompressed, size_t compressed_size, - uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_size)], + uint8_t compressed[HEDLEY_ARRAY_PARAM(compressed_size)], SquashOptions* options) { SquashStatus res; @@ -1155,7 +1155,7 @@ squash_codec_decompress_to_buffer (SquashCodec* codec, size_t decompressed_size; bool try_smaller = false; do { - if (SQUASH_UNLIKELY(try_smaller)) + if (HEDLEY_UNLIKELY(try_smaller)) decompressed_alloc >>= 1; else decompressed_alloc <<= 1; @@ -1166,18 +1166,18 @@ squash_codec_decompress_to_buffer (SquashCodec* codec, squash_free (decompressed_data); decompressed_data = squash_malloc (decompressed_alloc); - if (SQUASH_UNLIKELY(decompressed_data == NULL)) + if (HEDLEY_UNLIKELY(decompressed_data == NULL)) return squash_error (SQUASH_MEMORY); res = squash_codec_decompress_with_options(codec, &decompressed_size, decompressed_data, compressed_size, compressed, options); /* If we failed because of API restrictions in the codec on the buffer size, maybe it will work with a slightly smaller buffer... */ - if (SQUASH_UNLIKELY(res == SQUASH_RANGE) && (decompressed_alloc <= (compressed_npot_size << 3)) && !try_smaller) { + if (HEDLEY_UNLIKELY(res == SQUASH_RANGE) && (decompressed_alloc <= (compressed_npot_size << 3)) && !try_smaller) { try_smaller = true; res = SQUASH_BUFFER_FULL; continue; - } else if (SQUASH_UNLIKELY(try_smaller) && res == SQUASH_BUFFER_FULL) { + } else if (HEDLEY_UNLIKELY(try_smaller) && res == SQUASH_BUFFER_FULL) { /* We're caught between the buffer being to big for the API and too small for the data. This shouldn't usually happen since the API wouldn't allow us to compress the data in the first @@ -1187,7 +1187,7 @@ squash_codec_decompress_to_buffer (SquashCodec* codec, } } while (res == SQUASH_BUFFER_FULL); - if (SQUASH_LIKELY(res == SQUASH_OK)) + if (HEDLEY_LIKELY(res == SQUASH_OK)) squash_buffer_steal (decompressed, decompressed_size, decompressed_alloc, decompressed_data); else squash_free (decompressed_data); diff --git a/squash/squash-codec.h b/squash/squash-codec.h index a63de34..498b540 100644 --- a/squash/squash-codec.h +++ b/squash/squash-codec.h @@ -36,7 +36,7 @@ #error "Only can be included directly." #endif -SQUASH_BEGIN_DECLS +HEDLEY_BEGIN_C_DECLS typedef enum { SQUASH_CODEC_INFO_CAN_FLUSH = 1 << 0, @@ -54,10 +54,10 @@ typedef enum { #define SQUASH_CODEC_INFO_INVALID ((SquashCodecInfo) 0) typedef SquashStatus (*SquashReadFunc) (size_t* data_size, - uint8_t data[SQUASH_ARRAY_PARAM(*data_size)], + uint8_t data[HEDLEY_ARRAY_PARAM(*data_size)], void* user_data); typedef SquashStatus (*SquashWriteFunc) (size_t* data_size, - const uint8_t data[SQUASH_ARRAY_PARAM(*data_size)], + const uint8_t data[HEDLEY_ARRAY_PARAM(*data_size)], void* user_data); struct SquashCodecImpl_ { @@ -80,27 +80,27 @@ struct SquashCodecImpl_ { /* Buffers */ SquashStatus (* decompress_buffer) (SquashCodec* codec, size_t* decompressed_size, - uint8_t decompressed[SQUASH_ARRAY_PARAM(*decompressed_size)], + uint8_t decompressed[HEDLEY_ARRAY_PARAM(*decompressed_size)], size_t compressed_size, - const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_size)], + const uint8_t compressed[HEDLEY_ARRAY_PARAM(compressed_size)], SquashOptions* options); SquashStatus (* compress_buffer) (SquashCodec* codec, size_t* compressed_size, - uint8_t compressed[SQUASH_ARRAY_PARAM(*compressed_size)], + uint8_t compressed[HEDLEY_ARRAY_PARAM(*compressed_size)], size_t uncompressed_size, - const uint8_t uncompressed[SQUASH_ARRAY_PARAM(uncompressed_size)], + const uint8_t uncompressed[HEDLEY_ARRAY_PARAM(uncompressed_size)], SquashOptions* options); SquashStatus (* compress_buffer_unsafe) (SquashCodec* codec, size_t* compressed_size, - uint8_t compressed[SQUASH_ARRAY_PARAM(*compressed_size)], + uint8_t compressed[HEDLEY_ARRAY_PARAM(*compressed_size)], size_t uncompressed_size, - const uint8_t uncompressed[SQUASH_ARRAY_PARAM(uncompressed_size)], + const uint8_t uncompressed[HEDLEY_ARRAY_PARAM(uncompressed_size)], SquashOptions* options); /* Codecs */ size_t (* get_uncompressed_size) (SquashCodec* codec, size_t compressed_size, - const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_size)]); + const uint8_t compressed[HEDLEY_ARRAY_PARAM(compressed_size)]); size_t (* get_max_compressed_size) (SquashCodec* codec, size_t uncompressed_size); /* Reserved */ @@ -116,67 +116,67 @@ struct SquashCodecImpl_ { typedef void (*SquashCodecForeachFunc) (SquashCodec* codec, void* data); -SQUASH_NONNULL(1) +HEDLEY_NON_NULL(1) SQUASH_API SquashStatus squash_codec_init (SquashCodec* codec); -SQUASH_NONNULL(1) +HEDLEY_NON_NULL(1) SQUASH_API const char* squash_codec_get_name (SquashCodec* codec); -SQUASH_NONNULL(1) +HEDLEY_NON_NULL(1) SQUASH_API unsigned int squash_codec_get_priority (SquashCodec* codec); -SQUASH_NONNULL(1) +HEDLEY_NON_NULL(1) SQUASH_API SquashPlugin* squash_codec_get_plugin (SquashCodec* codec); -SQUASH_NONNULL(1) +HEDLEY_NON_NULL(1) SQUASH_API SquashContext* squash_codec_get_context (SquashCodec* codec); -SQUASH_NONNULL(1) +HEDLEY_NON_NULL(1) SQUASH_API const char* squash_codec_get_extension (SquashCodec* codec); -SQUASH_NONNULL(1, 3) +HEDLEY_NON_NULL(1, 3) SQUASH_API size_t squash_codec_get_uncompressed_size (SquashCodec* codec, size_t compressed_size, - const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_size)]); -SQUASH_NONNULL(1) + const uint8_t compressed[HEDLEY_ARRAY_PARAM(compressed_size)]); +HEDLEY_NON_NULL(1) SQUASH_API size_t squash_codec_get_max_compressed_size (SquashCodec* codec, size_t uncompressed_size); -SQUASH_SENTINEL -SQUASH_NONNULL(1) +HEDLEY_SENTINEL(0) +HEDLEY_NON_NULL(1) SQUASH_API SquashStream* squash_codec_create_stream (SquashCodec* codec, SquashStreamType stream_type, ...); -SQUASH_NONNULL(1) +HEDLEY_NON_NULL(1) SQUASH_API SquashStream* squash_codec_create_stream_with_options (SquashCodec* codec, SquashStreamType stream_type, SquashOptions* options); -SQUASH_SENTINEL -SQUASH_NONNULL(1, 2, 3, 5) +HEDLEY_SENTINEL(0) +HEDLEY_NON_NULL(1, 2, 3, 5) SQUASH_API SquashStatus squash_codec_compress (SquashCodec* codec, size_t* compressed_size, - uint8_t compressed[SQUASH_ARRAY_PARAM(*compressed_size)], + uint8_t compressed[HEDLEY_ARRAY_PARAM(*compressed_size)], size_t uncompressed_size, - const uint8_t uncompressed[SQUASH_ARRAY_PARAM(uncompressed_size)], + const uint8_t uncompressed[HEDLEY_ARRAY_PARAM(uncompressed_size)], ...); -SQUASH_NONNULL(1, 2, 3, 5) +HEDLEY_NON_NULL(1, 2, 3, 5) SQUASH_API SquashStatus squash_codec_compress_with_options (SquashCodec* codec, size_t* compressed_size, - uint8_t compressed[SQUASH_ARRAY_PARAM(*compressed_size)], + uint8_t compressed[HEDLEY_ARRAY_PARAM(*compressed_size)], size_t uncompressed_size, - const uint8_t uncompressed[SQUASH_ARRAY_PARAM(uncompressed_size)], + const uint8_t uncompressed[HEDLEY_ARRAY_PARAM(uncompressed_size)], SquashOptions* options); -SQUASH_SENTINEL -SQUASH_NONNULL(1, 2, 3, 5) +HEDLEY_SENTINEL(0) +HEDLEY_NON_NULL(1, 2, 3, 5) SQUASH_API SquashStatus squash_codec_decompress (SquashCodec* codec, size_t* decompressed_size, - uint8_t decompressed[SQUASH_ARRAY_PARAM(*decompressed_size)], + uint8_t decompressed[HEDLEY_ARRAY_PARAM(*decompressed_size)], size_t compressed_size, - const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_size)], + const uint8_t compressed[HEDLEY_ARRAY_PARAM(compressed_size)], ...); -SQUASH_NONNULL(1, 2, 3, 5) +HEDLEY_NON_NULL(1, 2, 3, 5) SQUASH_API SquashStatus squash_codec_decompress_with_options (SquashCodec* codec, size_t* decompressed_size, - uint8_t decompressed[SQUASH_ARRAY_PARAM(*decompressed_size)], + uint8_t decompressed[HEDLEY_ARRAY_PARAM(*decompressed_size)], size_t compressed_size, - const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_size)], + const uint8_t compressed[HEDLEY_ARRAY_PARAM(compressed_size)], SquashOptions* options); -SQUASH_NONNULL(1) +HEDLEY_NON_NULL(1) SQUASH_API SquashCodecInfo squash_codec_get_info (SquashCodec* codec); -SQUASH_NONNULL(1) +HEDLEY_NON_NULL(1) SQUASH_API const SquashOptionInfo* squash_codec_get_option_info (SquashCodec* codec); -SQUASH_END_DECLS +HEDLEY_END_C_DECLS #endif /* SQUASH_CODEC_H */ diff --git a/squash/squash-context-internal.h b/squash/squash-context-internal.h index 0d4277c..9e8c948 100644 --- a/squash/squash-context-internal.h +++ b/squash/squash-context-internal.h @@ -32,14 +32,14 @@ #error "This is internal API; you cannot use it." #endif -SQUASH_BEGIN_DECLS +HEDLEY_BEGIN_C_DECLS -SQUASH_NONNULL(1, 2) SQUASH_INTERNAL +HEDLEY_NON_NULL(1, 2) SQUASH_INTERNAL void squash_context_add_codec (SquashContext* context, SquashCodec* codec); SQUASH_TREE_PROTOTYPES(SquashCodecRef_, tree) SQUASH_TREE_DEFINE(SquashCodecRef_, tree) -SQUASH_END_DECLS +HEDLEY_END_C_DECLS #endif /* SQUASH_CONTEXT_INTERNAL_H */ diff --git a/squash/squash-context.c b/squash/squash-context.c index daa4819..28a1a19 100644 --- a/squash/squash-context.c +++ b/squash/squash-context.c @@ -373,7 +373,7 @@ static SquashStatus squash_codecs_file_parser_parse (SquashCodecsFileParser* parser, FILE* input) { bool res = squash_ini_parse (input, squash_codecs_file_parser_callback, parser); - if (SQUASH_LIKELY(res && parser->codec != NULL)) { + if (HEDLEY_LIKELY(res && parser->codec != NULL)) { squash_plugin_add_codec (parser->plugin, parser->codec); return SQUASH_OK; } else { @@ -671,7 +671,7 @@ squash_foreach_codec (SquashCodecForeachFunc func, void* data) { static SquashContext* squash_context_new (void) { SquashContext* context = squash_malloc (sizeof (SquashContext)); - if (SQUASH_UNLIKELY(context == NULL)) + if (HEDLEY_UNLIKELY(context == NULL)) return NULL; memset (context, 0, sizeof (SquashContext)); diff --git a/squash/squash-context.h b/squash/squash-context.h index a91658f..edd3fa5 100644 --- a/squash/squash-context.h +++ b/squash/squash-context.h @@ -33,32 +33,32 @@ #error "Only can be included directly." #endif -SQUASH_BEGIN_DECLS +HEDLEY_BEGIN_C_DECLS SQUASH_API void squash_set_default_search_path (const char* search_path); SQUASH_API SquashContext* squash_context_get_default (void); -SQUASH_NONNULL(1, 2) +HEDLEY_NON_NULL(1, 2) SQUASH_API SquashPlugin* squash_context_get_plugin (SquashContext* context, const char* plugin); -SQUASH_NONNULL(1, 2) +HEDLEY_NON_NULL(1, 2) SQUASH_API SquashCodec* squash_context_get_codec (SquashContext* context, const char* codec); -SQUASH_NONNULL(1, 2) +HEDLEY_NON_NULL(1, 2) SQUASH_API void squash_context_foreach_plugin (SquashContext* context, SquashPluginForeachFunc func, void* data); -SQUASH_NONNULL(1, 2) +HEDLEY_NON_NULL(1, 2) SQUASH_API void squash_context_foreach_codec (SquashContext* context, SquashCodecForeachFunc func, void* data); -SQUASH_NONNULL(1, 2) +HEDLEY_NON_NULL(1, 2) SQUASH_API SquashCodec* squash_context_get_codec_from_extension (SquashContext* context, const char* extension); -SQUASH_NONNULL(1) +HEDLEY_NON_NULL(1) SQUASH_API SquashPlugin* squash_get_plugin (const char* plugin); -SQUASH_NONNULL(1) +HEDLEY_NON_NULL(1) SQUASH_API SquashCodec* squash_get_codec (const char* codec); -SQUASH_NONNULL(1) +HEDLEY_NON_NULL(1) SQUASH_API void squash_foreach_plugin (SquashPluginForeachFunc func, void* data); -SQUASH_NONNULL(1) +HEDLEY_NON_NULL(1) SQUASH_API void squash_foreach_codec (SquashCodecForeachFunc func, void* data); -SQUASH_NONNULL(1) +HEDLEY_NON_NULL(1) SQUASH_API SquashCodec* squash_get_codec_from_extension (const char* extension); -SQUASH_END_DECLS +HEDLEY_END_C_DECLS #endif /* SQUASH_CONTEXT_H */ diff --git a/squash/squash-file.c b/squash/squash-file.c index 1342a66..712f1de 100644 --- a/squash/squash-file.c +++ b/squash/squash-file.c @@ -145,7 +145,7 @@ squash_file_open_with_options (SquashCodec* codec, const char* filename, const c #if !defined(_WIN32) FILE* fp = fopen (filename, mode); - if (SQUASH_UNLIKELY(fp == NULL)) + if (HEDLEY_UNLIKELY(fp == NULL)) return NULL; return squash_file_steal_with_options (codec, fp, options); @@ -209,7 +209,7 @@ squash_file_wopen_with_options (SquashCodec* codec, const wchar_t* filename, con return file; #else FILE* fp = _wfopen (filename, mode); - if (SQUASH_UNLIKELY(fp == NULL)) + if (HEDLEY_UNLIKELY(fp == NULL)) return NULL; return squash_file_steal_with_options (codec, fp, options); @@ -321,7 +321,7 @@ squash_file_steal_with_options (SquashCodec* codec, FILE* fp, SquashOptions* opt SquashStatus squash_file_read (SquashFile* file, size_t* decompressed_size, - uint8_t decompressed[SQUASH_ARRAY_PARAM(*decompressed_size)]) { + uint8_t decompressed[HEDLEY_ARRAY_PARAM(*decompressed_size)]) { assert (file != NULL); assert (decompressed_size != NULL); assert (decompressed != NULL); @@ -352,17 +352,17 @@ squash_file_read (SquashFile* file, SquashStatus squash_file_read_unlocked (SquashFile* file, size_t* decompressed_size, - uint8_t decompressed[SQUASH_ARRAY_PARAM(*decompressed_size)]) { + uint8_t decompressed[HEDLEY_ARRAY_PARAM(*decompressed_size)]) { assert (file != NULL); assert (decompressed_size != NULL); assert (decompressed != NULL); - if (SQUASH_UNLIKELY(file->last_status < 0)) + if (HEDLEY_UNLIKELY(file->last_status < 0)) return file->last_status; if (file->stream == NULL) { file->stream = squash_codec_create_stream_with_options (file->codec, SQUASH_STREAM_DECOMPRESS, file->options); - if (SQUASH_UNLIKELY(file->stream == NULL)) { + if (HEDLEY_UNLIKELY(file->stream == NULL)) { return file->last_status = squash_error (SQUASH_FAILED); } } @@ -436,18 +436,18 @@ squash_file_read_unlocked (SquashFile* file, static SquashStatus squash_file_write_internal (SquashFile* file, size_t uncompressed_size, - const uint8_t uncompressed[SQUASH_ARRAY_PARAM(uncompressed_size)], + const uint8_t uncompressed[HEDLEY_ARRAY_PARAM(uncompressed_size)], SquashOperation operation) { SquashStatus res; assert (file != NULL); - if (SQUASH_UNLIKELY(file->last_status < 0)) + if (HEDLEY_UNLIKELY(file->last_status < 0)) return file->last_status; if (file->stream == NULL) { file->stream = squash_codec_create_stream_with_options (file->codec, SQUASH_STREAM_COMPRESS, file->options); - if (SQUASH_UNLIKELY(file->stream == NULL)) { + if (HEDLEY_UNLIKELY(file->stream == NULL)) { res = squash_error (SQUASH_FAILED); goto cleanup; } @@ -476,7 +476,7 @@ squash_file_write_internal (SquashFile* file, res = squash_stream_finish (file->stream); break; case SQUASH_OPERATION_TERMINATE: - squash_assert_unreachable (); + HEDLEY_UNREACHABLE (); break; } @@ -524,7 +524,7 @@ squash_file_write_internal (SquashFile* file, SquashStatus squash_file_write (SquashFile* file, size_t uncompressed_size, - const uint8_t uncompressed[SQUASH_ARRAY_PARAM(uncompressed_size)]) { + const uint8_t uncompressed[HEDLEY_ARRAY_PARAM(uncompressed_size)]) { squash_file_lock (file); SquashStatus res = squash_file_write_unlocked (file, uncompressed_size, uncompressed); squash_file_unlock (file); @@ -602,11 +602,11 @@ squash_file_vwprintf (SquashFile* file, assert (format != NULL); size = _vscwprintf (format, ap); - if (SQUASH_UNLIKELY(size < 0)) + if (HEDLEY_UNLIKELY(size < 0)) return squash_error (SQUASH_FAILED); buf = calloc (size + 1, sizeof (wchar_t)); - if (SQUASH_UNLIKELY(buf == NULL)) + if (HEDLEY_UNLIKELY(buf == NULL)) return squash_error (SQUASH_MEMORY); #if !defined(_WIN32) @@ -614,7 +614,7 @@ squash_file_vwprintf (SquashFile* file, #else const int written = _vsnwprintf (buf, size + 1, format, ap); #endif - if (SQUASH_UNLIKELY(written != size)) { + if (HEDLEY_UNLIKELY(written != size)) { res = squash_error (SQUASH_FAILED); } else { size_t data_size; @@ -623,7 +623,7 @@ squash_file_vwprintf (SquashFile* file, squash_charset_convert (&data_size, &data, "UTF-8", size * sizeof(wchar_t), (char*) buf, squash_charset_get_wide ()); - if (SQUASH_LIKELY(conv_success)) + if (HEDLEY_LIKELY(conv_success)) res = squash_file_write (file, data_size, (uint8_t*) data); else res = squash_error (SQUASH_FAILED); @@ -660,26 +660,26 @@ squash_file_vprintf (SquashFile* file, #if defined(_WIN32) size = _vscprintf (format, ap); - if (SQUASH_UNLIKELY(size < 0)) + if (HEDLEY_UNLIKELY(size < 0)) return squash_error (SQUASH_FAILED); #else char buf[256]; size = vsnprintf (buf, sizeof (buf), format, ap); - if (SQUASH_UNLIKELY(size < 0)) + if (HEDLEY_UNLIKELY(size < 0)) return squash_error (SQUASH_FAILED); else if (size >= (int) sizeof (buf)) #endif { heap_buf = squash_malloc (size + 1); - if (SQUASH_UNLIKELY(heap_buf == NULL)) + if (HEDLEY_UNLIKELY(heap_buf == NULL)) return squash_error (SQUASH_MEMORY); const int written = vsnprintf (heap_buf, size + 1, format, ap); - if (SQUASH_UNLIKELY(written != size)) + if (HEDLEY_UNLIKELY(written != size)) res = squash_error (SQUASH_FAILED); } - if (SQUASH_LIKELY(res == SQUASH_OK)) { + if (HEDLEY_LIKELY(res == SQUASH_OK)) { res = squash_file_write (file, size, #if !defined(_WIN32) (heap_buf == NULL) ? (uint8_t*) buf : @@ -728,7 +728,7 @@ squash_file_printf (SquashFile* file, SquashStatus squash_file_write_unlocked (SquashFile* file, size_t uncompressed_size, - const uint8_t uncompressed[SQUASH_ARRAY_PARAM(uncompressed_size)]) { + const uint8_t uncompressed[HEDLEY_ARRAY_PARAM(uncompressed_size)]) { return squash_file_write_internal (file, uncompressed_size, uncompressed, SQUASH_OPERATION_PROCESS); } @@ -829,8 +829,8 @@ squash_file_close (SquashFile* file) { res = SQUASH_OK; if (fp != NULL) { - const SquashStatus cres = SQUASH_LIKELY(fclose (fp) == 0) ? SQUASH_OK : squash_error (SQUASH_IO); - if (SQUASH_LIKELY(res > 0)) + const SquashStatus cres = HEDLEY_LIKELY(fclose (fp) == 0) ? SQUASH_OK : squash_error (SQUASH_IO); + if (HEDLEY_LIKELY(res > 0)) res = cres; } return res; @@ -859,7 +859,7 @@ SquashStatus squash_file_free (SquashFile* file, FILE** fp) { SquashStatus res = SQUASH_OK; - if (SQUASH_UNLIKELY(file == NULL)) { + if (HEDLEY_UNLIKELY(file == NULL)) { if (fp != NULL) *fp = NULL; return SQUASH_OK; diff --git a/squash/squash-file.h b/squash/squash-file.h index d07cb97..df94f0f 100644 --- a/squash/squash-file.h +++ b/squash/squash-file.h @@ -38,100 +38,100 @@ #include #include -SQUASH_BEGIN_DECLS +HEDLEY_BEGIN_C_DECLS -SQUASH_SENTINEL -SQUASH_NONNULL(1, 2, 3) +HEDLEY_SENTINEL(0) +HEDLEY_NON_NULL(1, 2, 3) SQUASH_API SquashFile* squash_file_open (SquashCodec* codec, const char* filename, const char* mode, ...); -SQUASH_NONNULL(1, 2, 3) +HEDLEY_NON_NULL(1, 2, 3) SQUASH_API SquashFile* squash_file_open_with_options (SquashCodec* codec, const char* filename, const char* mode, SquashOptions* options); -SQUASH_SENTINEL -SQUASH_NONNULL(1, 2) +HEDLEY_SENTINEL(0) +HEDLEY_NON_NULL(1, 2) SQUASH_API SquashFile* squash_file_steal (SquashCodec* codec, FILE* fp, ...); -SQUASH_NONNULL(1, 2) +HEDLEY_NON_NULL(1, 2) SQUASH_API SquashFile* squash_file_steal_with_options (SquashCodec* codec, FILE* fp, SquashOptions* options); -SQUASH_NONNULL(1, 2, 3) +HEDLEY_NON_NULL(1, 2, 3) SQUASH_API SquashStatus squash_file_read (SquashFile* file, size_t* decompressed_size, - uint8_t decompressed[SQUASH_ARRAY_PARAM(*decompressed_size)]); -SQUASH_NONNULL(1, 3) + uint8_t decompressed[HEDLEY_ARRAY_PARAM(*decompressed_size)]); +HEDLEY_NON_NULL(1, 3) SQUASH_API SquashStatus squash_file_write (SquashFile* file, size_t uncompressed_size, - const uint8_t uncompressed[SQUASH_ARRAY_PARAM(uncompressed_size)]); + const uint8_t uncompressed[HEDLEY_ARRAY_PARAM(uncompressed_size)]); #if defined(__GNUC__) __attribute__((__format__ (__printf__, 2, 3))) #endif -SQUASH_NONNULL(1, 2) +HEDLEY_NON_NULL(1, 2) SQUASH_API SquashStatus squash_file_printf (SquashFile* file, const char* format, ...); -SQUASH_NONNULL(1, 2) +HEDLEY_NON_NULL(1, 2) SQUASH_API SquashStatus squash_file_vprintf (SquashFile* file, const char* format, va_list ap); -SQUASH_NONNULL(1) +HEDLEY_NON_NULL(1) SQUASH_API SquashStatus squash_file_flush (SquashFile* file); -SQUASH_NONNULL(1) +HEDLEY_NON_NULL(1) SQUASH_API SquashStatus squash_file_close (SquashFile* file); SQUASH_API SquashStatus squash_file_free (SquashFile* file, FILE** fp); -SQUASH_NONNULL(1) +HEDLEY_NON_NULL(1) SQUASH_API bool squash_file_eof (SquashFile* file); -SQUASH_NONNULL(1) +HEDLEY_NON_NULL(1) SQUASH_API SquashStatus squash_file_error (SquashFile* file); -SQUASH_NONNULL(1) +HEDLEY_NON_NULL(1) SQUASH_API void squash_file_lock (SquashFile* file); -SQUASH_NONNULL(1) +HEDLEY_NON_NULL(1) SQUASH_API void squash_file_unlock (SquashFile* file); -SQUASH_NONNULL(1, 2, 3) +HEDLEY_NON_NULL(1, 2, 3) SQUASH_API SquashStatus squash_file_read_unlocked (SquashFile* file, size_t* decompressed_size, - uint8_t decompressed[SQUASH_ARRAY_PARAM(*decompressed_size)]); -SQUASH_NONNULL(1, 3) + uint8_t decompressed[HEDLEY_ARRAY_PARAM(*decompressed_size)]); +HEDLEY_NON_NULL(1, 3) SQUASH_API SquashStatus squash_file_write_unlocked (SquashFile* file, size_t uncompressed_size, - const uint8_t uncompressed[SQUASH_ARRAY_PARAM(uncompressed_size)]); -SQUASH_NONNULL(1) + const uint8_t uncompressed[HEDLEY_ARRAY_PARAM(uncompressed_size)]); +HEDLEY_NON_NULL(1) SQUASH_API SquashStatus squash_file_flush_unlocked (SquashFile* file); #if defined(SQUASH_ENABLE_WIDE_CHAR_API) -SQUASH_SENTINEL -SQUASH_NONNULL(1, 2, 3) +HEDLEY_SENTINEL(0) +HEDLEY_NON_NULL(1, 2, 3) SQUASH_API SquashFile* squash_file_wopen (SquashCodec* codec, const wchar_t* filename, const wchar_t* mode, ...); -SQUASH_NONNULL(1, 2, 3) +HEDLEY_NON_NULL(1, 2, 3) SQUASH_API SquashFile* squash_file_wopen_with_options (SquashCodec* codec, const wchar_t* filename, const wchar_t* mode, SquashOptions* options); -SQUASH_NONNULL(1, 2) +HEDLEY_NON_NULL(1, 2) SQUASH_API SquashStatus squash_file_wprintf (SquashFile* file, const wchar_t* format, ...); -SQUASH_NONNULL(1, 2) +HEDLEY_NON_NULL(1, 2) SQUASH_API SquashStatus squash_file_vwprintf (SquashFile* file, const wchar_t* format, va_list ap); #endif /* defined(SQUASH_ENABLE_WIDE_CHAR_API) */ -SQUASH_END_DECLS +HEDLEY_END_C_DECLS #endif /* SQUASH_FILE_H */ diff --git a/squash/squash-ini-internal.h b/squash/squash-ini-internal.h index abf8c4e..1d71488 100644 --- a/squash/squash-ini-internal.h +++ b/squash/squash-ini-internal.h @@ -38,7 +38,7 @@ typedef bool (* SquashIniParserCallback) (const char* section, size_t value_size, void* user_data); -SQUASH_NONNULL(1, 2) SQUASH_INTERNAL +HEDLEY_NON_NULL(1, 2) SQUASH_INTERNAL bool squash_ini_parse (FILE* input, SquashIniParserCallback callback, void* user_data); diff --git a/squash/squash-license.h b/squash/squash-license.h index 3e587b1..a06bd98 100644 --- a/squash/squash-license.h +++ b/squash/squash-license.h @@ -34,7 +34,7 @@ #include -SQUASH_BEGIN_DECLS +HEDLEY_BEGIN_C_DECLS typedef enum { SQUASH_LICENSE_UNKNOWN = 0, @@ -80,6 +80,6 @@ typedef enum { SQUASH_API SquashLicense squash_license_from_string (const char* license); SQUASH_API const char* squash_license_to_string (SquashLicense license); -SQUASH_END_DECLS +HEDLEY_END_C_DECLS #endif /* SQUASH_LICENSE_H */ diff --git a/squash/squash-mapped-file-internal.h b/squash/squash-mapped-file-internal.h index a5d6e7c..fb898dc 100644 --- a/squash/squash-mapped-file-internal.h +++ b/squash/squash-mapped-file-internal.h @@ -34,7 +34,7 @@ #include -SQUASH_BEGIN_DECLS +HEDLEY_BEGIN_C_DECLS typedef struct SquashMappedFile_s { uint8_t* data; @@ -47,21 +47,21 @@ typedef struct SquashMappedFile_s { static const SquashMappedFile squash_mapped_file_empty = { MAP_FAILED, 0 }; -SQUASH_NONNULL(1, 2) SQUASH_INTERNAL +HEDLEY_NON_NULL(1, 2) SQUASH_INTERNAL bool squash_mapped_file_init_full (SquashMappedFile* mapped, FILE* fp, size_t size, bool size_is_suggestion, bool writable); -SQUASH_NONNULL(1, 2) SQUASH_INTERNAL +HEDLEY_NON_NULL(1, 2) SQUASH_INTERNAL bool squash_mapped_file_init (SquashMappedFile* mapped, FILE* fp, size_t size, bool writable); -SQUASH_NONNULL(1) SQUASH_INTERNAL +HEDLEY_NON_NULL(1) SQUASH_INTERNAL bool squash_mapped_file_destroy (SquashMappedFile* mapped, bool success); -SQUASH_END_DECLS +HEDLEY_END_C_DECLS #endif /* SQUASH_FILE_INTERNAL_H */ diff --git a/squash/squash-mapped-file.c b/squash/squash-mapped-file.c index 267880e..99be20b 100644 --- a/squash/squash-mapped-file.c +++ b/squash/squash-mapped-file.c @@ -121,12 +121,12 @@ squash_mapped_file_destroy (SquashMappedFile* mapped, bool success) { if (success) { const int sres = fseeko (mapped->fp, mapped->size, SEEK_CUR); - if (SQUASH_LIKELY(sres != -1)) { + if (HEDLEY_LIKELY(sres != -1)) { if (mapped->writable) { const off_t pos = ftello (mapped->fp); - if (SQUASH_LIKELY(pos != -1)) { + if (HEDLEY_LIKELY(pos != -1)) { const int tr = ftruncate (fileno (mapped->fp), pos); - return SQUASH_LIKELY(tr != -1) ? true : false; + return HEDLEY_LIKELY(tr != -1) ? true : false; } else { return false; } diff --git a/squash/squash-memory-internal.h b/squash/squash-memory-internal.h index 3cb8793..f86c298 100644 --- a/squash/squash-memory-internal.h +++ b/squash/squash-memory-internal.h @@ -32,11 +32,11 @@ #error "This is internal API; you cannot use it." #endif -SQUASH_BEGIN_DECLS +HEDLEY_BEGIN_C_DECLS SQUASH_INTERNAL void squash_get_memory_functions (SquashMemoryFuncs* memfns); -SQUASH_END_DECLS +HEDLEY_END_C_DECLS #endif /* SQUASH_SLIST_INTERNAL_H */ diff --git a/squash/squash-memory.c b/squash/squash-memory.c index 3591d5d..d91929d 100644 --- a/squash/squash-memory.c +++ b/squash/squash-memory.c @@ -60,7 +60,7 @@ squash_wrap_aligned_alloc (size_t alignment, size_t size) { #if defined(HAVE_POSIX_MEMALIGN) void* ptr; int r = posix_memalign (&ptr, alignment, size); - if (SQUASH_UNLIKELY(r != 0)) + if (HEDLEY_UNLIKELY(r != 0)) return (squash_error (SQUASH_MEMORY), NULL); return ptr; #elif defined(HAVE__ALIGNED_MALLOC) @@ -233,7 +233,7 @@ squash_aligned_alloc (size_t alignment, size_t size) { return (void*) (addr + padding); } - squash_assert_unreachable (); + HEDLEY_UNREACHABLE (); } /** diff --git a/squash/squash-memory.h b/squash/squash-memory.h index f3ed939..856ab70 100644 --- a/squash/squash-memory.h +++ b/squash/squash-memory.h @@ -38,7 +38,7 @@ #define SQUASH_MALLOC #endif -SQUASH_BEGIN_DECLS +HEDLEY_BEGIN_C_DECLS typedef struct SquashMemoryFuncs_ { void* (* malloc) (size_t size); @@ -60,6 +60,6 @@ SQUASH_API void squash_free (void* ptr); SQUASH_API void* squash_aligned_alloc (size_t alignment, size_t size); SQUASH_API void squash_aligned_free (void* ptr); -SQUASH_END_DECLS +HEDLEY_END_C_DECLS #endif /* SQUASH_MEMORY_H */ diff --git a/squash/squash-mtx-internal.h b/squash/squash-mtx-internal.h index ac0b8a3..9bcda7d 100644 --- a/squash/squash-mtx-internal.h +++ b/squash/squash-mtx-internal.h @@ -34,7 +34,7 @@ #include "tinycthread/source/tinycthread.h" -SQUASH_BEGIN_DECLS +HEDLEY_BEGIN_C_DECLS #ifdef __GNUC__ # define SQUASH_POSSIBLY_UNUSED __attribute__((__unused__)) @@ -58,6 +58,6 @@ SQUASH_BEGIN_DECLS assert (mtx_unlock (&(SQUASH_MTX_NAME(name,mtx))) == thrd_success); \ } while(0); -SQUASH_END_DECLS +HEDLEY_END_C_DECLS #endif /* SQUASH_MTX_INTERNAL_H */ diff --git a/squash/squash-object.c b/squash/squash-object.c index ae81d30..856fe02 100644 --- a/squash/squash-object.c +++ b/squash/squash-object.c @@ -253,7 +253,7 @@ squash_object_unref (void* obj) { unsigned int ref_count = squash_atomic_dec (&(object->ref_count)); if (ref_count == 1) { - if (SQUASH_LIKELY(object->destroy_notify != NULL)) + if (HEDLEY_LIKELY(object->destroy_notify != NULL)) object->destroy_notify (obj); squash_free (obj); diff --git a/squash/squash-object.h b/squash/squash-object.h index c2490ca..a03d7c0 100644 --- a/squash/squash-object.h +++ b/squash/squash-object.h @@ -34,7 +34,7 @@ #include -SQUASH_BEGIN_DECLS +HEDLEY_BEGIN_C_DECLS SQUASH_API void* squash_object_ref (void* obj); SQUASH_API void* squash_object_unref (void* obj); @@ -49,11 +49,11 @@ struct SquashObject_ { SquashDestroyNotify destroy_notify; }; -SQUASH_NONNULL(1) +HEDLEY_NON_NULL(1) SQUASH_API void squash_object_init (void* obj, bool is_floating, SquashDestroyNotify destroy_notify); -SQUASH_NONNULL(1) +HEDLEY_NON_NULL(1) SQUASH_API void squash_object_destroy (void* obj); -SQUASH_END_DECLS +HEDLEY_END_C_DECLS #endif /* SQUASH_OBJECT_H */ diff --git a/squash/squash-options.c b/squash/squash-options.c index 10f02e7..3deb7ed 100644 --- a/squash/squash-options.c +++ b/squash/squash-options.c @@ -199,7 +199,7 @@ squash_options_find (SquashOptions* options, SquashCodec* codec, const char* key const char* squash_options_get_string (SquashOptions* options, SquashCodec* codec, const char* key) { if (codec == NULL) { - if (SQUASH_UNLIKELY(options == NULL)) + if (HEDLEY_UNLIKELY(options == NULL)) return NULL; codec = options->codec; } @@ -221,7 +221,7 @@ squash_options_get_string (SquashOptions* options, SquashCodec* codec, const cha bool squash_options_get_bool (SquashOptions* options, SquashCodec* codec, const char* key) { if (codec == NULL) { - if (SQUASH_UNLIKELY(options == NULL)) + if (HEDLEY_UNLIKELY(options == NULL)) return false; codec = options->codec; } @@ -243,7 +243,7 @@ squash_options_get_bool (SquashOptions* options, SquashCodec* codec, const char* int squash_options_get_int (SquashOptions* options, SquashCodec* codec, const char* key) { if (codec == NULL) { - if (SQUASH_UNLIKELY(options == NULL)) + if (HEDLEY_UNLIKELY(options == NULL)) return -1; codec = options->codec; } @@ -265,7 +265,7 @@ squash_options_get_int (SquashOptions* options, SquashCodec* codec, const char* size_t squash_options_get_size (SquashOptions* options, SquashCodec* codec, const char* key) { if (codec == NULL) { - if (SQUASH_UNLIKELY(options == NULL)) + if (HEDLEY_UNLIKELY(options == NULL)) return 0; codec = options->codec; } @@ -280,7 +280,7 @@ squash_options_get_size (SquashOptions* options, SquashCodec* codec, const char* static const SquashOptionValue* squash_options_get_value_at (SquashOptions* options, SquashCodec* codec, const SquashOptionInfo** info, SquashOptionType* type, size_t idx) { const SquashOptionInfo* ci = squash_codec_get_option_info (codec); - if (SQUASH_UNLIKELY(ci == NULL)) + if (HEDLEY_UNLIKELY(ci == NULL)) return NULL; ci = &(ci[idx]); @@ -310,7 +310,7 @@ squash_options_get_value_at (SquashOptions* options, SquashCodec* codec, const S const char* squash_options_get_string_at (SquashOptions* options, SquashCodec* codec, size_t idx) { if (codec == NULL) { - if (SQUASH_UNLIKELY(options == NULL)) + if (HEDLEY_UNLIKELY(options == NULL)) return NULL; codec = options->codec; } @@ -318,7 +318,7 @@ squash_options_get_string_at (SquashOptions* options, SquashCodec* codec, size_t const SquashOptionInfo* info; SquashOptionType type; const SquashOptionValue* val = squash_options_get_value_at (options, codec, &info, &type, idx); - if (SQUASH_UNLIKELY(val == NULL)) + if (HEDLEY_UNLIKELY(val == NULL)) return NULL; switch ((int) type) { @@ -330,7 +330,7 @@ squash_options_get_string_at (SquashOptions* options, SquashCodec* codec, size_t return NULL; } - /* squash_assert_unreachable (); */ + /* HEDLEY_UNREACHABLE (); */ return NULL; } @@ -347,14 +347,14 @@ squash_options_get_string_at (SquashOptions* options, SquashCodec* codec, size_t bool squash_options_get_bool_at (SquashOptions* options, SquashCodec* codec, size_t idx) { if (codec == NULL) { - if (SQUASH_UNLIKELY(options == NULL)) + if (HEDLEY_UNLIKELY(options == NULL)) return false; codec = options->codec; } SquashOptionType type; const SquashOptionValue* val = squash_options_get_value_at (options, codec, NULL, &type, idx); - if (SQUASH_UNLIKELY(val == NULL)) + if (HEDLEY_UNLIKELY(val == NULL)) return false; switch ((int) type) { @@ -364,7 +364,7 @@ squash_options_get_bool_at (SquashOptions* options, SquashCodec* codec, size_t i return false; } - squash_assert_unreachable (); + HEDLEY_UNREACHABLE (); } /** @@ -380,14 +380,14 @@ squash_options_get_bool_at (SquashOptions* options, SquashCodec* codec, size_t i int squash_options_get_int_at (SquashOptions* options, SquashCodec* codec, size_t idx) { if (codec == NULL) { - if (SQUASH_UNLIKELY(options == NULL)) + if (HEDLEY_UNLIKELY(options == NULL)) return -1; codec = options->codec; } SquashOptionType type; const SquashOptionValue* val = squash_options_get_value_at (options, codec, NULL, &type, idx); - if (SQUASH_UNLIKELY(val == NULL)) + if (HEDLEY_UNLIKELY(val == NULL)) return -1; switch ((int) type) { @@ -402,7 +402,7 @@ squash_options_get_int_at (SquashOptions* options, SquashCodec* codec, size_t id return -1; } - squash_assert_unreachable (); + HEDLEY_UNREACHABLE (); } /** @@ -418,14 +418,14 @@ squash_options_get_int_at (SquashOptions* options, SquashCodec* codec, size_t id size_t squash_options_get_size_at (SquashOptions* options, SquashCodec* codec, size_t idx) { if (codec == NULL) { - if (SQUASH_UNLIKELY(options == NULL)) + if (HEDLEY_UNLIKELY(options == NULL)) return 0; codec = options->codec; } SquashOptionType type; const SquashOptionValue* val = squash_options_get_value_at (options, codec, NULL, &type, idx); - if (SQUASH_UNLIKELY(val == NULL)) + if (HEDLEY_UNLIKELY(val == NULL)) return 0; switch ((int) type) { @@ -436,7 +436,7 @@ squash_options_get_size_at (SquashOptions* options, SquashCodec* codec, size_t i return 0; } - squash_assert_unreachable (); + HEDLEY_UNREACHABLE (); } /** @@ -571,7 +571,7 @@ squash_options_set_string_at (SquashOptions* options, size_t idx, const char* va return squash_error (SQUASH_BAD_VALUE); } - squash_assert_unreachable (); + HEDLEY_UNREACHABLE (); } /** @@ -605,7 +605,7 @@ squash_options_set_bool_at (SquashOptions* options, size_t idx, bool value) { return squash_error (SQUASH_BAD_VALUE); } - squash_assert_unreachable (); + HEDLEY_UNREACHABLE (); } /** @@ -645,7 +645,7 @@ squash_options_set_int_at (SquashOptions* options, size_t idx, int value) { return squash_error (SQUASH_BAD_VALUE); } - squash_assert_unreachable (); + HEDLEY_UNREACHABLE (); } /** @@ -679,7 +679,7 @@ squash_options_set_size_at (SquashOptions* options, size_t idx, size_t value) { (value != 0 || !info->info.range_size.allow_zero)) return squash_error (SQUASH_BAD_VALUE); - if (SQUASH_UNLIKELY(!((value == 0 && info->info.range_size.allow_zero) || + if (HEDLEY_UNLIKELY(!((value == 0 && info->info.range_size.allow_zero) || (value >= info->info.range_size.min && value <= info->info.range_size.max)))) return squash_error (SQUASH_BAD_VALUE); } @@ -689,7 +689,7 @@ squash_options_set_size_at (SquashOptions* options, size_t idx, size_t value) { return squash_error (SQUASH_BAD_VALUE); } - squash_assert_unreachable (); + HEDLEY_UNREACHABLE (); } /** @@ -725,16 +725,16 @@ squash_options_parse_option (SquashOptions* options, const char* key, const char char* endptr; long int res = strtol (value, &endptr, 0); - if (SQUASH_UNLIKELY(*endptr != '\0')) + if (HEDLEY_UNLIKELY(*endptr != '\0')) return squash_error (SQUASH_BAD_VALUE); #if INT_MAX < LONG_MAX - if (SQUASH_UNLIKELY(res > INT_MAX)) + if (HEDLEY_UNLIKELY(res > INT_MAX)) return squash_error (SQUASH_RANGE); #endif #if INT_MIN > LONG_MIN - if (SQUASH_UNLIKELY(res < INT_MIN)) + if (HEDLEY_UNLIKELY(res < INT_MIN)) return squash_error (SQUASH_RANGE); #endif return squash_options_set_int_at (options, option_n, res); @@ -747,7 +747,7 @@ squash_options_parse_option (SquashOptions* options, const char* key, const char unsigned long long int i = strtoull (value, &endptr, 10); #if SIZE_MAX < ULLONG_MAX - if (SQUASH_UNLIKELY(i > SIZE_MAX)) + if (HEDLEY_UNLIKELY(i > SIZE_MAX)) return squash_error (SQUASH_RANGE); #endif @@ -759,19 +759,19 @@ squash_options_parse_option (SquashOptions* options, const char* key, const char switch (*endptr) { case 'g': case 'G': - if (SQUASH_UNLIKELY((SIZE_MAX / 1024) < res)) + if (HEDLEY_UNLIKELY((SIZE_MAX / 1024) < res)) return squash_error (SQUASH_RANGE); res *= 1024; /* Fall through */ case 'm': case 'M': - if (SQUASH_UNLIKELY((SIZE_MAX / 1024) < res)) + if (HEDLEY_UNLIKELY((SIZE_MAX / 1024) < res)) return squash_error (SQUASH_RANGE); res *= 1024; /* Fall through */ case 'k': case 'K': - if (SQUASH_UNLIKELY((SIZE_MAX / 1024) < res)) + if (HEDLEY_UNLIKELY((SIZE_MAX / 1024) < res)) return squash_error (SQUASH_RANGE); res *= 1024; break; @@ -785,12 +785,12 @@ squash_options_parse_option (SquashOptions* options, const char* key, const char if (*endptr == 'i' || *endptr == 'I') endptr++; - if (SQUASH_LIKELY(*endptr == 'b' || *endptr == 'B')) + if (HEDLEY_LIKELY(*endptr == 'b' || *endptr == 'B')) endptr++; else return squash_error (SQUASH_BAD_VALUE); - if (SQUASH_UNLIKELY(*endptr != '\0')) + if (HEDLEY_UNLIKELY(*endptr != '\0')) return squash_error (SQUASH_BAD_VALUE); } } @@ -830,10 +830,10 @@ squash_options_parse_option (SquashOptions* options, const char* key, const char case SQUASH_OPTION_TYPE_NONE: default: - squash_assert_unreachable(); + HEDLEY_UNREACHABLE(); } - squash_assert_unreachable(); + HEDLEY_UNREACHABLE(); } /** @@ -1036,7 +1036,7 @@ squash_options_init (void* options, break; case SQUASH_OPTION_TYPE_NONE: default: - squash_assert_unreachable(); + HEDLEY_UNREACHABLE(); } } } @@ -1092,13 +1092,13 @@ squash_options_parse_optionw (SquashOptions* options, const wchar_t* key, const SquashStatus res = SQUASH_OK; nkey = squash_charset_wide_to_utf8 (key); - if (SQUASH_UNLIKELY(nkey == NULL)) { + if (HEDLEY_UNLIKELY(nkey == NULL)) { res = squash_error (SQUASH_FAILED); goto finish; } nvalue = squash_charset_wide_to_utf8 (value); - if (SQUASH_UNLIKELY(nvalue == NULL)) { + if (HEDLEY_UNLIKELY(nvalue == NULL)) { res = squash_error (SQUASH_FAILED); goto finish; } diff --git a/squash/squash-options.h b/squash/squash-options.h index 72dffaf..019c7bb 100644 --- a/squash/squash-options.h +++ b/squash/squash-options.h @@ -37,7 +37,7 @@ #include #include -SQUASH_BEGIN_DECLS +HEDLEY_BEGIN_C_DECLS typedef struct SquashOptionInfoEnumStringMap_ SquashOptionInfoEnumStringMap; typedef struct SquashOptionInfoEnumString_ SquashOptionInfoEnumString; @@ -116,12 +116,12 @@ struct SquashOptionInfo_ { SquashOptionValue default_value; }; -SQUASH_SENTINEL -SQUASH_NONNULL(1) +HEDLEY_SENTINEL(0) +HEDLEY_NON_NULL(1) SQUASH_API SquashOptions* squash_options_new (SquashCodec* codec, ...); -SQUASH_NONNULL(1, 2) +HEDLEY_NON_NULL(1, 2) SQUASH_API SquashOptions* squash_options_newv (SquashCodec* codec, va_list options); -SQUASH_NONNULL(1) +HEDLEY_NON_NULL(1) SQUASH_API SquashOptions* squash_options_newa (SquashCodec* codec, const char* const* keys, const char* const* values); SQUASH_API const char* squash_options_get_string (SquashOptions* options, SquashCodec* codec, const char* key); @@ -134,69 +134,69 @@ SQUASH_API bool squash_options_get_bool_at (SquashOptions* options, SQUASH_API int squash_options_get_int_at (SquashOptions* options, SquashCodec* codec, size_t index); SQUASH_API size_t squash_options_get_size_at (SquashOptions* options, SquashCodec* codec, size_t index); -SQUASH_NONNULL(1, 2, 3) +HEDLEY_NON_NULL(1, 2, 3) SQUASH_API SquashStatus squash_options_set_string (SquashOptions* options, const char* key, const char* value); -SQUASH_NONNULL(1, 2) +HEDLEY_NON_NULL(1, 2) SQUASH_API SquashStatus squash_options_set_bool (SquashOptions* options, const char* key, bool value); -SQUASH_NONNULL(1, 2) +HEDLEY_NON_NULL(1, 2) SQUASH_API SquashStatus squash_options_set_int (SquashOptions* options, const char* key, int value); -SQUASH_NONNULL(1, 2) +HEDLEY_NON_NULL(1, 2) SQUASH_API SquashStatus squash_options_set_size (SquashOptions* options, const char* key, size_t value); -SQUASH_NONNULL(1, 3) +HEDLEY_NON_NULL(1, 3) SQUASH_API SquashStatus squash_options_set_string_at (SquashOptions* options, size_t index, const char* value); -SQUASH_NONNULL(1) +HEDLEY_NON_NULL(1) SQUASH_API SquashStatus squash_options_set_bool_at (SquashOptions* options, size_t index, bool value); -SQUASH_NONNULL(1) +HEDLEY_NON_NULL(1) SQUASH_API SquashStatus squash_options_set_int_at (SquashOptions* options, size_t index, int value); -SQUASH_NONNULL(1) +HEDLEY_NON_NULL(1) SQUASH_API SquashStatus squash_options_set_size_at (SquashOptions* options, size_t index, size_t value); -SQUASH_SENTINEL -SQUASH_NONNULL(1) +HEDLEY_SENTINEL(0) +HEDLEY_NON_NULL(1) SQUASH_API SquashStatus squash_options_parse (SquashOptions* options, ...); -SQUASH_NONNULL(1, 2) +HEDLEY_NON_NULL(1, 2) SQUASH_API SquashStatus squash_options_parsev (SquashOptions* options, va_list options_list); -SQUASH_NONNULL(1) +HEDLEY_NON_NULL(1) SQUASH_API SquashStatus squash_options_parsea (SquashOptions* options, const char* const* keys, const char* const* values); -SQUASH_NONNULL(1, 2, 3) +HEDLEY_NON_NULL(1, 2, 3) SQUASH_API SquashStatus squash_options_parse_option (SquashOptions* options, const char* key, const char* value); -SQUASH_NONNULL(1, 2) +HEDLEY_NON_NULL(1, 2) SQUASH_API void squash_options_init (void* options, SquashCodec* codec, SquashDestroyNotify destroy_notify); -SQUASH_NONNULL(1) +HEDLEY_NON_NULL(1) SQUASH_API void squash_options_destroy (void* options); #if defined(SQUASH_ENABLE_WIDE_CHAR_API) -SQUASH_SENTINEL -SQUASH_NONNULL(1) +HEDLEY_SENTINEL(0) +HEDLEY_NON_NULL(1) SQUASH_API SquashOptions* squash_options_neww (SquashCodec* codec, ...); -SQUASH_NONNULL(1, 2) +HEDLEY_NON_NULL(1, 2) SQUASH_API SquashOptions* squash_options_newvw (SquashCodec* codec, va_list options); -SQUASH_NONNULL(1) +HEDLEY_NON_NULL(1) SQUASH_API SquashOptions* squash_options_newaw (SquashCodec* codec, const wchar_t* const* keys, const wchar_t* const* values); -SQUASH_NONNULL(2, 3) +HEDLEY_NON_NULL(2, 3) SQUASH_API const char* squash_options_get_stringw (SquashOptions* options, SquashCodec* codec, const char* key); -SQUASH_NONNULL(2, 3) +HEDLEY_NON_NULL(2, 3) SQUASH_API bool squash_options_get_boolw (SquashOptions* options, SquashCodec* codec, const char* key); -SQUASH_NONNULL(2, 3) +HEDLEY_NON_NULL(2, 3) SQUASH_API int squash_options_get_intw (SquashOptions* options, SquashCodec* codec, const char* key); -SQUASH_NONNULL(2, 3) +HEDLEY_NON_NULL(2, 3) SQUASH_API size_t squash_options_get_sizew (SquashOptions* options, SquashCodec* codec, const char* key); -SQUASH_SENTINEL -SQUASH_NONNULL(1) +HEDLEY_SENTINEL(0) +HEDLEY_NON_NULL(1) SQUASH_API SquashStatus squash_options_parsew (SquashOptions* options, ...); -SQUASH_NONNULL(1, 2) +HEDLEY_NON_NULL(1, 2) SQUASH_API SquashStatus squash_options_parsevw (SquashOptions* options, va_list options_list); -SQUASH_NONNULL(1) +HEDLEY_NON_NULL(1) SQUASH_API SquashStatus squash_options_parseaw (SquashOptions* options, const wchar_t* const* keys, const wchar_t* const* values); -SQUASH_NONNULL(1, 2, 3) +HEDLEY_NON_NULL(1, 2, 3) SQUASH_API SquashStatus squash_options_parse_optionw (SquashOptions* options, const wchar_t* key, const wchar_t* value); #endif -SQUASH_END_DECLS +HEDLEY_END_C_DECLS #endif /* SQUASH_OPTIONS_H */ diff --git a/squash/squash-plugin-internal.h b/squash/squash-plugin-internal.h index f9b5a47..3a9a66b 100644 --- a/squash/squash-plugin-internal.h +++ b/squash/squash-plugin-internal.h @@ -32,22 +32,22 @@ #error "This is internal API; you cannot use it." #endif -SQUASH_BEGIN_DECLS +HEDLEY_BEGIN_C_DECLS -SQUASH_NONNULL(1, 2, 3) SQUASH_INTERNAL +HEDLEY_NON_NULL(1, 2, 3) SQUASH_INTERNAL SquashPlugin* squash_plugin_new (char* name, char* directory, SquashContext* context); -SQUASH_NONNULL(1, 2) SQUASH_INTERNAL +HEDLEY_NON_NULL(1, 2) SQUASH_INTERNAL void squash_plugin_add_codec (SquashPlugin* plugin, SquashCodec* codec); -SQUASH_NONNULL(1) SQUASH_INTERNAL +HEDLEY_NON_NULL(1) SQUASH_INTERNAL SquashStatus squash_plugin_load (SquashPlugin* plugin); -SQUASH_NONNULL(1, 2, 3) SQUASH_INTERNAL +HEDLEY_NON_NULL(1, 2, 3) SQUASH_INTERNAL SquashStatus squash_plugin_init_codec (SquashPlugin* plugin, SquashCodec* codec, SquashCodecImpl* impl); -SQUASH_NONNULL(1, 2) SQUASH_INTERNAL +HEDLEY_NON_NULL(1, 2) SQUASH_INTERNAL int squash_plugin_compare (SquashPlugin* a, SquashPlugin* b); SQUASH_TREE_PROTOTYPES(SquashPlugin_, tree) SQUASH_TREE_DEFINE(SquashPlugin_, tree) -SQUASH_END_DECLS +HEDLEY_END_C_DECLS #endif /* SQUASH_PLUGIN_INTERNAL_H */ diff --git a/squash/squash-plugin.c b/squash/squash-plugin.c index 9b2921e..98dcc5e 100644 --- a/squash/squash-plugin.c +++ b/squash/squash-plugin.c @@ -156,7 +156,7 @@ squash_plugin_init (SquashPlugin* plugin) { squash_free (plugin_file_name); - if (SQUASH_LIKELY(handle != NULL)) { + if (HEDLEY_LIKELY(handle != NULL)) { SQUASH_MTX_LOCK(plugin_init); if (plugin->plugin == NULL) { plugin->plugin = handle; @@ -186,7 +186,7 @@ squash_plugin_init (SquashPlugin* plugin) { } } - return SQUASH_LIKELY(plugin->plugin != NULL) ? SQUASH_OK : squash_error (SQUASH_UNABLE_TO_LOAD); + return HEDLEY_LIKELY(plugin->plugin != NULL) ? SQUASH_OK : squash_error (SQUASH_UNABLE_TO_LOAD); } /** @@ -288,12 +288,12 @@ squash_plugin_init_codec (SquashPlugin* plugin, SquashCodec* codec, SquashCodecI *(void **) (&init_codec_func) = GetProcAddress (plugin->plugin, "squash_plugin_init_codec"); #endif - if (SQUASH_UNLIKELY(init_codec_func == NULL)) { + if (HEDLEY_UNLIKELY(init_codec_func == NULL)) { return squash_error (SQUASH_UNABLE_TO_LOAD); } SQUASH_MTX_LOCK(codec_init); - if (SQUASH_LIKELY(codec->initialized == 0)) { + if (HEDLEY_LIKELY(codec->initialized == 0)) { res = init_codec_func (codec, impl); codec->initialized = (res == SQUASH_OK); diff --git a/squash/squash-plugin.h b/squash/squash-plugin.h index 4030c3c..273d201 100644 --- a/squash/squash-plugin.h +++ b/squash/squash-plugin.h @@ -33,21 +33,21 @@ #error "Only can be included directly." #endif -SQUASH_BEGIN_DECLS +HEDLEY_BEGIN_C_DECLS -SQUASH_NONNULL(1) +HEDLEY_NON_NULL(1) SQUASH_API SquashStatus squash_plugin_init (SquashPlugin* plugin); -SQUASH_NONNULL(1) +HEDLEY_NON_NULL(1) SQUASH_API const char* squash_plugin_get_name (SquashPlugin* plugin); -SQUASH_NONNULL(1) +HEDLEY_NON_NULL(1) SQUASH_API SquashLicense* squash_plugin_get_licenses (SquashPlugin* plugin); -SQUASH_NONNULL(1, 2) +HEDLEY_NON_NULL(1, 2) SQUASH_API SquashCodec* squash_plugin_get_codec (SquashPlugin* plugin, const char* codec); typedef void (*SquashPluginForeachFunc) (SquashPlugin* plugin, void* data); -SQUASH_NONNULL(1, 2) +HEDLEY_NON_NULL(1, 2) SQUASH_API void squash_plugin_foreach_codec (SquashPlugin* plugin, SquashCodecForeachFunc func, void* data); #if defined _WIN32 || defined __CYGWIN__ @@ -64,6 +64,6 @@ SQUASH_API void squash_plugin_foreach_codec (SquashPlugin* plugin, Sq # endif #endif -SQUASH_END_DECLS +HEDLEY_END_C_DECLS #endif /* SQUASH_PLUGIN_H */ diff --git a/squash/squash-slist-internal.h b/squash/squash-slist-internal.h index 9a8d011..d2d8ef7 100644 --- a/squash/squash-slist-internal.h +++ b/squash/squash-slist-internal.h @@ -38,7 +38,7 @@ #define inline __inline #endif -SQUASH_BEGIN_DECLS +HEDLEY_BEGIN_C_DECLS typedef struct SquashSList_ { struct SquashSList_* next; @@ -91,6 +91,6 @@ squash_slist_append (SquashSList* list, size_t elem_size) { #define SQUASH_SLIST_APPEND(l,T) \ ((T*) squash_slist_append ((SquashSList*) l, sizeof (T))) -SQUASH_END_DECLS +HEDLEY_END_C_DECLS #endif /* SQUASH_SLIST_INTERNAL_H */ diff --git a/squash/squash-splice.c b/squash/squash-splice.c index 2d018f8..4765c47 100644 --- a/squash/squash-splice.c +++ b/squash/squash-splice.c @@ -225,13 +225,13 @@ squash_splice_stream (FILE* fp_in, #endif /* defined(SQUASH_MMAP_IO) */ file = squash_file_steal_with_options (codec, (stream_type == SQUASH_STREAM_COMPRESS ? fp_out : fp_in), options); - if (SQUASH_UNLIKELY(file == NULL)) { + if (HEDLEY_UNLIKELY(file == NULL)) { res = squash_error (SQUASH_FAILED); goto cleanup; } data = squash_malloc (SQUASH_FILE_BUF_SIZE); - if (SQUASH_UNLIKELY(data == NULL)) { + if (HEDLEY_UNLIKELY(data == NULL)) { res = squash_error (SQUASH_MEMORY); goto cleanup; } @@ -242,7 +242,7 @@ squash_splice_stream (FILE* fp_in, data_size = SQUASH_FREAD_UNLOCKED(data, 1, req_size, fp_in); if (data_size == 0) { - res = SQUASH_LIKELY(feof (fp_in)) ? SQUASH_OK : squash_error (SQUASH_IO); + res = HEDLEY_LIKELY(feof (fp_in)) ? SQUASH_OK : squash_error (SQUASH_IO); goto cleanup; } @@ -268,7 +268,7 @@ squash_splice_stream (FILE* fp_in, if (data_size > 0) { size_t bytes_written = SQUASH_FWRITE_UNLOCKED(data, 1, data_size, fp_out); assert (bytes_written == data_size); - if (SQUASH_UNLIKELY(bytes_written == 0)) { + if (HEDLEY_UNLIKELY(bytes_written == 0)) { res = squash_error (SQUASH_IO); break; } @@ -326,7 +326,7 @@ struct SquashFileSpliceData { static SquashStatus squash_file_splice_read (size_t* data_size, - uint8_t data[SQUASH_ARRAY_PARAM(*data_size)], + uint8_t data[HEDLEY_ARRAY_PARAM(*data_size)], void* user_data) { struct SquashFileSpliceData* ctx = (struct SquashFileSpliceData*) user_data; @@ -351,7 +351,7 @@ squash_file_splice_read (size_t* data_size, ctx->pos += bytes_read; if (bytes_read == 0) { - return SQUASH_LIKELY(feof (ctx->fp_in)) ? SQUASH_END_OF_STREAM : squash_error (SQUASH_IO); + return HEDLEY_LIKELY(feof (ctx->fp_in)) ? SQUASH_END_OF_STREAM : squash_error (SQUASH_IO); } else { return SQUASH_OK; } @@ -359,14 +359,14 @@ squash_file_splice_read (size_t* data_size, static SquashStatus squash_file_splice_write (size_t* data_size, - const uint8_t data[SQUASH_ARRAY_PARAM(*data_size)], + const uint8_t data[HEDLEY_ARRAY_PARAM(*data_size)], void* user_data) { struct SquashFileSpliceData* ctx = (struct SquashFileSpliceData*) user_data; const size_t requested = *data_size; *data_size = SQUASH_FWRITE_UNLOCKED(data, 1, requested, ctx->fp_out); - return SQUASH_LIKELY(*data_size == requested) ? SQUASH_OK : squash_error (SQUASH_IO); + return HEDLEY_LIKELY(*data_size == requested) ? SQUASH_OK : squash_error (SQUASH_IO); } /* I would care more about the absurd name if this were exposed publicly. */ @@ -460,7 +460,7 @@ struct SquashSpliceLimitedData { static SQUASH_THREAD_LOCAL SquashStatus squash_splice_custom_limited_res; static SquashStatus -squash_splice_custom_limited_write (size_t* data_size, const uint8_t data[SQUASH_ARRAY_PARAM(*data_size)], void* user_data) { +squash_splice_custom_limited_write (size_t* data_size, const uint8_t data[HEDLEY_ARRAY_PARAM(*data_size)], void* user_data) { assert (user_data != NULL); SquashStatus res = SQUASH_OK; @@ -493,7 +493,7 @@ squash_splice_custom_limited_write (size_t* data_size, const uint8_t data[SQUASH } static SquashStatus -squash_splice_custom_limited_read (size_t* data_size, uint8_t data[SQUASH_ARRAY_PARAM(*data_size)], void* user_data) { +squash_splice_custom_limited_read (size_t* data_size, uint8_t data[HEDLEY_ARRAY_PARAM(*data_size)], void* user_data) { assert (user_data != NULL); struct SquashSpliceLimitedData* ctx = user_data; @@ -551,13 +551,13 @@ squash_splice_custom_with_options (SquashCodec* codec, } } else if (codec->impl.process_stream) { SquashStream* stream = squash_stream_new_with_options(codec, stream_type, options); - if (SQUASH_UNLIKELY(stream == NULL)) + if (HEDLEY_UNLIKELY(stream == NULL)) return squash_error (SQUASH_FAILED); uint8_t* const in_buf = squash_malloc (SQUASH_SPLICE_BUF_SIZE); uint8_t* const out_buf = squash_malloc (SQUASH_SPLICE_BUF_SIZE); - if (SQUASH_UNLIKELY(in_buf == NULL) || SQUASH_UNLIKELY(out_buf == NULL)) { + if (HEDLEY_UNLIKELY(in_buf == NULL) || HEDLEY_UNLIKELY(out_buf == NULL)) { res = squash_error (SQUASH_MEMORY); goto cleanup_stream; } @@ -633,14 +633,14 @@ squash_splice_custom_with_options (SquashCodec* codec, const size_t old_size = buffer->size; const size_t read_request = limit_input ? (size - old_size): SQUASH_SPLICE_BUF_SIZE; - if (SQUASH_UNLIKELY(!squash_buffer_set_size (buffer, old_size + read_request))) { + if (HEDLEY_UNLIKELY(!squash_buffer_set_size (buffer, old_size + read_request))) { res = squash_error (SQUASH_MEMORY); goto cleanup_buffer; } size_t bytes_read = read_request; res = read_cb (&bytes_read, buffer->data + old_size, user_data); - if (SQUASH_UNLIKELY(res < 0)) { + if (HEDLEY_UNLIKELY(res < 0)) { goto cleanup_buffer; } @@ -656,7 +656,7 @@ squash_splice_custom_with_options (SquashCodec* codec, if (stream_type == SQUASH_STREAM_COMPRESS) { out_data_size = squash_codec_get_max_compressed_size (codec, buffer->size); out_data = squash_malloc (out_data_size); - if (SQUASH_UNLIKELY(out_data == NULL)) { + if (HEDLEY_UNLIKELY(out_data == NULL)) { res = squash_error (SQUASH_MEMORY); goto cleanup_buffer; } @@ -670,13 +670,13 @@ squash_splice_custom_with_options (SquashCodec* codec, if (knows_uncompressed) { out_data_size = squash_codec_get_uncompressed_size(codec, buffer->size, buffer->data); - if (SQUASH_UNLIKELY(out_data_size == 0)) { + if (HEDLEY_UNLIKELY(out_data_size == 0)) { res = squash_error (SQUASH_INVALID_BUFFER); goto cleanup_buffer; } out_data = squash_malloc (out_data_size); - if (SQUASH_UNLIKELY(out_data == NULL)) { + if (HEDLEY_UNLIKELY(out_data == NULL)) { res = squash_error (SQUASH_MEMORY); goto cleanup_buffer; } @@ -688,7 +688,7 @@ squash_splice_custom_with_options (SquashCodec* codec, } else { SquashBuffer* decompressed_buffer = squash_buffer_new (0); res = squash_codec_decompress_to_buffer (codec, decompressed_buffer, buffer->size, buffer->data, options); - if (SQUASH_UNLIKELY(res != SQUASH_OK)) { + if (HEDLEY_UNLIKELY(res != SQUASH_OK)) { squash_buffer_free (decompressed_buffer); goto cleanup_buffer; } diff --git a/squash/squash-splice.h b/squash/squash-splice.h index 743ceb0..1ed3995 100644 --- a/squash/squash-splice.h +++ b/squash/squash-splice.h @@ -36,25 +36,25 @@ #include #include -SQUASH_BEGIN_DECLS +HEDLEY_BEGIN_C_DECLS -SQUASH_SENTINEL -SQUASH_NONNULL(1, 3, 4) +HEDLEY_SENTINEL(0) +HEDLEY_NON_NULL(1, 3, 4) SQUASH_API SquashStatus squash_splice (SquashCodec* codec, SquashStreamType stream_type, FILE* fp_out, FILE* fp_in, size_t size, ...); -SQUASH_NONNULL(1, 3, 4) +HEDLEY_NON_NULL(1, 3, 4) SQUASH_API SquashStatus squash_splice_with_options (SquashCodec* codec, SquashStreamType stream_type, FILE* fp_out, FILE* fp_in, size_t size, SquashOptions* options); -SQUASH_SENTINEL -SQUASH_NONNULL(1, 3, 4) +HEDLEY_SENTINEL(0) +HEDLEY_NON_NULL(1, 3, 4) SQUASH_API SquashStatus squash_splice_custom (SquashCodec* codec, SquashStreamType stream_type, SquashWriteFunc write_cb, @@ -62,7 +62,7 @@ SQUASH_API SquashStatus squash_splice_custom (SquashCodec* codec, void* user_data, size_t size, ...); -SQUASH_NONNULL(1, 3, 4) +HEDLEY_NON_NULL(1, 3, 4) SQUASH_API SquashStatus squash_splice_custom_with_options (SquashCodec* codec, SquashStreamType stream_type, SquashWriteFunc write_cb, @@ -71,6 +71,6 @@ SQUASH_API SquashStatus squash_splice_custom_with_options (SquashCodec* codec, size_t size, SquashOptions* options); -SQUASH_END_DECLS +HEDLEY_END_C_DECLS #endif /* SQUASH_SPLICE_H */ diff --git a/squash/squash-status.h b/squash/squash-status.h index db96083..cc16944 100644 --- a/squash/squash-status.h +++ b/squash/squash-status.h @@ -32,7 +32,7 @@ #error "Only can be included directly." #endif -SQUASH_BEGIN_DECLS +HEDLEY_BEGIN_C_DECLS typedef enum { SQUASH_OK = 1, @@ -58,6 +58,6 @@ SQUASH_API const char* squash_status_to_string (SquashStatus status); SQUASH_API SquashStatus squash_error (SquashStatus status); -SQUASH_END_DECLS +HEDLEY_END_C_DECLS #endif /* SQUASH_STATUS_H */ diff --git a/squash/squash-stream-internal.h b/squash/squash-stream-internal.h index d01c8ed..a348ea7 100644 --- a/squash/squash-stream-internal.h +++ b/squash/squash-stream-internal.h @@ -32,7 +32,7 @@ #error "This is internal API; you cannot use it." #endif -SQUASH_BEGIN_DECLS +HEDLEY_BEGIN_C_DECLS struct SquashStreamPrivate_ { thrd_t thread; @@ -50,6 +50,6 @@ struct SquashStreamPrivate_ { #define SQUASH_OPERATION_INVALID ((SquashOperation) 0) #define SQUASH_STATUS_INVALID ((SquashStatus) 0) -SQUASH_END_DECLS +HEDLEY_END_C_DECLS #endif /* !defined(SQUASH_STREAM_INTERNAL_H) */ diff --git a/squash/squash-stream.c b/squash/squash-stream.c index f39faf1..93f32e6 100644 --- a/squash/squash-stream.c +++ b/squash/squash-stream.c @@ -229,7 +229,7 @@ squash_stream_yield (SquashStream* stream, SquashStatus status) { static SquashStatus squash_stream_read_cb (size_t* data_size, - uint8_t data[SQUASH_ARRAY_PARAM(*data_size)], + uint8_t data[HEDLEY_ARRAY_PARAM(*data_size)], void* user_data) { assert (user_data != NULL); assert (data_size != NULL); @@ -267,7 +267,7 @@ squash_stream_read_cb (size_t* data_size, static SquashStatus squash_stream_write_cb (size_t* data_size, - const uint8_t data[SQUASH_ARRAY_PARAM(*data_size)], + const uint8_t data[HEDLEY_ARRAY_PARAM(*data_size)], void* user_data) { assert (user_data != NULL); assert (data_size != NULL); @@ -460,7 +460,7 @@ squash_stream_destroy (void* stream) { s = (SquashStream*) stream; - if (SQUASH_UNLIKELY(s->priv != NULL)) { + if (HEDLEY_UNLIKELY(s->priv != NULL)) { SquashStreamPrivate* priv = (SquashStreamPrivate*) s->priv; if (!priv->finished) { @@ -577,7 +577,7 @@ squash_stream_process_internal (SquashStream* stream, SquashOperation operation) /* Flush is optional, so return an error if it doesn't exist but flushing was requested. */ - if (SQUASH_UNLIKELY(operation == SQUASH_OPERATION_FLUSH && ((impl->info & SQUASH_CODEC_INFO_CAN_FLUSH) == 0))) { + if (HEDLEY_UNLIKELY(operation == SQUASH_OPERATION_FLUSH && ((impl->info & SQUASH_CODEC_INFO_CAN_FLUSH) == 0))) { return squash_error (SQUASH_INVALID_OPERATION); } @@ -621,7 +621,7 @@ squash_stream_process_internal (SquashStream* stream, SquashOperation operation) break; } - if (SQUASH_UNLIKELY(current_operation > operation)) { + if (HEDLEY_UNLIKELY(current_operation > operation)) { return squash_error (SQUASH_STATE); } @@ -734,7 +734,7 @@ squash_stream_process_internal (SquashStream* stream, SquashOperation operation) /* Plugins *should* return SQUASH_OK, not SQUASH_END_OF_STREAM, from the finish function, but it's an easy mistake to make (and correct), so... */ - if (SQUASH_UNLIKELY(res == SQUASH_END_OF_STREAM)) { + if (HEDLEY_UNLIKELY(res == SQUASH_END_OF_STREAM)) { res = SQUASH_OK; } @@ -752,7 +752,7 @@ squash_stream_process_internal (SquashStream* stream, SquashOperation operation) /* Check our internal single byte buffer */ if (next_out != 0) { - if (SQUASH_UNLIKELY(stream->avail_out == 0)) { + if (HEDLEY_UNLIKELY(stream->avail_out == 0)) { res = squash_error (SQUASH_BUFFER_FULL); } } diff --git a/squash/squash-stream.h b/squash/squash-stream.h index e7dfeaf..75c8695 100644 --- a/squash/squash-stream.h +++ b/squash/squash-stream.h @@ -36,7 +36,7 @@ #error "Only can be included directly." #endif -SQUASH_BEGIN_DECLS +HEDLEY_BEGIN_C_DECLS typedef struct SquashStreamPrivate_ SquashStreamPrivate; @@ -81,41 +81,41 @@ struct SquashStream_ { SquashDestroyNotify destroy_user_data; }; -SQUASH_SENTINEL -SQUASH_NONNULL(1) +HEDLEY_SENTINEL(0) +HEDLEY_NON_NULL(1) SQUASH_API SquashStream* squash_stream_new (SquashCodec* codec, SquashStreamType stream_type, ...); -SQUASH_NONNULL(1, 3) +HEDLEY_NON_NULL(1, 3) SQUASH_API SquashStream* squash_stream_newv (SquashCodec* codec, SquashStreamType stream_type, va_list options); -SQUASH_NONNULL(1) +HEDLEY_NON_NULL(1) SQUASH_API SquashStream* squash_stream_newa (SquashCodec* codec, SquashStreamType stream_type, const char* const* keys, const char* const* values); -SQUASH_NONNULL(1) +HEDLEY_NON_NULL(1) SQUASH_API SquashStream* squash_stream_new_with_options (SquashCodec* codec, SquashStreamType stream_type, SquashOptions* options); -SQUASH_NONNULL(1) +HEDLEY_NON_NULL(1) SQUASH_API SquashStatus squash_stream_process (SquashStream* stream); -SQUASH_NONNULL(1) +HEDLEY_NON_NULL(1) SQUASH_API SquashStatus squash_stream_flush (SquashStream* stream); -SQUASH_NONNULL(1) +HEDLEY_NON_NULL(1) SQUASH_API SquashStatus squash_stream_finish (SquashStream* stream); -SQUASH_NONNULL(1, 2) +HEDLEY_NON_NULL(1, 2) SQUASH_API void squash_stream_init (void* stream, SquashCodec* codec, SquashStreamType stream_type, SquashOptions* options, SquashDestroyNotify destroy_notify); -SQUASH_NONNULL(1) +HEDLEY_NON_NULL(1) SQUASH_API void squash_stream_destroy (void* stream); -SQUASH_END_DECLS +HEDLEY_END_C_DECLS #endif /* SQUASH_STREAM_H */ diff --git a/squash/squash-types-internal.h b/squash/squash-types-internal.h index ca14cb2..a731336 100644 --- a/squash/squash-types-internal.h +++ b/squash/squash-types-internal.h @@ -36,7 +36,7 @@ #include #endif -SQUASH_BEGIN_DECLS +HEDLEY_BEGIN_C_DECLS typedef SQUASH_TREE_HEAD(SquashPluginTree_, SquashPlugin_) SquashPluginTree; typedef SQUASH_TREE_HEAD(SquashCodecTree_, SquashCodec_) SquashCodecTree; @@ -91,6 +91,6 @@ typedef struct SquashBuffer_ { size_t allocated; } SquashBuffer; -SQUASH_END_DECLS +HEDLEY_END_C_DECLS #endif /* SQUASH_TYPES_INTERNAL_H */ diff --git a/squash/squash-types.h b/squash/squash-types.h index 3ab4f4f..33f651a 100644 --- a/squash/squash-types.h +++ b/squash/squash-types.h @@ -34,7 +34,7 @@ #include -SQUASH_BEGIN_DECLS +HEDLEY_BEGIN_C_DECLS typedef struct SquashObject_ SquashObject; typedef struct SquashOptions_ SquashOptions; @@ -45,6 +45,6 @@ typedef struct SquashCodecImpl_ SquashCodecImpl; typedef struct SquashPlugin_ SquashPlugin; typedef struct SquashFile_ SquashFile; -SQUASH_END_DECLS +HEDLEY_END_C_DECLS #endif /* SQUASH_TYPES_H */ diff --git a/squash/squash-util-internal.h b/squash/squash-util-internal.h index 1221e52..a4b2aca 100644 --- a/squash/squash-util-internal.h +++ b/squash/squash-util-internal.h @@ -32,7 +32,7 @@ #error "This is internal API; you cannot use it." #endif -SQUASH_BEGIN_DECLS +HEDLEY_BEGIN_C_DECLS SQUASH_INTERNAL size_t squash_get_page_size (void); @@ -41,6 +41,6 @@ size_t squash_npot (size_t v); SQUASH_INTERNAL size_t squash_get_huge_page_size (void); -SQUASH_END_DECLS +HEDLEY_END_C_DECLS #endif /* SQUASH_UTIL_INTERNAL_H */ diff --git a/squash/squash-util.c b/squash/squash-util.c index fc99129..4cdfa90 100644 --- a/squash/squash-util.c +++ b/squash/squash-util.c @@ -46,20 +46,20 @@ size_t squash_get_page_size (void) { static size_t page_size = 0; - if (SQUASH_UNLIKELY(page_size == 0)) { + if (HEDLEY_UNLIKELY(page_size == 0)) { #if defined(_WIN32) SYSTEM_INFO si; GetSystemInfo(&si); page_size = si.dwPageSize; #elif defined(_SC_PAGESIZE) const long ps = sysconf (_SC_PAGESIZE); - page_size = SQUASH_UNLIKELY(ps == -1) ? 8192 : ((size_t) ps); + page_size = HEDLEY_UNLIKELY(ps == -1) ? 8192 : ((size_t) ps); #else int hw_pagesize[] = { CTL_HW, HW_PAGESIZE }; unsigned int ps; size_t len = sizeof(ps); int sres = sysctl (hw_pagesize, sizeof(hw_pagesize) / sizeof(*hw_pagesize), &ps, &len, null, 0); - page_size = SQUASH_LIKELY(sres == 0) ? (size_t) ps : 8192; + page_size = HEDLEY_LIKELY(sres == 0) ? (size_t) ps : 8192; #endif } diff --git a/squash/squash-version.c b/squash/squash-version.c index 890c12e..384311b 100644 --- a/squash/squash-version.c +++ b/squash/squash-version.c @@ -61,41 +61,6 @@ * Current version, encoded as a single number */ -/** - * @def SQUASH_VERSION_EXTRACT_MAJOR - * - * Extract the major version number from an encoded version - * - * @see SQUASH_VERSION - */ - -/** - * @def SQUASH_VERSION_EXTRACT_MINOR - * - * Extract the minor version number from an encoded version - * - * @see SQUASH_VERSION - */ - -/** - * @def SQUASH_VERSION_EXTRACT_REVISION - * - * Extract the revision number from an encoded version - * - * @see SQUASH_VERSION - */ - -/** - * @def SQUASH_VERSION(major,minor,revision) - * - * Encode the major, minor, and revisions into a single number - * - * @param major Major version number - * @param minor Minor version number - * @param revision Revision number - * @return Encoded version - */ - /** * @brief Get the library version * diff --git a/squash/squash-version.h.in b/squash/squash-version.h.in index 492fbfe..9b7419a 100644 --- a/squash/squash-version.h.in +++ b/squash/squash-version.h.in @@ -1,4 +1,4 @@ -/* Copyright (c) 2013 The Squash Authors +/* Copyright (c) 2013, 2016 The Squash Authors * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -37,18 +37,13 @@ #define SQUASH_VERSION_REVISION ${SQUASH_VERSION_REVISION} #define SQUASH_VERSION_API "${SQUASH_VERSION_API}" -#define SQUASH_VERSION(major,minor,revision) (((major) << 16) | ((minor) << 8) | (revision)) -#define SQUASH_VERSION_CURRENT SQUASH_VERSION(SQUASH_VERSION_MAJOR, SQUASH_VERSION_MINOR, SQUASH_VERSION_REVISION) +#define SQUASH_VERSION_CURRENT HEDLEY_VERSION_ENCODE(SQUASH_VERSION_MAJOR, SQUASH_VERSION_MINOR, SQUASH_VERSION_REVISION) -#define SQUASH_VERSION_EXTRACT_MAJOR(version) (((version) >> 16) & 0xff) -#define SQUASH_VERSION_EXTRACT_MINOR(version) (((version) >> 8) & 0xff) -#define SQUASH_VERSION_EXTRACT_REVISION(version) ((version) & 0xff) - -SQUASH_BEGIN_DECLS +HEDLEY_BEGIN_C_DECLS SQUASH_API unsigned int squash_version (void); SQUASH_API const char* squash_version_api (void); -SQUASH_END_DECLS +HEDLEY_END_C_DECLS #endif /* SQUASH_VERSION_H */ diff --git a/squash/squash.h b/squash/squash.h index 78e7582..1a16b57 100644 --- a/squash/squash.h +++ b/squash/squash.h @@ -33,6 +33,8 @@ #include #include +#include "hedley/hedley.h" + #if !defined(SQUASH_DISABLE_WIDE_CHAR_API) && !defined(SQUASH_ENABLE_WIDE_CHAR_API) # define SQUASH_ENABLE_WIDE_CHAR_API #endif @@ -41,66 +43,6 @@ # include #endif -#ifdef __cplusplus -# define SQUASH_BEGIN_DECLS extern "C" { -# define SQUASH_END_DECLS } -#else -# define SQUASH_BEGIN_DECLS -# define SQUASH_END_DECLS -#endif - -#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus) -# define SQUASH_ARRAY_PARAM(name) name -#else -# define SQUASH_ARRAY_PARAM(name) -#endif - -#if defined(__GNUC__) -# define squash_assert_unreachable() do { assert(false); __builtin_unreachable(); } while(0) -#elif defined(_MSC_VER) -# define squash_assert_unreachable() __assume(0) -#else -# define squash_assert_unreachable() assert(false) -#endif - -#if defined(__clang__) -# if __has_attribute(sentinel) -# define SQUASH_SENTINEL __attribute__((__sentinel__)) -# else -# define SQUASH_SENTINEL -# endif -#elif defined(__GNUC__) -# define SQUASH_SENTINEL __attribute__((__sentinel__)) -#else -# define SQUASH_SENTINEL -#endif - -#if defined(__clang__) -# if __has_attribute(nonnull) -# define SQUASH_NONNULL(...) __attribute__((__nonnull__ (__VA_ARGS__))) -# else -# define SQUASH_NONNULL(...) -# endif -#elif !defined(__INTEL_COMPILER) && defined(__GNUC__) && (__GNUC__ >= 5) -# if defined(NDEBUG) -# define SQUASH_NONNULL(...) __attribute__((__nonnull__ (__VA_ARGS__))) -# else -# define SQUASH_NONNULL(...) __attribute__((__nonnull__ (__VA_ARGS__))) __attribute__((__optimize__("no-isolate-erroneous-paths-attribute"))) -# endif -#elif defined(__GNUC__) -# define SQUASH_NONNULL(...) __attribute__((__nonnull__ (__VA_ARGS__))) -#else -# define SQUASH_NONNULL(...) -#endif - -#if defined(__clang__) || defined(__GNUC__) -# define SQUASH_LIKELY(expr) (__builtin_expect ((expr) != 0, 1)) -# define SQUASH_UNLIKELY(expr) (__builtin_expect ((expr) != 0, 0)) -#else -# define SQUASH_LIKELY(expr) (expr) -# define SQUASH_UNLIKELY(expr) (expr) -#endif - #if defined(_Thread_local) || (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201102L)) # define SQUASH_THREAD_LOCAL _Thread_local #elif defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(__SUNPRO_CC) || defined(__IBMCPP__) @@ -127,9 +69,9 @@ #endif #if defined(SQUASH_COMPILATION) -# define SQUASH_API SQUASH_EXTERNAL +# define SQUASH_API HEDLEY_PUBLIC #else -# define SQUASH_API SQUASH_IMPORT +# define SQUASH_API HEDLEY_IMPORT #endif #include diff --git a/tests/buffer.c b/tests/buffer.c index 32a5b55..2e06192 100644 --- a/tests/buffer.c +++ b/tests/buffer.c @@ -90,7 +90,7 @@ squash_test_endianness(MUNIT_UNUSED const MunitParameter params[], void* user_da return MUNIT_SKIP; FILE* fp = fopen(filename, "rb"); - if (SQUASH_UNLIKELY(fp == NULL)) + if (HEDLEY_UNLIKELY(fp == NULL)) return MUNIT_ERROR; compressed_length = fread(compressed, 1, compressed_length, fp); diff --git a/tests/stream.c b/tests/stream.c index cc36114..1e98e6a 100644 --- a/tests/stream.c +++ b/tests/stream.c @@ -3,9 +3,9 @@ static SquashStatus buffer_to_buffer_compress_with_stream (SquashCodec* codec, size_t* compressed_length, - uint8_t compressed[SQUASH_ARRAY_PARAM(*compressed_length)], + uint8_t compressed[HEDLEY_ARRAY_PARAM(*compressed_length)], size_t uncompressed_length, - const uint8_t uncompressed[SQUASH_ARRAY_PARAM(uncompressed_length)]) { + const uint8_t uncompressed[HEDLEY_ARRAY_PARAM(uncompressed_length)]) { size_t step_size = munit_rand_int_range (64, 255); SquashStream* stream = squash_codec_create_stream (codec, SQUASH_STREAM_COMPRESS, NULL); SquashStatus res; @@ -72,9 +72,9 @@ squash_test_stream_compress(MUNIT_UNUSED const MunitParameter params[], void* us static SquashStatus buffer_to_buffer_decompress_with_stream (SquashCodec* codec, size_t* decompressed_length, - uint8_t decompressed[SQUASH_ARRAY_PARAM(*decompressed_length)], + uint8_t decompressed[HEDLEY_ARRAY_PARAM(*decompressed_length)], size_t compressed_length, - const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_length)]) { + const uint8_t compressed[HEDLEY_ARRAY_PARAM(compressed_length)]) { size_t step_size = munit_rand_int_range (64, 255); SquashStream* stream = squash_codec_create_stream (codec, SQUASH_STREAM_DECOMPRESS, NULL); SquashStatus res = SQUASH_OK; diff --git a/tests/threads.c b/tests/threads.c index 3cc6455..122627f 100644 --- a/tests/threads.c +++ b/tests/threads.c @@ -12,7 +12,7 @@ static unsigned int squash_test_cpu_count (void) { static unsigned int count = 0; - if (SQUASH_UNLIKELY (count == 0)) { + if (HEDLEY_UNLIKELY (count == 0)) { unsigned int c = 0; #if defined(_WIN32) diff --git a/utils/squash.c b/utils/squash.c index aa2abc6..f22eaca 100644 --- a/utils/squash.c +++ b/utils/squash.c @@ -74,9 +74,9 @@ print_version_and_exit (int argc, char** argv, int exit_code) { const unsigned int libversion = squash_version (); fprintf (stdout, "squash version %d.%d.%d (library version %d.%d.%d)\n", SQUASH_VERSION_MAJOR, SQUASH_VERSION_MINOR, SQUASH_VERSION_REVISION, - SQUASH_VERSION_EXTRACT_MAJOR(libversion), - SQUASH_VERSION_EXTRACT_MINOR(libversion), - SQUASH_VERSION_EXTRACT_REVISION(libversion)); + HEDLEY_VERSION_DECODE_MAJOR(libversion), + HEDLEY_VERSION_DECODE_MINOR(libversion), + HEDLEY_VERSION_DECODE_REVISION(libversion)); exit (exit_code); }