mirror of
https://github.com/facebook/zstd.git
synced 2025-07-30 22:23:13 +03:00
fixed clang warnings in gzread.c and gzwrite.c
This commit is contained in:
@ -27,7 +27,7 @@ local int gz_load(state, buf, len, have)
|
|||||||
unsigned len;
|
unsigned len;
|
||||||
unsigned *have;
|
unsigned *have;
|
||||||
{
|
{
|
||||||
int ret;
|
ssize_t ret;
|
||||||
unsigned get, max = ((unsigned)-1 >> 2) + 1;
|
unsigned get, max = ((unsigned)-1 >> 2) + 1;
|
||||||
|
|
||||||
*have = 0;
|
*have = 0;
|
||||||
@ -320,7 +320,7 @@ local z_size_t gz_read(state, buf, len)
|
|||||||
/* set n to the maximum amount of len that fits in an unsigned int */
|
/* set n to the maximum amount of len that fits in an unsigned int */
|
||||||
n = -1;
|
n = -1;
|
||||||
if (n > len)
|
if (n > len)
|
||||||
n = len;
|
n = (unsigned)len;
|
||||||
|
|
||||||
/* first just try copying data from the output buffer */
|
/* first just try copying data from the output buffer */
|
||||||
if (state.state->x.have) {
|
if (state.state->x.have) {
|
||||||
@ -401,7 +401,7 @@ int ZEXPORT gzread(file, buf, len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* read len or fewer bytes to buf */
|
/* read len or fewer bytes to buf */
|
||||||
len = gz_read(state, buf, len);
|
len = (unsigned)gz_read(state, buf, len);
|
||||||
|
|
||||||
/* check for an error */
|
/* check for an error */
|
||||||
if (len == 0 && state.state->err != Z_OK && state.state->err != Z_BUF_ERROR)
|
if (len == 0 && state.state->err != Z_OK && state.state->err != Z_BUF_ERROR)
|
||||||
@ -485,7 +485,7 @@ int ZEXPORT gzgetc(file)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* nothing there -- try gz_read() */
|
/* nothing there -- try gz_read() */
|
||||||
ret = gz_read(state, buf, 1);
|
ret = (unsigned)gz_read(state, buf, 1);
|
||||||
return ret < 1 ? -1 : buf[0];
|
return ret < 1 ? -1 : buf[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ local int gz_comp(state, flush)
|
|||||||
if (state.state->direct) {
|
if (state.state->direct) {
|
||||||
while (strm->avail_in) {
|
while (strm->avail_in) {
|
||||||
put = strm->avail_in > max ? max : strm->avail_in;
|
put = strm->avail_in > max ? max : strm->avail_in;
|
||||||
writ = write(state.state->fd, strm->next_in, put);
|
writ = (int)write(state.state->fd, strm->next_in, put);
|
||||||
if (writ < 0) {
|
if (writ < 0) {
|
||||||
gz_error(state, Z_ERRNO, zstrerror());
|
gz_error(state, Z_ERRNO, zstrerror());
|
||||||
return -1;
|
return -1;
|
||||||
@ -110,7 +110,7 @@ local int gz_comp(state, flush)
|
|||||||
while (strm->next_out > state.state->x.next) {
|
while (strm->next_out > state.state->x.next) {
|
||||||
put = strm->next_out - state.state->x.next > (int)max ? max :
|
put = strm->next_out - state.state->x.next > (int)max ? max :
|
||||||
(unsigned)(strm->next_out - state.state->x.next);
|
(unsigned)(strm->next_out - state.state->x.next);
|
||||||
writ = write(state.state->fd, state.state->x.next, put);
|
writ = (int)write(state.state->fd, state.state->x.next, put);
|
||||||
if (writ < 0) {
|
if (writ < 0) {
|
||||||
gz_error(state, Z_ERRNO, zstrerror());
|
gz_error(state, Z_ERRNO, zstrerror());
|
||||||
return -1;
|
return -1;
|
||||||
@ -204,7 +204,7 @@ local z_size_t gz_write(state, buf, len)
|
|||||||
if (len < state.state->size) {
|
if (len < state.state->size) {
|
||||||
/* copy to input buffer, compress when full */
|
/* copy to input buffer, compress when full */
|
||||||
do {
|
do {
|
||||||
unsigned have, copy;
|
z_size_t have, copy;
|
||||||
|
|
||||||
if (state.state->strm.avail_in == 0)
|
if (state.state->strm.avail_in == 0)
|
||||||
state.state->strm.next_in = state.state->in;
|
state.state->strm.next_in = state.state->in;
|
||||||
@ -230,10 +230,10 @@ local z_size_t gz_write(state, buf, len)
|
|||||||
/* directly compress user buffer to file */
|
/* directly compress user buffer to file */
|
||||||
state.state->strm.next_in = (z_const Bytef *)buf;
|
state.state->strm.next_in = (z_const Bytef *)buf;
|
||||||
do {
|
do {
|
||||||
unsigned n = (unsigned)-1;
|
z_size_t n = (unsigned)-1;
|
||||||
if (n > len)
|
if (n > len)
|
||||||
n = len;
|
n = len;
|
||||||
state.state->strm.avail_in = n;
|
state.state->strm.avail_in = (z_uInt)n;
|
||||||
state.state->x.pos += n;
|
state.state->x.pos += n;
|
||||||
if (gz_comp(state, Z_NO_FLUSH) == -1)
|
if (gz_comp(state, Z_NO_FLUSH) == -1)
|
||||||
return 0;
|
return 0;
|
||||||
@ -371,7 +371,7 @@ int ZEXPORT gzputs(file, str)
|
|||||||
|
|
||||||
/* write string */
|
/* write string */
|
||||||
len = strlen(str);
|
len = strlen(str);
|
||||||
ret = gz_write(state, str, len);
|
ret = (int)gz_write(state, str, len);
|
||||||
return ret == 0 && len != 0 ? -1 : ret;
|
return ret == 0 && len != 0 ? -1 : ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user