]> git.lizzy.rs Git - zlib.git/commitdiff
Clean up portability for shifts and integer sizes.
authorMark Adler <madler@alumni.caltech.edu>
Sun, 6 Sep 2015 01:56:55 +0000 (18:56 -0700)
committerMark Adler <madler@alumni.caltech.edu>
Sun, 6 Sep 2015 01:56:55 +0000 (18:56 -0700)
adler32.c
inflate.c
zlib.h

index a868f073d8a0e35dcb3ec812b41b1d3f0acdd84d..cfacc88cde32cf1832fd2083638383280f5d9baa 100644 (file)
--- a/adler32.c
+++ b/adler32.c
@@ -11,7 +11,7 @@
 
 local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
 
-#define BASE 65521      /* largest prime smaller than 65536 */
+#define BASE 65521U     /* largest prime smaller than 65536 */
 #define NMAX 5552
 /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
 
@@ -156,7 +156,7 @@ local uLong adler32_combine_(adler1, adler2, len2)
     sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
     if (sum1 >= BASE) sum1 -= BASE;
     if (sum1 >= BASE) sum1 -= BASE;
-    if (sum2 >= (BASE << 1)) sum2 -= (BASE << 1);
+    if (sum2 >= ((unsigned long)BASE << 1)) sum2 -= ((unsigned long)BASE << 1);
     if (sum2 >= BASE) sum2 -= BASE;
     return sum1 | (sum2 << 16);
 }
index a71841670eff6476d3b86a49dcf91acdf2e7bb3f..72e8438d7eb45e7037b86a65619d6f2dd8893af8 100644 (file)
--- a/inflate.c
+++ b/inflate.c
@@ -243,7 +243,7 @@ int value;
     }
     if (bits > 16 || state->bits + bits > 32) return Z_STREAM_ERROR;
     value &= (1L << bits) - 1;
-    state->hold += value << state->bits;
+    state->hold += (unsigned)value << state->bits;
     state->bits += bits;
     return Z_OK;
 }
diff --git a/zlib.h b/zlib.h
index 40e5732af99bbf398546d54b87f2cf60c73ed419..66dc6006a75a54a4c7d6af387369878d78c93cfc 100644 (file)
--- a/zlib.h
+++ b/zlib.h
@@ -978,7 +978,7 @@ ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm));
    location in the input stream can be determined from avail_in and data_type
    as noted in the description for the Z_BLOCK flush parameter for inflate.
 
-     inflateMark returns the value noted above or -1 << 16 if the provided
+     inflateMark returns the value noted above or -65536 if the provided
    source stream state was inconsistent.
 */