Tests: Silence warnings from -Wsign-conversion.

Note that assigning an unsigned int to lzma_check doesn't warn
on GNU/Linux x86-64 since the enum type is unsigned on that
platform. The enum can be signed on some other platform though
so it's best to use enumeration type lzma_check in these situations.
This commit is contained in:
Lasse Collin 2023-01-12 03:51:07 +02:00
parent 3f13bf6b9e
commit 49245bb31e
2 changed files with 8 additions and 8 deletions

View File

@ -133,7 +133,7 @@ test_lzma_crc64(void)
static void static void
test_lzma_supported_checks(void) test_lzma_supported_checks(void)
{ {
static const int expected_check_ids[] = { static const lzma_check expected_check_ids[] = {
LZMA_CHECK_NONE, LZMA_CHECK_NONE,
#ifdef HAVE_CHECK_CRC32 #ifdef HAVE_CHECK_CRC32
LZMA_CHECK_CRC32, LZMA_CHECK_CRC32,
@ -146,7 +146,7 @@ test_lzma_supported_checks(void)
#endif #endif
}; };
for (int i = 0; i <= LZMA_CHECK_ID_MAX + 1; i++) { for (lzma_check i = 0; i <= LZMA_CHECK_ID_MAX + 1; i++) {
bool matched = false; bool matched = false;
for (unsigned int j = 0; j < ARRAY_SIZE(expected_check_ids); for (unsigned int j = 0; j < ARRAY_SIZE(expected_check_ids);
j++) { j++) {
@ -173,7 +173,7 @@ test_lzma_check_size(void)
32, 32, 32, 64, 64, 64 32, 32, 32, 64, 64, 64
}; };
for (unsigned int i = 0; i < ARRAY_SIZE(expected_check_sizes); i++) for (lzma_check i = 0; i < ARRAY_SIZE(expected_check_sizes); i++)
assert_uint_eq(expected_check_sizes[i], lzma_check_size(i)); assert_uint_eq(expected_check_sizes[i], lzma_check_size(i));
assert_uint_eq(lzma_check_size(LZMA_CHECK_ID_MAX + 1), UINT32_MAX); assert_uint_eq(lzma_check_size(LZMA_CHECK_ID_MAX + 1), UINT32_MAX);

View File

@ -70,7 +70,7 @@ test_lzma_stream_header_encode(void)
#ifndef HAVE_ENCODERS #ifndef HAVE_ENCODERS
assert_skip("Encoder support disabled"); assert_skip("Encoder support disabled");
#else #else
for (int i = 0; i < LZMA_CHECK_ID_MAX; i++) for (lzma_check i = 0; i < LZMA_CHECK_ID_MAX; i++)
stream_header_encode_helper(i); stream_header_encode_helper(i);
lzma_stream_flags flags = { lzma_stream_flags flags = {
@ -152,7 +152,7 @@ test_lzma_stream_footer_encode(void)
#ifndef HAVE_ENCODERS #ifndef HAVE_ENCODERS
assert_skip("Encoder support disabled"); assert_skip("Encoder support disabled");
#else #else
for (int i = 0; i < LZMA_CHECK_ID_MAX; i++) for (lzma_check i = 0; i < LZMA_CHECK_ID_MAX; i++)
stream_footer_encode_helper(i); stream_footer_encode_helper(i);
lzma_stream_flags flags = { lzma_stream_flags flags = {
@ -223,7 +223,7 @@ test_lzma_stream_header_decode(void)
#if !defined(HAVE_ENCODERS) || !defined(HAVE_DECODERS) #if !defined(HAVE_ENCODERS) || !defined(HAVE_DECODERS)
assert_skip("Encoder or decoder support disabled"); assert_skip("Encoder or decoder support disabled");
#else #else
for (int i = 0; i < LZMA_CHECK_ID_MAX; i++) for (lzma_check i = 0; i < LZMA_CHECK_ID_MAX; i++)
stream_header_decode_helper(i); stream_header_decode_helper(i);
lzma_stream_flags flags = { lzma_stream_flags flags = {
@ -319,7 +319,7 @@ test_lzma_stream_footer_decode(void)
#if !defined(HAVE_ENCODERS) || !defined(HAVE_DECODERS) #if !defined(HAVE_ENCODERS) || !defined(HAVE_DECODERS)
assert_skip("Encoder or decoder support disabled"); assert_skip("Encoder or decoder support disabled");
#else #else
for (int i = 0; i < LZMA_CHECK_ID_MAX; i++) for (lzma_check i = 0; i < LZMA_CHECK_ID_MAX; i++)
stream_footer_decode_helper(i); stream_footer_decode_helper(i);
lzma_stream_flags flags = { lzma_stream_flags flags = {
@ -422,7 +422,7 @@ test_lzma_stream_flags_compare(void)
second.check = LZMA_CHECK_CRC32; second.check = LZMA_CHECK_CRC32;
// Check types must be equal // Check types must be equal
for (uint32_t i = 0; i < LZMA_CHECK_ID_MAX; i++) { for (lzma_check i = 0; i < LZMA_CHECK_ID_MAX; i++) {
first.check = i; first.check = i;
if (i == second.check) if (i == second.check)
assert_lzma_ret(lzma_stream_flags_compare(&first, assert_lzma_ret(lzma_stream_flags_compare(&first,