Browse Source

zlib: Suppress clang-analyzer warnings

Brad King 2 years ago
parent
commit
bba02b8b4b
2 changed files with 12 additions and 0 deletions
  1. 6 0
      Utilities/cmzlib/gzread.c
  2. 6 0
      Utilities/cmzlib/gzwrite.c

+ 6 - 0
Utilities/cmzlib/gzread.c

@@ -434,6 +434,12 @@ z_size_t ZEXPORT gzfread(buf, size, nitems, file)
         return 0;
     }
 
+#ifdef __clang_analyzer__
+    /* clang-analyzer does not see size==0 through len==0 below. */
+    if (!size)
+        return 0;
+#endif
+
     /* read len or fewer bytes to buf, return the number of full items read */
     return len ? gz_read(state, buf, len) / size : 0;
 }

+ 6 - 0
Utilities/cmzlib/gzwrite.c

@@ -305,6 +305,12 @@ z_size_t ZEXPORT gzfwrite(buf, size, nitems, file)
         return 0;
     }
 
+#ifdef __clang_analyzer__
+    /* clang-analyzer does not see size==0 through len==0 below. */
+    if (!size)
+        return 0;
+#endif
+
     /* write len bytes to buf, return the number of full items written */
     return len ? gz_write(state, buf, len) / size : 0;
 }