summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Adler <madler@alumni.caltech.edu>2017-02-11 22:45:27 -0800
committerMark Adler <madler@alumni.caltech.edu>2017-02-15 22:39:26 -0800
commit793ad7f559555757e6443ea591ce70de5505fc69 (patch)
tree5dcbb55465c3d28237521bd7134d1d60a095ce42
parente00a2bd392ca51351ecee55dbeee803f6ebda2f5 (diff)
downloadzlib-793ad7f559555757e6443ea591ce70de5505fc69.tar.gz
zlib-793ad7f559555757e6443ea591ce70de5505fc69.tar.bz2
zlib-793ad7f559555757e6443ea591ce70de5505fc69.zip
Avoid some conversion warnings in gzread.c and gzwrite.c.
-rw-r--r--gzread.c10
-rw-r--r--gzwrite.c4
2 files changed, 6 insertions, 8 deletions
diff --git a/gzread.c b/gzread.c
index 956b91e..f94abfe 100644
--- a/gzread.c
+++ b/gzread.c
@@ -314,9 +314,9 @@ local z_size_t gz_read(state, buf, len)
314 got = 0; 314 got = 0;
315 do { 315 do {
316 /* set n to the maximum amount of len that fits in an unsigned int */ 316 /* set n to the maximum amount of len that fits in an unsigned int */
317 n = -1; 317 n = (unsigned)-1;
318 if (n > len) 318 if (n > len)
319 n = len; 319 n = (unsigned)len;
320 320
321 /* first just try copying data from the output buffer */ 321 /* first just try copying data from the output buffer */
322 if (state->x.have) { 322 if (state->x.have) {
@@ -397,7 +397,7 @@ int ZEXPORT gzread(file, buf, len)
397 } 397 }
398 398
399 /* read len or fewer bytes to buf */ 399 /* read len or fewer bytes to buf */
400 len = gz_read(state, buf, len); 400 len = (unsigned)gz_read(state, buf, len);
401 401
402 /* check for an error */ 402 /* check for an error */
403 if (len == 0 && state->err != Z_OK && state->err != Z_BUF_ERROR) 403 if (len == 0 && state->err != Z_OK && state->err != Z_BUF_ERROR)
@@ -447,7 +447,6 @@ z_size_t ZEXPORT gzfread(buf, size, nitems, file)
447int ZEXPORT gzgetc(file) 447int ZEXPORT gzgetc(file)
448 gzFile file; 448 gzFile file;
449{ 449{
450 int ret;
451 unsigned char buf[1]; 450 unsigned char buf[1];
452 gz_statep state; 451 gz_statep state;
453 452
@@ -469,8 +468,7 @@ int ZEXPORT gzgetc(file)
469 } 468 }
470 469
471 /* nothing there -- try gz_read() */ 470 /* nothing there -- try gz_read() */
472 ret = gz_read(state, buf, 1); 471 return gz_read(state, buf, 1) < 1 ? -1 : buf[0];
473 return ret < 1 ? -1 : buf[0];
474} 472}
475 473
476int ZEXPORT gzgetc_(file) 474int ZEXPORT gzgetc_(file)
diff --git a/gzwrite.c b/gzwrite.c
index c7b5651..35b9aa6 100644
--- a/gzwrite.c
+++ b/gzwrite.c
@@ -209,7 +209,7 @@ local z_size_t gz_write(state, buf, len)
209 state->in); 209 state->in);
210 copy = state->size - have; 210 copy = state->size - have;
211 if (copy > len) 211 if (copy > len)
212 copy = len; 212 copy = (unsigned)len;
213 memcpy(state->in + have, buf, copy); 213 memcpy(state->in + have, buf, copy);
214 state->strm.avail_in += copy; 214 state->strm.avail_in += copy;
215 state->x.pos += copy; 215 state->x.pos += copy;
@@ -229,7 +229,7 @@ local z_size_t gz_write(state, buf, len)
229 do { 229 do {
230 unsigned n = (unsigned)-1; 230 unsigned n = (unsigned)-1;
231 if (n > len) 231 if (n > len)
232 n = len; 232 n = (unsigned)len;
233 state->strm.avail_in = n; 233 state->strm.avail_in = n;
234 state->x.pos += n; 234 state->x.pos += n;
235 if (gz_comp(state, Z_NO_FLUSH) == -1) 235 if (gz_comp(state, Z_NO_FLUSH) == -1)