From: Josh Triplett Date: Sun, 16 Aug 2020 23:12:13 +0000 (-0700) Subject: Fix testsuite warnings on Windows, using PRIu64 X-Git-Tag: 1.9.9-b1~98 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1a46fb9ee1b6926eb8635d32d7f7c1c023a79625;p=thirdparty%2Fzlib-ng.git Fix testsuite warnings on Windows, using PRIu64 zlib-ng already counts on inttypes.h and stdint.h, so use those to avoid printf-related warnings by casting integer fields whose size may vary to uint64_t and printing them that way. --- diff --git a/test/example.c b/test/example.c index c744fe71..70969f46 100644 --- a/test/example.c +++ b/test/example.c @@ -16,6 +16,7 @@ #include #include #include +#include #define TESTFILE "foo.gz" @@ -452,7 +453,7 @@ void test_large_inflate(unsigned char *compr, size_t comprLen, unsigned char *un CHECK_ERR(err, "inflateEnd"); if (d_stream.total_out != 2*uncomprLen + diff) { - fprintf(stderr, "bad large inflate: %zu\n", d_stream.total_out); + fprintf(stderr, "bad large inflate: %" PRIu64 "\n", (uint64_t)d_stream.total_out); exit(1); } else { printf("large_inflate(): OK\n"); diff --git a/test/fuzz/example_large_fuzzer.c b/test/fuzz/example_large_fuzzer.c index 4f90a7ff..bd27a84f 100644 --- a/test/fuzz/example_large_fuzzer.c +++ b/test/fuzz/example_large_fuzzer.c @@ -109,7 +109,7 @@ void test_large_inflate(unsigned char *compr, size_t comprLen, unsigned char *un CHECK_ERR(err, "inflateEnd"); if (d_stream.total_out != 2 * uncomprLen + diff) { - fprintf(stderr, "bad large inflate: %zu\n", d_stream.total_out); + fprintf(stderr, "bad large inflate: %" PRIu64 "\n", (uint64_t)d_stream.total_out); exit(1); } } diff --git a/test/infcover.c b/test/infcover.c index 6c96bb56..ebba626c 100644 --- a/test/infcover.c +++ b/test/infcover.c @@ -10,6 +10,8 @@ #include #undef NDEBUG #include +#include +#include /* get definition of internal structure so we can mess with it (see pull()), and so we can call inflate_trees() (see cover5()) */ @@ -184,14 +186,14 @@ static void mem_limit(PREFIX3(stream) *strm, size_t limit) { static void mem_used(PREFIX3(stream) *strm, char *prefix) { struct mem_zone *zone = strm->opaque; - fprintf(stderr, "%s: %zu allocated\n", prefix, zone->total); + fprintf(stderr, "%s: %" PRIu64 " allocated\n", prefix, (uint64_t)zone->total); } /* show the high water allocation in bytes */ static void mem_high(PREFIX3(stream) *strm, char *prefix) { struct mem_zone *zone = strm->opaque; - fprintf(stderr, "%s: %zu high water mark\n", prefix, zone->highwater); + fprintf(stderr, "%s: %" PRIu64 " high water mark\n", prefix, (uint64_t)zone->highwater); } /* release the memory allocation zone -- if there are any surprises, notify */ @@ -215,8 +217,8 @@ static void mem_done(PREFIX3(stream) *strm, char *prefix) { /* issue alerts about anything unexpected */ if (count || zone->total) - fprintf(stderr, "** %s: %zu bytes in %d blocks not freed\n", - prefix, zone->total, count); + fprintf(stderr, "** %s: %" PRIu64 " bytes in %d blocks not freed\n", + prefix, (uint64_t)zone->total, count); if (zone->notlifo) fprintf(stderr, "** %s: %d frees not LIFO\n", prefix, zone->notlifo); if (zone->rogue) diff --git a/trees_emit.h b/trees_emit.h index 4cb17db8..512429f3 100644 --- a/trees_emit.h +++ b/trees_emit.h @@ -6,8 +6,11 @@ #ifdef ZLIB_DEBUG # include +# include +# include #endif + /* trees.h */ extern ZLIB_INTERNAL const ct_data static_ltree[L_CODES+2]; extern ZLIB_INTERNAL const ct_data static_dtree[D_CODES]; @@ -170,8 +173,8 @@ static inline void zng_emit_end_block(deflate_state *s, const ct_data *ltree, co send_code(s, END_BLOCK, ltree, bi_buf, bi_valid); s->bi_valid = bi_valid; s->bi_buf = bi_buf; - Tracev((stderr, "\n+++ Emit End Block: Last: %u Pending: %u Total Out: %zu\n", - last, s->pending, s->strm->total_out)); + Tracev((stderr, "\n+++ Emit End Block: Last: %u Pending: %u Total Out: %" PRIu64 "\n", + last, s->pending, (uint64_t)s->strm->total_out)); (void)last; }