]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Use a uniform approach for the largest value of an unsigned type.
authorMark Adler <madler@alumni.caltech.edu>
Sat, 31 Dec 2016 16:49:17 +0000 (08:49 -0800)
committerHans Kristian Rosbach <hk-git@circlestorm.org>
Tue, 7 Feb 2017 09:38:47 +0000 (10:38 +0100)
compress.c
inflate.c
uncompr.c

index 1fba05701145dfabaa2bfde50ab029a5a0e558a5..d4f99bb31a055fd64fe4db447278e70166b90049 100644 (file)
@@ -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;
index 298479f860b29f96da7fab40457f20a193b5f9d7..0f7e3e7118e882109043730a9e9803452c6db6b6 100644 (file)
--- a/inflate.c
+++ b/inflate.c
@@ -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);
 }
index 834ffc90c9efe62bda0ee932d92c099305665769..7bf47b8dd450be819c364e639457cce77b02c9e3 100644 (file)
--- a/uncompr.c
+++ b/uncompr.c
@@ -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 */