]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Use size_t types for len arithmetic, matching signature
authorAdam Stylinski <kungfujesus06@gmail.com>
Sun, 27 Mar 2022 23:20:08 +0000 (19:20 -0400)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Thu, 31 Mar 2022 14:12:10 +0000 (16:12 +0200)
This suppresses a warning and keeps everything safely the same type.
While it's unlikely that the input for any of this will exceed the size
of an unsigned 32 bit integer, this approach is cleaner than casting and
should not result in a performance degradation.

arch/x86/adler32_ssse3.c

index 5d28ac95fcd1913b061207ba10230e1c31715ea2..014c89a88133bd60c646808b67f0c568f73ba533 100644 (file)
@@ -59,10 +59,10 @@ Z_INTERNAL uint32_t adler32_ssse3(uint32_t adler, const unsigned char *buf, size
      * additions worthwhile or if it's worth it to just eat the cost of an unaligned
      * load. This is a pretty simple test, just test if 16 - the remainder + len is
      * < 16 */
-    uint32_t max_iters = NMAX;
-    uint32_t rem = (uintptr_t)buf & 15;
-    uint32_t align_offset = 16 - rem;
-    uint32_t k = 0;
+    size_t max_iters = NMAX;
+    size_t rem = (uintptr_t)buf & 15;
+    size_t align_offset = 16 - rem;
+    size_t k = 0;
     if (rem) {
         if (len < 16 + align_offset) {
             /* Let's eat the cost of this one unaligned load so that
@@ -79,7 +79,7 @@ Z_INTERNAL uint32_t adler32_ssse3(uint32_t adler, const unsigned char *buf, size
             goto unaligned_jmp;
         }
 
-        for (uint32_t i = 0; i < align_offset; ++i) {
+        for (size_t i = 0; i < align_offset; ++i) {
             adler += *(buf++);
             sum2 += adler;
         }