]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Fixed MSVC warnings in chunkcopy_safe.
authorNathan Moinvaziri <nathan@nathanm.com>
Wed, 16 Mar 2022 21:10:14 +0000 (14:10 -0700)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Sun, 27 Mar 2022 17:17:21 +0000 (19:17 +0200)
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

index 2735c581dfd46ffba66eb6d8ab17cf3c36d68be5..87529aa6d40fc54f6bd7128a6a4f54dd1598821c 100644 (file)
     } 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;