diff options
author | Mark Adler <madler@alumni.caltech.edu> | 2016-10-11 22:15:50 -0700 |
---|---|---|
committer | Mark Adler <madler@alumni.caltech.edu> | 2016-10-11 22:15:50 -0700 |
commit | 7096424f23df1b1813237fb5f8bc8f34cfcedd0c (patch) | |
tree | c41e8ef447e7e6764be5f3ba822fdc0c8da049f1 /gzwrite.c | |
parent | 2edb94a3025d288dc251bc6cbb2c02e60fbd7438 (diff) | |
download | zlib-7096424f23df1b1813237fb5f8bc8f34cfcedd0c.tar.gz zlib-7096424f23df1b1813237fb5f8bc8f34cfcedd0c.tar.bz2 zlib-7096424f23df1b1813237fb5f8bc8f34cfcedd0c.zip |
Clean up type conversions.
Diffstat (limited to 'gzwrite.c')
-rw-r--r-- | gzwrite.c | 22 |
1 files changed, 12 insertions, 10 deletions
@@ -72,7 +72,8 @@ local int gz_comp(state, flush) | |||
72 | gz_statep state; | 72 | gz_statep state; |
73 | int flush; | 73 | int flush; |
74 | { | 74 | { |
75 | int ret, got; | 75 | int ret; |
76 | ssize_t got; | ||
76 | unsigned have; | 77 | unsigned have; |
77 | z_streamp strm = &(state->strm); | 78 | z_streamp strm = &(state->strm); |
78 | 79 | ||
@@ -88,7 +89,7 @@ local int gz_comp(state, flush) | |||
88 | gz_error(state, Z_ERRNO, zstrerror()); | 89 | gz_error(state, Z_ERRNO, zstrerror()); |
89 | return -1; | 90 | return -1; |
90 | } | 91 | } |
91 | strm->avail_in -= got; | 92 | strm->avail_in -= (unsigned)got; |
92 | strm->next_in += got; | 93 | strm->next_in += got; |
93 | } | 94 | } |
94 | return 0; | 95 | return 0; |
@@ -103,7 +104,7 @@ local int gz_comp(state, flush) | |||
103 | (flush != Z_FINISH || ret == Z_STREAM_END))) { | 104 | (flush != Z_FINISH || ret == Z_STREAM_END))) { |
104 | while (strm->next_out > state->x.next) { | 105 | while (strm->next_out > state->x.next) { |
105 | got = write(state->fd, state->x.next, | 106 | got = write(state->fd, state->x.next, |
106 | strm->next_out - state->x.next); | 107 | (unsigned long)(strm->next_out - state->x.next)); |
107 | if (got < 0) { | 108 | if (got < 0) { |
108 | gz_error(state, Z_ERRNO, zstrerror()); | 109 | gz_error(state, Z_ERRNO, zstrerror()); |
109 | return -1; | 110 | return -1; |
@@ -281,7 +282,7 @@ int ZEXPORT gzputc(file, c) | |||
281 | strm->next_in = state->in; | 282 | strm->next_in = state->in; |
282 | have = (unsigned)((strm->next_in + strm->avail_in) - state->in); | 283 | have = (unsigned)((strm->next_in + strm->avail_in) - state->in); |
283 | if (have < state->size) { | 284 | if (have < state->size) { |
284 | state->in[have] = c; | 285 | state->in[have] = (unsigned char)c; |
285 | strm->avail_in++; | 286 | strm->avail_in++; |
286 | state->x.pos++; | 287 | state->x.pos++; |
287 | return c & 0xff; | 288 | return c & 0xff; |
@@ -289,7 +290,7 @@ int ZEXPORT gzputc(file, c) | |||
289 | } | 290 | } |
290 | 291 | ||
291 | /* no room in buffer or not initialized, use gz_write() */ | 292 | /* no room in buffer or not initialized, use gz_write() */ |
292 | buf[0] = c; | 293 | buf[0] = (unsigned char)c; |
293 | if (gzwrite(file, buf, 1) != 1) | 294 | if (gzwrite(file, buf, 1) != 1) |
294 | return -1; | 295 | return -1; |
295 | return c & 0xff; | 296 | return c & 0xff; |
@@ -315,7 +316,8 @@ int ZEXPORT gzputs(file, str) | |||
315 | /* -- see zlib.h -- */ | 316 | /* -- see zlib.h -- */ |
316 | int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) | 317 | int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) |
317 | { | 318 | { |
318 | unsigned len, left; | 319 | int len; |
320 | unsigned left; | ||
319 | char *next; | 321 | char *next; |
320 | gz_statep state; | 322 | gz_statep state; |
321 | z_streamp strm; | 323 | z_streamp strm; |
@@ -346,7 +348,7 @@ int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) | |||
346 | be state->size bytes available after the current contents */ | 348 | be state->size bytes available after the current contents */ |
347 | if (strm->avail_in == 0) | 349 | if (strm->avail_in == 0) |
348 | strm->next_in = state->in; | 350 | strm->next_in = state->in; |
349 | next = (char *)(strm->next_in + strm->avail_in); | 351 | next = (char *)(state->in + (strm->next_in - state->in) + strm->avail_in); |
350 | next[state->size - 1] = 0; | 352 | next[state->size - 1] = 0; |
351 | #ifdef NO_vsnprintf | 353 | #ifdef NO_vsnprintf |
352 | # ifdef HAS_vsprintf_void | 354 | # ifdef HAS_vsprintf_void |
@@ -366,11 +368,11 @@ int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) | |||
366 | #endif | 368 | #endif |
367 | 369 | ||
368 | /* check that printf() results fit in buffer */ | 370 | /* check that printf() results fit in buffer */ |
369 | if (len == 0 || len >= state->size || next[state->size - 1] != 0) | 371 | if (len == 0 || (unsigned)len >= state->size || next[state->size - 1] != 0) |
370 | return 0; | 372 | return 0; |
371 | 373 | ||
372 | /* update buffer and position, compress first half if past that */ | 374 | /* update buffer and position, compress first half if past that */ |
373 | strm->avail_in += len; | 375 | strm->avail_in += (unsigned)len; |
374 | state->x.pos += len; | 376 | state->x.pos += len; |
375 | if (strm->avail_in >= state->size) { | 377 | if (strm->avail_in >= state->size) { |
376 | left = strm->avail_in - state->size; | 378 | left = strm->avail_in - state->size; |
@@ -381,7 +383,7 @@ int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) | |||
381 | strm->next_in = state->in; | 383 | strm->next_in = state->in; |
382 | strm->avail_in = left; | 384 | strm->avail_in = left; |
383 | } | 385 | } |
384 | return (int)len; | 386 | return len; |
385 | } | 387 | } |
386 | 388 | ||
387 | int ZEXPORTVA gzprintf(gzFile file, const char *format, ...) | 389 | int ZEXPORTVA gzprintf(gzFile file, const char *format, ...) |