From: Hans Kristian Rosbach Date: Tue, 25 Aug 2020 14:36:28 +0000 (+0200) Subject: Fix more conversion warnings related to s->bi_valid, stored_len and misc. X-Git-Tag: 1.9.9-b1~64 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6264b5a58d7470333a64d69b247a2bd561bbbe68;p=thirdparty%2Fzlib-ng.git Fix more conversion warnings related to s->bi_valid, stored_len and misc. --- diff --git a/deflate.h b/deflate.h index 898f78ce..9087e2e2 100644 --- 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); diff --git a/deflate_p.h b/deflate_p.h index 78a63af0..60ca1370 100644 --- a/deflate_p.h +++ b/deflate_p.h @@ -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 47734f30..83d77c15 100644 --- 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 */