From a1394399b4d750bc74af426460177166e82c7339 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Sat, 19 Jan 2019 23:38:20 -0800 Subject: [PATCH] fixed minor conversion warnings in examples/ --- doc/zstd_manual.html | 16 ++++++++++------ examples/multiple_simple_compression.c | 8 ++++---- examples/utils.h | 4 ++-- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/doc/zstd_manual.html b/doc/zstd_manual.html index 6dfa6d997..c7962e7de 100644 --- a/doc/zstd_manual.html +++ b/doc/zstd_manual.html @@ -1011,22 +1011,26 @@ static ZSTD_customMem const ZSTD_defaultCMem = { NULL, NULL, NULL }; /**< t


ZSTD_compressionParameters ZSTD_getCParams(int compressionLevel, unsigned long long estimatedSrcSize, size_t dictSize);
-

@return ZSTD_compressionParameters structure for a selected compression level and estimated srcSize. - `estimatedSrcSize` value is optional, select 0 if not known +

@return ZSTD_compressionParameters structure for a selected compression level and estimated srcSize. + `estimatedSrcSize` value is optional, select 0 if not known


ZSTD_parameters ZSTD_getParams(int compressionLevel, unsigned long long estimatedSrcSize, size_t dictSize);
-

same as ZSTD_getCParams(), but @return a full `ZSTD_parameters` object instead of sub-component `ZSTD_compressionParameters`. - All fields of `ZSTD_frameParameters` are set to default : contentSize=1, checksum=0, noDictID=0 +

same as ZSTD_getCParams(), but @return a full `ZSTD_parameters` object instead of sub-component `ZSTD_compressionParameters`. + All fields of `ZSTD_frameParameters` are set to default : contentSize=1, checksum=0, noDictID=0


size_t ZSTD_checkCParams(ZSTD_compressionParameters params);
-

Ensure param values remain within authorized range +

Ensure param values remain within authorized range. + @return 0 on success, or an error code (can be checked with ZSTD_isError())


ZSTD_compressionParameters ZSTD_adjustCParams(ZSTD_compressionParameters cPar, unsigned long long srcSize, size_t dictSize);
 

optimize params for a given `srcSize` and `dictSize`. - both values are optional, select `0` if unknown. + `srcSize` can be unknown, in which case use ZSTD_CONTENTSIZE_UNKNOWN. + `dictSize` must be `0` when there is no dictionary. + cPar can be invalid : all parameters will be clamped within valid range in the @return struct. + This function never fails (wide contract)


size_t ZSTD_compress_advanced(ZSTD_CCtx* cctx,
diff --git a/examples/multiple_simple_compression.c b/examples/multiple_simple_compression.c
index 65c775bfa..b9bb29a9d 100644
--- a/examples/multiple_simple_compression.c
+++ b/examples/multiple_simple_compression.c
@@ -28,7 +28,7 @@ typedef struct {
  * allocate memory for buffers big enough to compress all files
  * as well as memory for output file name (ofn)
  */
-static resources createResources_orDie(int argc, const char** argv, char **ofn, int* ofnBufferLen)
+static resources createResources_orDie(int argc, const char** argv, char **ofn, size_t* ofnBufferLen)
 {
     size_t maxFilenameLength=0;
     size_t maxFileSize = 0;
@@ -94,14 +94,14 @@ int main(int argc, const char** argv)
 
     /* memory allocation for outFilename and resources */
     char* outFilename;
-    int outFilenameBufferLen;
-    resources const ress = createResources_orDie(argc, argv, &outFilename, &outFilenameBufferLen); 
+    size_t outFilenameBufferLen;
+    resources const ress = createResources_orDie(argc, argv, &outFilename, &outFilenameBufferLen);
 
     /* compress files with shared context, input and output buffers */
     int argNb;
     for (argNb = 1; argNb < argc; argNb++) {
         const char* const inFilename = argv[argNb];
-        int inFilenameLen = strlen(inFilename);
+        size_t const inFilenameLen = strlen(inFilename);
         assert(inFilenameLen + 5 <= outFilenameBufferLen);
         memcpy(outFilename, inFilename, inFilenameLen);
         memcpy(outFilename+inFilenameLen, ".zst", 5);
diff --git a/examples/utils.h b/examples/utils.h
index 6d1360457..77c7a4f0c 100644
--- a/examples/utils.h
+++ b/examples/utils.h
@@ -56,7 +56,7 @@ static size_t fsize_orDie(const char *filename)
      * 2. if off_t -> size_t type conversion results in discrepancy,
      *    the file size is too large for type size_t.
      */
-    if ((fileSize < 0) || (fileSize != (off_t)size)) { 
+    if ((fileSize < 0) || (fileSize != (off_t)size)) {
         fprintf(stderr, "%s : filesize too large \n", filename);
         exit(ERROR_largeFile);
     }
@@ -150,7 +150,7 @@ static void* malloc_orDie(size_t size)
  * @return If successful this function will load file into buffer and
  * return file size, otherwise it will printout an error to stderr and exit.
  */
-static size_t loadFile_orDie(const char* fileName, void* buffer, int bufferSize)
+static size_t loadFile_orDie(const char* fileName, void* buffer, size_t bufferSize)
 {
     size_t const fileSize = fsize_orDie(fileName);
     assert(fileSize <= bufferSize);