From 8f147c3d12591a811c5438c011d4203bb7fc5260 Mon Sep 17 00:00:00 2001 From: Mark Adler Date: Fri, 30 Dec 2016 22:05:05 -0800 Subject: [PATCH] Avoid some random compiler warnings on various platforms. --- deflate.c | 7 ++++--- gzwrite.c | 2 +- inftrees.c | 4 ++-- test/example.c | 7 ++++--- test/minigzip.c | 4 ++-- trees.c | 2 +- 6 files changed, 14 insertions(+), 12 deletions(-) diff --git a/deflate.c b/deflate.c index cf4c056..9079741 100644 --- a/deflate.c +++ b/deflate.c @@ -447,11 +447,12 @@ int ZEXPORT deflateGetDictionary (strm, dictionary, dictLength) uInt *dictLength; { deflate_state *s; + uInt len; if (deflateStateCheck(strm)) return Z_STREAM_ERROR; s = strm->state; - uInt len = s->strstart + s->lookahead; + len = s->strstart + s->lookahead; if (len > s->w_size) len = s->w_size; if (dictionary != Z_NULL && len) @@ -1758,12 +1759,12 @@ local block_state deflate_stored(s, flush) * code following this won't be able to either. */ if (flush != Z_NO_FLUSH && s->strm->avail_in == 0 && - s->strstart == s->block_start) + (long)s->strstart == s->block_start) return flush == Z_FINISH ? finish_done : block_done; /* Fill the window with any remaining input. */ have = s->window_size - s->strstart - 1; - if (s->strm->avail_in > have && s->block_start >= s->w_size) { + if (s->strm->avail_in > have && s->block_start >= (long)s->w_size) { /* Slide the window down. */ s->block_start -= s->w_size; s->strstart -= s->w_size; diff --git a/gzwrite.c b/gzwrite.c index 2420514..c29308b 100644 --- a/gzwrite.c +++ b/gzwrite.c @@ -225,7 +225,7 @@ local z_size_t gz_write(state, buf, len) /* directly compress user buffer to file */ state->strm.next_in = (z_const Bytef *)buf; do { - unsigned n = -1; + unsigned n = (unsigned)-1; if (n > len) n = len; state->strm.avail_in = n; diff --git a/inftrees.c b/inftrees.c index 0ea34eb..8b2ad4f 100644 --- a/inftrees.c +++ b/inftrees.c @@ -188,7 +188,7 @@ unsigned short FAR *work; extra = lext; match = 257; break; - case DISTS: + default: /* DISTS */ base = dbase; extra = dext; match = 0; @@ -214,7 +214,7 @@ unsigned short FAR *work; for (;;) { /* create table entry */ here.bits = (unsigned char)(len - drop); - if (work[sym] + 1 < match) { + if (work[sym] + 1U < match) { here.op = (unsigned char)0; here.val = work[sym]; } diff --git a/test/example.c b/test/example.c index 104b2b7..f008749 100644 --- a/test/example.c +++ b/test/example.c @@ -59,13 +59,13 @@ void *myalloc(q, n, m) void *q; unsigned n, m; { - q = Z_NULL; + (void)q; return calloc(n, m); } void myfree(void *q, void *p) { - q = Z_NULL; + (void)q; free(p); } @@ -573,7 +573,8 @@ int main(argc, argv) } #ifdef Z_SOLO - argc = strlen(argv[0]); + (void)argc; + (void)argv; #else test_compress(compr, comprLen, uncompr, uncomprLen); diff --git a/test/minigzip.c b/test/minigzip.c index 850458c..b392304 100644 --- a/test/minigzip.c +++ b/test/minigzip.c @@ -156,14 +156,14 @@ void *myalloc(q, n, m) void *q; unsigned n, m; { - q = Z_NULL; + (void)q; return calloc(n, m); } void myfree(q, p) void *q, *p; { - q = Z_NULL; + (void)q; free(p); } diff --git a/trees.c b/trees.c index 685a388..559a0de 100644 --- a/trees.c +++ b/trees.c @@ -870,7 +870,7 @@ void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last) bi_windup(s); /* align on byte boundary */ put_short(s, (ush)stored_len); put_short(s, (ush)~stored_len); - zmemcpy(s->pending_buf + s->pending, buf, stored_len); + zmemcpy(s->pending_buf + s->pending, (Bytef *)buf, stored_len); s->pending += stored_len; #ifdef ZLIB_DEBUG s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L; -- 2.44.0