Skip to content

Commit

Permalink
Use a uniform approach for the largest value of an unsigned type.
Browse files Browse the repository at this point in the history
  • Loading branch information
madler authored and Dead2 committed Feb 7, 2017
1 parent a7edd5a commit cd00715
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ int ZEXPORT compress2(unsigned char *dest, size_t *destLen, const unsigned char
size_t sourceLen, int level) {
z_stream stream;
int err;
const unsigned int max = (unsigned int)0 - 1;
const unsigned int max = (unsigned int)-1;
size_t left;

left = *destLen;
Expand Down
2 changes: 1 addition & 1 deletion inflate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1496,7 +1496,7 @@ long ZEXPORT inflateMark(z_stream *strm) {
unsigned long ZEXPORT inflateCodesUsed(z_stream *strm) {
struct inflate_state *state;
if (strm == NULL || strm->state == NULL)
return (unsigned long)0 - 1;
return (unsigned long)-1;
state = (struct inflate_state *)strm->state;
return (unsigned long)(state->next - state->codes);
}
2 changes: 1 addition & 1 deletion uncompr.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
int ZEXPORT uncompress2(unsigned char *dest, size_t *destLen, const unsigned char *source, size_t *sourceLen) {
z_stream stream;
int err;
const unsigned int max = (unsigned int)0 - 1;
const unsigned int max = (unsigned int)-1;
size_t len, left;
unsigned char buf[1]; /* for detection of incomplete stream when *destLen == 0 */

Expand Down

0 comments on commit cd00715

Please sign in to comment.