]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Use int for srcSizeHint when sensible
authorNick Magerko <nmagerko@fb.com>
Mon, 19 Aug 2019 23:49:25 +0000 (16:49 -0700)
committerNick Magerko <nmagerko@fb.com>
Mon, 19 Aug 2019 23:49:25 +0000 (16:49 -0700)
lib/compress/zstd_compress_internal.h
programs/fileio.c

index 0e4ec6b7d16a281b9aafc18d20d36be84234a4dc..3e590ec3737a84927d4b0781fca96076d2195ba4 100644 (file)
@@ -203,7 +203,7 @@ struct ZSTD_CCtx_params_s {
     size_t targetCBlockSize;   /* Tries to fit compressed block size to be around targetCBlockSize.
                                 * No target when targetCBlockSize == 0.
                                 * There is no guarantee on compressed block size */
-    size_t srcSizeHint;        /* User's best guess of source size.
+    int srcSizeHint;           /* User's best guess of source size.
                                 * Hint is not valid when srcSizeHint == 0.
                                 * There is no guarantee that hint is close to actual source size */
 
index 20543cd5e49fdd6d489ffd832fd687829a440941..0eda12649394b1bdf65e30cf1fb30724713748b7 100644 (file)
@@ -30,6 +30,7 @@
 #include <string.h>     /* strcmp, strlen */
 #include <assert.h>
 #include <errno.h>      /* errno */
+#include <limits.h>     /* INT_MAX */
 #include <signal.h>
 #include "timefn.h"     /* UTIL_getTime, UTIL_clockSpanMicro */
 
@@ -305,7 +306,7 @@ struct FIO_prefs_s {
     int ldmBucketSizeLog;
     int ldmHashRateLog;
     size_t targetCBlockSize;
-    size_t srcSizeHint;
+    int srcSizeHint;
     ZSTD_literalCompressionMode_e literalCompressionMode;
 
     /* IO preferences */
@@ -425,7 +426,7 @@ void FIO_setTargetCBlockSize(FIO_prefs_t* const prefs, size_t targetCBlockSize)
 }
 
 void FIO_setSrcSizeHint(FIO_prefs_t* const prefs, size_t srcSizeHint) {
-    prefs->srcSizeHint = srcSizeHint;
+    prefs->srcSizeHint = (int)MIN((size_t)INT_MAX, srcSizeHint);
 }
 
 void FIO_setLiteralCompressionMode(