]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Fix testsuite warnings on Windows, using PRIu64
authorJosh Triplett <josh@joshtriplett.org>
Sun, 16 Aug 2020 23:12:13 +0000 (16:12 -0700)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Thu, 20 Aug 2020 10:05:55 +0000 (12:05 +0200)
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.

test/example.c
test/fuzz/example_large_fuzzer.c
test/infcover.c
trees_emit.h

index c744fe71ec0b5efda2ea68657eb201d7e556ee0c..70969f46e545c7f516d84c10a4ae88815e908cb0 100644 (file)
@@ -16,6 +16,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include <inttypes.h>
+#include <stdint.h>
 
 #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");
index 4f90a7ff729d4e0537e4a6a3e29370e0a1cc8d3a..bd27a84f12093a6080baa38fd5145a472712248d 100644 (file)
@@ -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);
     }
 }
index 6c96bb565087fab1cd1dfe3c904237e607eddbf1..ebba626cf5defde40691f654271d31aae601ab14 100644 (file)
@@ -10,6 +10,8 @@
 #include <string.h>
 #undef NDEBUG
 #include <assert.h>
+#include <inttypes.h>
+#include <stdint.h>
 
 /* 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)
index 4cb17db85cc9dcfb52bc97fde68d2c95591d5030..512429f3d7ddd61498d85d0a0bd3a3248979c212 100644 (file)
@@ -6,8 +6,11 @@
 
 #ifdef ZLIB_DEBUG
 #  include <ctype.h>
+#  include <inttypes.h>
+#  include <stdint.h>
 #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;
 }