From: Mark Adler Date: Sun, 6 Sep 2015 01:56:55 +0000 (-0700) Subject: Clean up portability for shifts and integer sizes. X-Git-Tag: 1.9.9-b1~793^2~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=46c21b18e01ad2d9104973f51086985a0237a292;p=thirdparty%2Fzlib-ng.git Clean up portability for shifts and integer sizes. --- diff --git a/adler32.c b/adler32.c index f2dd922f0..6b6e8d4eb 100644 --- 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); } diff --git a/inflate.c b/inflate.c index b695229a2..0b2ee2fec 100644 --- 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 56bfbba08..4f5fb131c 100644 --- 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. */