aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/test_filter_flags.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/tests/test_filter_flags.c b/tests/test_filter_flags.c
index a0916ab9..28e75d2f 100644
--- a/tests/test_filter_flags.c
+++ b/tests/test_filter_flags.c
@@ -104,7 +104,12 @@ test_lzma_filter_flags_size(void)
assert_true(size != 0 && size < LZMA_BLOCK_HEADER_SIZE_MAX);
}
- for (uint32_t i = 0; i < ARRAY_SIZE(bcj_filters_encoders); i++) {
+ // Do not use macro ARRAY_SIZE() in the for loop condition directly.
+ // If the BCJ filters are not configured and built, then ARRAY_SIZE()
+ // will return 0 and cause a warning because the for loop will never
+ // execute since any unsigned number cannot be < 0 (-Werror=type-limits).
+ const uint32_t bcj_array_size = ARRAY_SIZE(bcj_filters_decoders);
+ for (uint32_t i = 0; i < bcj_array_size; i++) {
assert_lzma_ret(lzma_filter_flags_size(&size,
&bcj_filters_encoders[i]), LZMA_OK);
assert_true(size != 0 && size < LZMA_BLOCK_HEADER_SIZE_MAX);
@@ -215,7 +220,8 @@ test_lzma_filter_flags_encode(void)
.start_offset = 257
};
- for (uint32_t i = 0; i < ARRAY_SIZE(bcj_filters_encoders); i++) {
+ const uint32_t bcj_array_size = ARRAY_SIZE(bcj_filters_decoders);
+ for (uint32_t i = 0; i < bcj_array_size; i++) {
// NULL options should pass for bcj filters
verify_filter_flags_encode(&bcj_filters_encoders[i], true);
lzma_filter bcj_with_options = {
@@ -377,7 +383,8 @@ test_lzma_filter_flags_decode(void)
free(decoded);
}
- for (uint32_t i = 0; i < ARRAY_SIZE(bcj_filters_decoders); i++) {
+ const uint32_t bcj_array_size = ARRAY_SIZE(bcj_filters_decoders);
+ for (uint32_t i = 0; i < bcj_array_size; i++) {
if (lzma_filter_encoder_is_supported(
bcj_filters_decoders[i].id)) {
lzma_filter bcj_decoded = {