]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
fixed zlib_wrapper conversion warnings
authorYann Collet <cyan@fb.com>
Thu, 22 Dec 2016 14:26:33 +0000 (15:26 +0100)
committerYann Collet <cyan@fb.com>
Thu, 22 Dec 2016 14:26:33 +0000 (15:26 +0100)
zlibWrapper/examples/fitblk.c
zlibWrapper/examples/zwrapbench.c
zlibWrapper/gzread.c
zlibWrapper/gzwrite.c
zlibWrapper/zstd_zlibwrapper.c

index f389c3a4ffd01e4142e3769281ad8c9cfb1d6623..ee413c3ae9165b7e32d3abb947e5e2f0f5582614 100644 (file)
@@ -82,7 +82,7 @@ local int partcompress(FILE *in, z_streamp def)
 
     flush = Z_SYNC_FLUSH;
     do {
-        def->avail_in = fread(raw, 1, RAWLEN, in);
+        def->avail_in = (uInt)fread(raw, 1, RAWLEN, in);
         if (ferror(in))
             return Z_ERRNO;
         def->next_in = raw;
@@ -148,7 +148,7 @@ int main(int argc, char **argv)
     /* get requested output size */
     if (argc != 2)
         quit("need one argument: size of output block");
-    ret = strtol(argv[1], argv + 1, 10);
+    ret = (int)strtol(argv[1], argv + 1, 10);
     if (argv[1][0] != 0)
         quit("argument must be a number");
     if (ret < 8)            /* 8 is minimum zlib stream size */
index 49a2632e1e153cdf629ca9c9c59227b00049745f..e5c54438b92cbd094b6e02773eb818a5546897e4 100644 (file)
@@ -315,10 +315,10 @@ static int BMK_benchMem(z_const void* srcBuffer, size_t srcSize,
                                 if (ZWRAP_isUsingZSTDcompression()) useSetDict = 0; /* zstd doesn't require deflateSetDictionary after ZWRAP_deflateReset_keepDict */
                             }
                             def.next_in = (z_const void*) blockTable[blockNb].srcPtr;
-                            def.avail_in = blockTable[blockNb].srcSize;
+                            def.avail_in = (uInt)blockTable[blockNb].srcSize;
                             def.total_in = 0;
                             def.next_out = (void*) blockTable[blockNb].cPtr;
-                            def.avail_out = blockTable[blockNb].cRoom;
+                            def.avail_out = (uInt)blockTable[blockNb].cRoom;
                             def.total_out = 0;
                             ret = deflate(&def, Z_FINISH);
                             if (ret != Z_STREAM_END) EXM_THROW(1, "deflate failure ret=%d srcSize=%d" , ret, (int)blockTable[blockNb].srcSize);
@@ -346,10 +346,10 @@ static int BMK_benchMem(z_const void* srcBuffer, size_t srcSize,
                                 if (ret != Z_OK) EXM_THROW(1, "deflateSetDictionary failure");
                             }
                             def.next_in = (z_const void*) blockTable[blockNb].srcPtr;
-                            def.avail_in = blockTable[blockNb].srcSize;
+                            def.avail_in = (uInt)blockTable[blockNb].srcSize;
                             def.total_in = 0;
                             def.next_out = (void*) blockTable[blockNb].cPtr;
-                            def.avail_out = blockTable[blockNb].cRoom;
+                            def.avail_out = (uInt)blockTable[blockNb].cRoom;
                             def.total_out = 0;
                             ret = deflate(&def, Z_FINISH);
                             if (ret != Z_STREAM_END) EXM_THROW(1, "deflate failure");
@@ -451,10 +451,10 @@ static int BMK_benchMem(z_const void* srcBuffer, size_t srcSize,
                                 ret = inflateReset(&inf);
                             if (ret != Z_OK) EXM_THROW(1, "inflateReset failure");
                             inf.next_in = (z_const void*) blockTable[blockNb].cPtr;
-                            inf.avail_in = blockTable[blockNb].cSize;
+                            inf.avail_in = (uInt)blockTable[blockNb].cSize;
                             inf.total_in = 0;
                             inf.next_out = (void*) blockTable[blockNb].resPtr;
-                            inf.avail_out = blockTable[blockNb].srcSize;
+                            inf.avail_out = (uInt)blockTable[blockNb].srcSize;
                             inf.total_out = 0;
                             ret = inflate(&inf, Z_FINISH);
                             if (ret == Z_NEED_DICT) {
@@ -483,10 +483,10 @@ static int BMK_benchMem(z_const void* srcBuffer, size_t srcSize,
                             ret = inflateInit(&inf);
                             if (ret != Z_OK) EXM_THROW(1, "inflateInit failure");
                             inf.next_in = (z_const void*) blockTable[blockNb].cPtr;
-                            inf.avail_in = blockTable[blockNb].cSize;
+                            inf.avail_in = (uInt)blockTable[blockNb].cSize;
                             inf.total_in = 0;
                             inf.next_out = (void*) blockTable[blockNb].resPtr;
-                            inf.avail_out = blockTable[blockNb].srcSize;
+                            inf.avail_out = (uInt)blockTable[blockNb].srcSize;
                             inf.total_out = 0;
                             ret = inflate(&inf, Z_FINISH);
                             if (ret == Z_NEED_DICT) {
index bf1a3cc6cb545186f112d0ea2c566ba715747bba..f251e2fe40aac48efdda91c6b55f6fa7276fbdb8 100644 (file)
@@ -30,7 +30,7 @@ local int gz_load(state, buf, len, have)
 
     *have = 0;
     do {
-        ret = read(state.state->fd, buf + *have, len - *have);
+        ret = (int)read(state.state->fd, buf + *have, len - *have);
         if (ret <= 0)
             break;
         *have += ret;
@@ -469,7 +469,7 @@ int ZEXPORT gzungetc(c, file)
     if (state.state->x.have == 0) {
         state.state->x.have = 1;
         state.state->x.next = state.state->out + (state.state->size << 1) - 1;
-        state.state->x.next[0] = c;
+        state.state->x.next[0] = (unsigned char)c;
         state.state->x.pos--;
         state.state->past = 0;
         return c;
@@ -491,7 +491,7 @@ int ZEXPORT gzungetc(c, file)
     }
     state.state->x.have++;
     state.state->x.next--;
-    state.state->x.next[0] = c;
+    state.state->x.next[0] = (unsigned char)c;
     state.state->x.pos--;
     state.state->past = 0;
     return c;
index 13c8fb26454b91af2e8a53ed5bf9841364e8f100..6f3c9658b595bc34032c695220fabb604528927e 100644 (file)
@@ -84,7 +84,7 @@ local int gz_comp(state, flush)
 
     /* write directly if requested */
     if (state.state->direct) {
-        got = write(state.state->fd, strm->next_in, strm->avail_in);
+        got = (int)write(state.state->fd, strm->next_in, strm->avail_in);
         if (got < 0 || (unsigned)got != strm->avail_in) {
             gz_error(state, Z_ERRNO, zstrerror());
             return -1;
@@ -101,7 +101,7 @@ local int gz_comp(state, flush)
         if (strm->avail_out == 0 || (flush != Z_NO_FLUSH &&
             (flush != Z_FINISH || ret == Z_STREAM_END))) {
             have = (unsigned)(strm->next_out - state.state->x.next);
-            if (have && ((got = write(state.state->fd, state.state->x.next, have)) < 0 ||
+            if (have && ((got = (int)write(state.state->fd, state.state->x.next, have)) < 0 ||
                          (unsigned)got != have)) {
                 gz_error(state, Z_ERRNO, zstrerror());
                 return -1;
@@ -278,7 +278,7 @@ int ZEXPORT gzputc(file, c)
             strm->next_in = state.state->in;
         have = (unsigned)((strm->next_in + strm->avail_in) - state.state->in);
         if (have < state.state->size) {
-            state.state->in[have] = c;
+            state.state->in[have] = (unsigned char)c;
             strm->avail_in++;
             state.state->x.pos++;
             return c & 0xff;
@@ -286,7 +286,7 @@ int ZEXPORT gzputc(file, c)
     }
 
     /* no room in buffer or not initialized, use gz_write() */
-    buf[0] = c;
+    buf[0] = (unsigned char)c;
     if (gzwrite(file, buf, 1) != 1)
         return -1;
     return c & 0xff;
index b25d92066a9cb006254d7ca3712cb6f374038056..238510523aa72b8093159909758cb7256cf59124 100644 (file)
@@ -61,7 +61,7 @@ ZEXTERN const char * ZEXPORT z_zlibVersion OF((void)) { return zlibVersion();  }
 static void* ZWRAP_allocFunction(void* opaque, size_t size)
 {
     z_streamp strm = (z_streamp) opaque;
-    void* address = strm->zalloc(strm->opaque, 1, size);
+    void* address = strm->zalloc(strm->opaque, 1, (uInt)size);
   /*  printf("ZWRAP alloc %p, %d \n", address, (int)size); */
     return address;
 }