From 045d2aca0f630e43b84f9b8db4043e1264062368 Mon Sep 17 00:00:00 2001 From: Levi Broderick Date: Wed, 30 Aug 2023 16:11:30 -0700 Subject: [PATCH] Address C4244 warnings in MSVC build --- deflate.c | 8 ++++---- deflate_quick.c | 4 ++-- slide_sse.c | 2 +- trees.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/deflate.c b/deflate.c index bd5e9577..108b1a18 100644 --- a/deflate.c +++ b/deflate.c @@ -1553,10 +1553,10 @@ local block_state deflate_stored(s, flush) _tr_stored_block(s, (char *)0, 0L, last); /* Replace the lengths in the dummy stored block with len. */ - s->pending_buf[s->pending - 4] = len; - s->pending_buf[s->pending - 3] = len >> 8; - s->pending_buf[s->pending - 2] = ~len; - s->pending_buf[s->pending - 1] = ~len >> 8; + s->pending_buf[s->pending - 4] = (Bytef)len; + s->pending_buf[s->pending - 3] = (Bytef)(len >> 8); + s->pending_buf[s->pending - 2] = (Bytef)~len; + s->pending_buf[s->pending - 1] = (Bytef)(~len >> 8); /* Write the stored block header bytes. */ flush_pending(s->strm); diff --git a/deflate_quick.c b/deflate_quick.c index 1a6e4f89..37c72b8a 100644 --- a/deflate_quick.c +++ b/deflate_quick.c @@ -136,7 +136,7 @@ local inline void quick_send_bits(deflate_state *z_const s, z_const int value, b = w >> 3; s->pending += b; - s->bi_buf = out >> (b << 3); + s->bi_buf = (ush)(out >> (b << 3)); s->bi_valid = w - (b << 3); } @@ -224,7 +224,7 @@ block_state deflate_quick(deflate_state *s, int flush) } if (s->lookahead >= MIN_MATCH) { - hash_head = quick_insert_string(s, s->strstart); + hash_head = quick_insert_string(s, (Pos)s->strstart); dist = s->strstart - hash_head; if ((dist-1) < (s->w_size - 1)) { diff --git a/slide_sse.c b/slide_sse.c index 342fd562..eb74202c 100644 --- a/slide_sse.c +++ b/slide_sse.c @@ -18,7 +18,7 @@ void slide_hash_sse(deflate_state *s) unsigned n; Posf *p; uInt wsize = s->w_size; - z_const __m128i xmm_wsize = _mm_set1_epi16(s->w_size); + z_const __m128i xmm_wsize = _mm_set1_epi16((short)s->w_size); n = s->hash_size; p = &s->head[n] - 8; diff --git a/trees.c b/trees.c index 35462a13..f78b7d8c 100644 --- a/trees.c +++ b/trees.c @@ -717,7 +717,7 @@ local void scan_tree(s, tree, max_code) if (++count < max_count && curlen == nextlen) { continue; } else if (count < min_count) { - s->bl_tree[curlen].Freq += count; + s->bl_tree[curlen].Freq += (ush)count; } else if (curlen != 0) { if (curlen != prevlen) s->bl_tree[curlen].Freq++; s->bl_tree[REP_3_6].Freq++;