]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Fix some of the old and new conversion warnings in deflate*
authorHans Kristian Rosbach <hk-git@circlestorm.org>
Tue, 25 Aug 2020 13:47:25 +0000 (15:47 +0200)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Thu, 27 Aug 2020 17:20:38 +0000 (19:20 +0200)
deflate.c
deflate_p.h
deflate_quick.c
deflate_slow.c

index cb88d55dcaf0054b85b0ae4bc3adf927c0e14900..a78f4959ad7dbb3c0ac9692246cd7d259aa7c63f 100644 (file)
--- a/deflate.c
+++ b/deflate.c
@@ -447,7 +447,7 @@ int32_t ZEXPORT PREFIX(deflateSetDictionary)(PREFIX3(stream) *strm, const uint8_
         if (wrap == 0) {            /* already empty otherwise */
             CLEAR_HASH(s);
             s->strstart = 0;
-            s->block_start = 0L;
+            s->block_start = 0;
             s->insert = 0;
         }
         dictionary += dictLength - s->w_size;  /* use the tail */
@@ -469,7 +469,7 @@ int32_t ZEXPORT PREFIX(deflateSetDictionary)(PREFIX3(stream) *strm, const uint8_
         fill_window(s);
     }
     s->strstart += s->lookahead;
-    s->block_start = (long)s->strstart;
+    s->block_start = (int)s->strstart;
     s->insert = s->lookahead;
     s->lookahead = 0;
     s->prev_length = MIN_MATCH-1;
@@ -621,7 +621,7 @@ int32_t ZEXPORT PREFIX(deflateParams)(PREFIX3(stream) *strm, int32_t level, int3
         int err = PREFIX(deflate)(strm, flush);
         if (err == Z_STREAM_ERROR)
             return err;
-        if (strm->avail_in || (s->strstart - s->block_start) + s->lookahead || !DEFLATE_DONE(strm, flush))
+        if (strm->avail_in || ((int)s->strstart - s->block_start) + s->lookahead || !DEFLATE_DONE(strm, flush))
             return Z_BUF_ERROR;
     }
     if (s->level != level) {
@@ -1029,7 +1029,7 @@ int32_t ZEXPORT PREFIX(deflate)(PREFIX3(stream) *strm, int32_t flush) {
                     CLEAR_HASH(s);             /* forget history */
                     if (s->lookahead == 0) {
                         s->strstart = 0;
-                        s->block_start = 0L;
+                        s->block_start = 0;
                         s->insert = 0;
                     }
                 }
@@ -1184,7 +1184,7 @@ ZLIB_INTERNAL unsigned read_buf(PREFIX3(stream) *strm, unsigned char *buf, unsig
  * Initialize the "longest match" routines for a new zlib stream
  */
 static void lm_init(deflate_state *s) {
-    s->window_size = (unsigned long)2L*s->w_size;
+    s->window_size = 2 * s->w_size;
 
     CLEAR_HASH(s);
 
@@ -1196,7 +1196,7 @@ static void lm_init(deflate_state *s) {
     s->max_chain_length = configuration_table[s->level].max_chain;
 
     s->strstart = 0;
-    s->block_start = 0L;
+    s->block_start = 0;
     s->lookahead = 0;
     s->insert = 0;
     s->prev_length = MIN_MATCH-1;
@@ -1249,7 +1249,7 @@ void check_match(deflate_state *s, Pos start, Pos match, int length) {
 
 void ZLIB_INTERNAL fill_window(deflate_state *s) {
     unsigned n;
-    unsigned long more;    /* Amount of free space at the end of the window. */
+    unsigned int more;    /* Amount of free space at the end of the window. */
     unsigned int wsize = s->w_size;
 
     Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead");
@@ -1264,7 +1264,7 @@ void ZLIB_INTERNAL fill_window(deflate_state *s) {
             memcpy(s->window, s->window+wsize, (unsigned)wsize);
             s->match_start = (s->match_start >= wsize) ? s->match_start - wsize : 0;
             s->strstart    -= wsize; /* we now have strstart >= MAX_DIST */
-            s->block_start -= (long) wsize;
+            s->block_start -= (int)wsize;
             if (s->insert > s->strstart)
                 s->insert = s->strstart;
             functable.slide_hash(s);
@@ -1329,8 +1329,8 @@ void ZLIB_INTERNAL fill_window(deflate_state *s) {
      * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead.
      */
     if (s->high_water < s->window_size) {
-        unsigned long curr = s->strstart + (unsigned long)s->lookahead;
-        unsigned long init;
+        unsigned int curr = s->strstart + s->lookahead;
+        unsigned int init;
 
         if (s->high_water < curr) {
             /* Previous high water mark below current data -- zero WIN_INIT
@@ -1346,7 +1346,7 @@ void ZLIB_INTERNAL fill_window(deflate_state *s) {
              * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up
              * to end of window, whichever is less.
              */
-            init = (unsigned long)curr + WIN_INIT - s->high_water;
+            init = curr + WIN_INIT - s->high_water;
             if (init > s->window_size - s->high_water)
                 init = s->window_size - s->high_water;
             memset(s->window + s->high_water, 0, init);
@@ -1397,7 +1397,7 @@ static block_state deflate_stored(deflate_state *s, int flush) {
             break;
             /* maximum stored block length that will fit in avail_out: */
         have = s->strm->avail_out - have;
-        left = s->strstart - s->block_start;    /* bytes left in window */
+        left = (int)s->strstart - s->block_start;    /* bytes left in window */
         if (len > (unsigned long)left + s->strm->avail_in)
             len = left + s->strm->avail_in;     /* limit len to the input */
         if (len > have)
@@ -1437,7 +1437,7 @@ static block_state deflate_stored(deflate_state *s, int flush) {
             s->strm->next_out += left;
             s->strm->avail_out -= left;
             s->strm->total_out += left;
-            s->block_start += left;
+            s->block_start += (int)left;
             len -= left;
         }
 
@@ -1482,7 +1482,7 @@ static block_state deflate_stored(deflate_state *s, int flush) {
             s->strstart += used;
             s->insert += MIN(used, s->w_size - s->insert);
         }
-        s->block_start = s->strstart;
+        s->block_start = (int)s->strstart;
     }
     if (s->high_water < s->strstart)
         s->high_water = s->strstart;
@@ -1493,14 +1493,14 @@ static block_state deflate_stored(deflate_state *s, int flush) {
 
     /* If flushing and all input has been consumed, then done. */
     if (flush != Z_NO_FLUSH && flush != Z_FINISH &&
-        s->strm->avail_in == 0 && (long)s->strstart == s->block_start)
+        s->strm->avail_in == 0 && (int)s->strstart == s->block_start)
         return block_done;
 
     /* Fill the window with any remaining input. */
     have = s->window_size - s->strstart;
-    if (s->strm->avail_in > have && s->block_start >= (long)s->w_size) {
+    if (s->strm->avail_in > have && s->block_start >= (int)s->w_size) {
         /* Slide the window down. */
-        s->block_start -= s->w_size;
+        s->block_start -= (int)s->w_size;
         s->strstart -= s->w_size;
         memcpy(s->window, s->window + s->w_size, s->strstart);
         if (s->matches < 2)
@@ -1528,7 +1528,7 @@ static block_state deflate_stored(deflate_state *s, int flush) {
         /* maximum stored block length that will fit in pending: */
     have = MIN(s->pending_buf_size - have, MAX_STORED);
     min_block = MIN(have, s->w_size);
-    left = s->strstart - s->block_start;
+    left = (int)s->strstart - s->block_start;
     if (left >= min_block ||
         ((left || flush == Z_FINISH) && flush != Z_NO_FLUSH &&
          s->strm->avail_in == 0 && left <= have)) {
@@ -1536,7 +1536,7 @@ static block_state deflate_stored(deflate_state *s, int flush) {
         last = flush == Z_FINISH && s->strm->avail_in == 0 &&
                len == left ? 1 : 0;
         zng_tr_stored_block(s, (char *)s->window + s->block_start, len, last);
-        s->block_start += len;
+        s->block_start += (int)len;
         flush_pending(s->strm);
     }
 
@@ -1586,7 +1586,7 @@ static block_state deflate_rle(deflate_state *s, int flush) {
                 if (match_len > s->lookahead)
                     match_len = s->lookahead;
             }
-            Assert(scan <= s->window+(unsigned int)(s->window_size-1), "wild scan");
+            Assert(scan <= s->window + s->window_size - 1, "wild scan");
         }
 
         /* Emit match if have run of MIN_MATCH or longer, else emit literal */
index 09746a75834fc449672e51fbb375b787f3e60d79..78a63af040522e2412b8434bfe5629bb5ecf1836 100644 (file)
@@ -58,12 +58,12 @@ static inline int zng_tr_tally_dist(deflate_state *s, unsigned dist, unsigned ch
  * IN assertion: strstart is set to the end of the current match.
  */
 #define FLUSH_BLOCK_ONLY(s, last) { \
-    zng_tr_flush_block(s, (s->block_start >= 0L ? \
+    zng_tr_flush_block(s, (s->block_start >= 0 ? \
                    (char *)&s->window[(unsigned)s->block_start] : \
                    NULL), \
-                   (unsigned long)((long)s->strstart - s->block_start), \
+                   (unsigned long)((int)s->strstart - s->block_start), \
                    (last)); \
-    s->block_start = s->strstart; \
+    s->block_start = (int)s->strstart; \
     flush_pending(s->strm); \
 }
 
index fb2e1382aa2a36c16b143eb8bac261028cc8a147..c8fb226c4fcaa91c109613ed65767de0c0b3953c 100644 (file)
@@ -28,20 +28,20 @@ extern const ct_data static_dtree[D_CODES];
 
 #define QUICK_START_BLOCK(s, last) { \
     zng_tr_emit_tree(s, STATIC_TREES, last); \
-    s->block_open = 1 + last; \
-    s->block_start = s->strstart; \
+    s->block_open = 1 + (int)last; \
+    s->block_start = (int)s->strstart; \
 }
 
 #define QUICK_END_BLOCK(s, last) { \
     if (s->block_open) { \
         zng_tr_emit_end_block(s, static_ltree, last); \
         s->block_open = 0; \
-        s->block_start = s->strstart; \
+        s->block_start = (int)s->strstart; \
         flush_pending(s->strm); \
         if (s->strm->avail_out == 0) \
             return (last) ? finish_started : need_more; \
     } \
-} 
+}
 
 ZLIB_INTERNAL block_state deflate_quick(deflate_state *s, int flush) {
     Pos hash_head;
index b79bc7eaff4998b380216acdc03ec1a3757e9f21..7c7f28bd05afb192ac8e03d794bc6c4e378aae91 100644 (file)
@@ -45,7 +45,7 @@ ZLIB_INTERNAL block_state deflate_slow(deflate_state *s, int flush) {
 
         /* Find the longest match, discarding those <= prev_length.
          */
-        s->prev_match = s->match_start;
+        s->prev_match = (Pos)s->match_start;
         match_len = MIN_MATCH-1;
 
         if (hash_head != NIL && s->prev_length < s->max_lazy_match && s->strstart - hash_head <= MAX_DIST(s)) {