From f542e6df737167a9850a4f60104e9dadbdf5ebad Mon Sep 17 00:00:00 2001 From: Cameron Cawley Date: Tue, 20 Jul 2021 17:48:56 +0100 Subject: [PATCH] Fix "Comparison result always 0" warnings with OpenWatcom --- examples/example3.c | 2 +- examples/example4.c | 2 +- examples/example5.c | 2 +- miniz.c | 4 ++-- miniz_zip.c | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/example3.c b/examples/example3.c index a97ba84..a2c6846 100644 --- a/examples/example3.c +++ b/examples/example3.c @@ -100,7 +100,7 @@ int main(int argc, char *argv[]) file_loc = ftell(pInfile); fseek(pInfile, 0, SEEK_SET); - if ((file_loc < 0) || (file_loc > INT_MAX)) + if ((file_loc < 0) || ((mz_uint64)file_loc > INT_MAX)) { // This is not a limitation of miniz or tinfl, but this example. printf("File is too large to be processed by this example.\n"); diff --git a/examples/example4.c b/examples/example4.c index 3f2d7cf..ac49e7f 100644 --- a/examples/example4.c +++ b/examples/example4.c @@ -47,7 +47,7 @@ int main(int argc, char *argv[]) file_loc = ftell(pInfile); fseek(pInfile, 0, SEEK_SET); - if ((file_loc < 0) || (file_loc > INT_MAX)) + if ((file_loc < 0) || ((mz_uint64)file_loc > INT_MAX)) { // This is not a limitation of miniz or tinfl, but this example. printf("File is too large to be processed by this example.\n"); diff --git a/examples/example5.c b/examples/example5.c index a190357..2e47199 100644 --- a/examples/example5.c +++ b/examples/example5.c @@ -132,7 +132,7 @@ int main(int argc, char *argv[]) file_loc = ftell(pInfile); fseek(pInfile, 0, SEEK_SET); - if ((file_loc < 0) || (file_loc > INT_MAX)) + if ((file_loc < 0) || ((mz_uint64)file_loc > INT_MAX)) { // This is not a limitation of miniz or tinfl, but this example. printf("File is too large to be processed by this example.\n"); diff --git a/miniz.c b/miniz.c index bfc234a..83e538a 100644 --- a/miniz.c +++ b/miniz.c @@ -320,7 +320,7 @@ int mz_compress2(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char memset(&stream, 0, sizeof(stream)); /* In case mz_ulong is 64-bits (argh I hate longs). */ - if ((source_len | *pDest_len) > 0xFFFFFFFFU) + if ((mz_uint64)(source_len | *pDest_len) > 0xFFFFFFFFU) return MZ_PARAM_ERROR; stream.next_in = pSource; @@ -559,7 +559,7 @@ int mz_uncompress2(unsigned char *pDest, mz_ulong *pDest_len, const unsigned cha memset(&stream, 0, sizeof(stream)); /* In case mz_ulong is 64-bits (argh I hate longs). */ - if ((*pSource_len | *pDest_len) > 0xFFFFFFFFU) + if ((mz_uint64)(*pSource_len | *pDest_len) > 0xFFFFFFFFU) return MZ_PARAM_ERROR; stream.next_in = pSource; diff --git a/miniz_zip.c b/miniz_zip.c index b372bb2..0ecaf91 100644 --- a/miniz_zip.c +++ b/miniz_zip.c @@ -3194,7 +3194,7 @@ mz_bool mz_zip_writer_add_mem_ex_v2(mz_zip_archive *pZip, const char *pArchive_n pState->m_zip64 = MZ_TRUE; /*return mz_zip_set_error(pZip, MZ_ZIP_TOO_MANY_FILES); */ } - if ((buf_size > 0xFFFFFFFF) || (uncomp_size > 0xFFFFFFFF)) + if (((mz_uint64)buf_size > 0xFFFFFFFF) || (uncomp_size > 0xFFFFFFFF)) { pState->m_zip64 = MZ_TRUE; /*return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE); */ @@ -4299,7 +4299,7 @@ mz_bool mz_zip_writer_finalize_archive(mz_zip_archive *pZip) if (pState->m_zip64) { - if ((pZip->m_total_files > MZ_UINT32_MAX) || (pState->m_central_dir.m_size >= MZ_UINT32_MAX)) + if (((mz_uint64)pZip->m_total_files > MZ_UINT32_MAX) || (pState->m_central_dir.m_size >= MZ_UINT32_MAX)) return mz_zip_set_error(pZip, MZ_ZIP_TOO_MANY_FILES); } else