From: Mark Adler Date: Sat, 31 Dec 2016 06:05:05 +0000 (-0800) Subject: Avoid some random compiler warnings on various platforms. X-Git-Tag: 1.9.9-b1~711 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a7edd5a1a6be7cf6ee5f789df09020d323a91ab9;p=thirdparty%2Fzlib-ng.git Avoid some random compiler warnings on various platforms. --- diff --git a/deflate.c b/deflate.c index 90415d35a..2b3e88f2f 100644 --- a/deflate.c +++ b/deflate.c @@ -418,11 +418,12 @@ int ZEXPORT deflateSetDictionary(z_stream *strm, const unsigned char *dictionary /* ========================================================================= */ int ZEXPORT deflateGetDictionary (z_stream *strm, unsigned char *dictionary, unsigned int *dictLength) { deflate_state *s; + unsigned int len; if (deflateStateCheck(strm)) return Z_STREAM_ERROR; s = strm->state; - unsigned int len = s->strstart + s->lookahead; + len = s->strstart + s->lookahead; if (len > s->w_size) len = s->w_size; if (dictionary != NULL && len) @@ -1434,12 +1435,12 @@ static block_state deflate_stored(deflate_state *s, int 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 216d978ac..71d50b1e5 100644 --- a/gzwrite.c +++ b/gzwrite.c @@ -203,7 +203,7 @@ static size_t gz_write(gz_statep state, void const *buf, size_t len) { /* directly compress user buffer to file */ state->strm.next_in = (const unsigned char *)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 5bb3cc5d3..d943adc74 100644 --- a/inftrees.c +++ b/inftrees.c @@ -181,7 +181,7 @@ int ZLIB_INTERNAL inflate_table(codetype type, uint16_t *lens, unsigned codes, extra = lext; match = 257; break; - case DISTS: + default: /* DISTS */ base = dbase; extra = dext; match = 0; @@ -207,7 +207,7 @@ int ZLIB_INTERNAL inflate_table(codetype type, uint16_t *lens, unsigned codes, 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]; } else if (work[sym] >= match) { diff --git a/trees.c b/trees.c index f10caa4b2..0beafc724 100644 --- a/trees.c +++ b/trees.c @@ -796,7 +796,7 @@ void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, char *buf, unsigned long s bi_windup(s); /* align on byte boundary */ put_short(s, (uint16_t)stored_len); put_short(s, (uint16_t)~stored_len); - memcpy(s->pending_buf + s->pending, buf, stored_len); + memcpy(s->pending_buf + s->pending, (unsigned char *)buf, stored_len); s->pending += stored_len; #ifdef ZLIB_DEBUG s->compressed_len = (s->compressed_len + 3 + 7) & (unsigned long)~7L;