Clean up portability for shifts and integer sizes.

This commit is contained in:
Mark Adler 2015-09-05 18:56:55 -07:00
parent e54e129940
commit 44ae761dc2
3 changed files with 4 additions and 4 deletions

View File

@ -11,7 +11,7 @@
local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2)); 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 #define NMAX 5552
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ /* 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; sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
if (sum1 >= BASE) sum1 -= BASE; if (sum1 >= BASE) sum1 -= BASE;
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; if (sum2 >= BASE) sum2 -= BASE;
return sum1 | (sum2 << 16); return sum1 | (sum2 << 16);
} }

View File

@ -243,7 +243,7 @@ int value;
} }
if (bits > 16 || state->bits + bits > 32) return Z_STREAM_ERROR; if (bits > 16 || state->bits + bits > 32) return Z_STREAM_ERROR;
value &= (1L << bits) - 1; value &= (1L << bits) - 1;
state->hold += value << state->bits; state->hold += (unsigned)value << state->bits;
state->bits += bits; state->bits += bits;
return Z_OK; return Z_OK;
} }

2
zlib.h
View File

@ -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 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. 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. source stream state was inconsistent.
*/ */