]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Fix more conversion warnings related to s->bi_valid, stored_len and misc.
authorHans Kristian Rosbach <hk-git@circlestorm.org>
Tue, 25 Aug 2020 14:36:28 +0000 (16:36 +0200)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Thu, 27 Aug 2020 17:20:38 +0000 (19:20 +0200)
deflate.h
deflate_p.h
trees.c

index 898f78ce7979cbdcdfacfea1e336b523cf5b7da2..9087e2e24b46c75635ff2ddaab80bb45378967e2 100644 (file)
--- a/deflate.h
+++ b/deflate.h
@@ -260,7 +260,7 @@ typedef struct internal_state {
     /* Output buffer. bits are inserted starting at the bottom (least
      * significant bits).
      */
-    int bi_valid;
+    int32_t bi_valid;
     /* Number of valid bits in bi_buf.  All bits above the last valid bit
      * are always zero.
      */
@@ -390,10 +390,10 @@ void ZLIB_INTERNAL slide_hash_c(deflate_state *s);
 
         /* in trees.c */
 void ZLIB_INTERNAL zng_tr_init(deflate_state *s);
-void ZLIB_INTERNAL zng_tr_flush_block(deflate_state *s, char *buf, unsigned long stored_len, int last);
+void ZLIB_INTERNAL zng_tr_flush_block(deflate_state *s, char *buf, uint32_t stored_len, int last);
 void ZLIB_INTERNAL zng_tr_flush_bits(deflate_state *s);
 void ZLIB_INTERNAL zng_tr_align(deflate_state *s);
-void ZLIB_INTERNAL zng_tr_stored_block(deflate_state *s, char *buf, unsigned long stored_len, int last);
+void ZLIB_INTERNAL zng_tr_stored_block(deflate_state *s, char *buf, uint32_t stored_len, int last);
 unsigned ZLIB_INTERNAL bi_reverse(unsigned code, int len);
 void ZLIB_INTERNAL flush_pending(PREFIX3(streamp) strm);
 
index 78a63af040522e2412b8434bfe5629bb5ecf1836..60ca1370f37bb25579237b6bebce145efd62b2e9 100644 (file)
@@ -61,7 +61,7 @@ static inline int zng_tr_tally_dist(deflate_state *s, unsigned dist, unsigned ch
     zng_tr_flush_block(s, (s->block_start >= 0 ? \
                    (char *)&s->window[(unsigned)s->block_start] : \
                    NULL), \
-                   (unsigned long)((int)s->strstart - s->block_start), \
+                   (uint32_t)((int)s->strstart - s->block_start), \
                    (last)); \
     s->block_start = (int)s->strstart; \
     flush_pending(s->strm); \
diff --git a/trees.c b/trees.c
index 47734f30827f4ded7f18a62580de05f9f9982c8c..83d77c154786e8b171293818b836402f19465b73 100644 (file)
--- a/trees.c
+++ b/trees.c
@@ -206,11 +206,13 @@ static void gen_bitlen(deflate_state *s, tree_desc *desc) {
      */
     tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */
 
-    for (h = s->heap_max+1; h < HEAP_SIZE; h++) {
+    for (h = s->heap_max + 1; h < HEAP_SIZE; h++) {
         n = s->heap[h];
-        bits = tree[tree[n].Dad].Len + 1;
-        if (bits > max_length)
-            bits = max_length, overflow++;
+        bits = tree[tree[n].Dad].Len + 1u;
+        if (bits > max_length){
+            bits = max_length;
+            overflow++;
+        }
         tree[n].Len = (uint16_t)bits;
         /* We overwrite tree[n].Dad which is no longer needed */
 
@@ -234,11 +236,11 @@ static void gen_bitlen(deflate_state *s, tree_desc *desc) {
 
     /* Find the first bit length which could increase: */
     do {
-        bits = max_length-1;
+        bits = max_length - 1;
         while (s->bl_count[bits] == 0)
             bits--;
-        s->bl_count[bits]--;      /* move one leaf down the tree */
-        s->bl_count[bits+1] += 2; /* move one overflow item as its brother */
+        s->bl_count[bits]--;       /* move one leaf down the tree */
+        s->bl_count[bits+1] += 2u; /* move one overflow item as its brother */
         s->bl_count[max_length]--;
         /* The brother of the overflow item also moves one step up,
          * but this does not affect bl_count[max_length]
@@ -587,7 +589,7 @@ static void send_all_trees(deflate_state *s, int lcodes, int dcodes, int blcodes
 /* ===========================================================================
  * Send a stored block
  */
-void ZLIB_INTERNAL zng_tr_stored_block(deflate_state *s, char *buf, unsigned long stored_len, int last) {
+void ZLIB_INTERNAL zng_tr_stored_block(deflate_state *s, char *buf, uint32_t stored_len, int last) {
     /* buf: input block */
     /* stored_len: length of input block */
     /* last: one if this is the last block for a file */
@@ -627,7 +629,7 @@ void ZLIB_INTERNAL zng_tr_align(deflate_state *s) {
  * Determine the best encoding for the current block: dynamic trees, static
  * trees or store, and write out the encoded block.
  */
-void ZLIB_INTERNAL zng_tr_flush_block(deflate_state *s, char *buf, unsigned long stored_len, int last) {
+void ZLIB_INTERNAL zng_tr_flush_block(deflate_state *s, char *buf, uint32_t stored_len, int last) {
     /* buf: input block, or NULL if too old */
     /* stored_len: length of input block */
     /* last: one if this is the last block for a file */