aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJia Tan <jiat0218@gmail.com>2023-01-11 20:42:29 +0800
committerLasse Collin <lasse.collin@tukaani.org>2023-01-11 17:31:54 +0200
commit21625b7e11d004788e40eb5eb88d9d89f65fe347 (patch)
treeacc10146f4e4033cc064fe9e8e8b87f0d29cbcf1 /tests
parentliblzma: CLMUL CRC64: Work around a bug in MSVC, second attempt. (diff)
downloadxz-21625b7e11d004788e40eb5eb88d9d89f65fe347.tar.xz
Tests: Fix type-limits warning in test_filter_flags.
This only occurs in test_filter_flags when the BCJ filters are not configured and built. In this case, ARRAY_SIZE() returns 0 and causes a type-limits warning with the loop variable since an unsigned number will always be >= 0.
Diffstat (limited to 'tests')
-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 = {