From d979b89e00b398d548460daebb99c104f88267bc Mon Sep 17 00:00:00 2001 From: Nathan Moinvaziri Date: Wed, 16 Mar 2022 14:10:14 -0700 Subject: [PATCH] Fixed MSVC warnings in chunkcopy_safe. inflate_p.h(244,18): warning C4018: '>': signed/unsigned mismatch inflate_p.h(234,38): warning C4244: 'initializing': conversion from '__int64' to 'int', possible loss of data inffast.c inflate_p.h(244,18): warning C4018: '>': signed/unsigned mismatch inflate_p.h(234,38): warning C4244: 'initializing': conversion from '__int64' to 'int', possible loss of data inflate.c inflate_p.h(244,18): warning C4018: '>': signed/unsigned mismatch inflate_p.h(234,38): warning C4244: 'initializing': conversion from '__int64' to 'int', possible loss of data --- inflate_p.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/inflate_p.h b/inflate_p.h index 2735c581..87529aa6 100644 --- a/inflate_p.h +++ b/inflate_p.h @@ -128,12 +128,12 @@ } while (0) /* Behave like chunkcopy, but avoid writing beyond of legal output. */ -static inline uint8_t* chunkcopy_safe(uint8_t *out, uint8_t *from, unsigned len, uint8_t *safe) { +static inline uint8_t* chunkcopy_safe(uint8_t *out, uint8_t *from, size_t len, uint8_t *safe) { uint32_t safelen = (uint32_t)((safe - out) + 1); len = MIN(len, safelen); - int olap_src = from >= out && from < out + len; - int olap_dst = out >= from && out < from + len; - int tocopy; + int32_t olap_src = from >= out && from < out + len; + int32_t olap_dst = out >= from && out < from + len; + size_t tocopy; /* For all cases without overlap, memcpy is ideal */ if (!(olap_src || olap_dst)) { @@ -146,7 +146,7 @@ static inline uint8_t* chunkcopy_safe(uint8_t *out, uint8_t *from, unsigned len, * initial bulk memcpy of the nonoverlapping region. Then, we can leverage the size of this to determine the safest * atomic memcpy size we can pick such that we have non-overlapping regions. This effectively becomes a safe look * behind or lookahead distance */ - int non_olap_size = (from > out) ? from - out : out - from; + int32_t non_olap_size = (int32_t)((from > out) ? from - out : out - from); memcpy(out, from, non_olap_size); out += non_olap_size; -- 2.47.2