]> git.ipfire.org Git - thirdparty/zlib-ng.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)
committerHans Kristian Rosbach <hk-git@circlestorm.org>
Tue, 3 Nov 2015 18:12:42 +0000 (19:12 +0100)
adler32.c
inflate.c
zlib.h

index f2dd922f08e7b2b52b9f2b0bb6c55843350b3dab..6b6e8d4eb1b91d937c8cddfe3b72254456c5d82d 100644 (file)
--- a/adler32.c
+++ b/adler32.c
@@ -9,7 +9,7 @@
 
 static uint32_t adler32_combine_(uint32_t adler1, uint32_t 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 */
 
@@ -162,7 +162,7 @@ static uint32_t adler32_combine_(uint32_t adler1, uint32_t adler2, z_off64_t len
     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 b695229a2c218da3e077f9ec22bc71b0cce0d53f..0b2ee2fecdd37b2710b6a7a8f6b49ba49df19074 100644 (file)
--- a/inflate.c
+++ b/inflate.c
@@ -217,7 +217,7 @@ int ZEXPORT inflatePrime(z_stream *strm, int bits, 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 56bfbba08296e9bab89c45c8a20e2cc431730066..4f5fb131ce2c9bc97ea96e8f8ee264b210e656bd 100644 (file)
--- a/zlib.h
+++ b/zlib.h
@@ -953,7 +953,7 @@ ZEXTERN long ZEXPORT inflateMark(z_stream *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.
 */