diff --git a/runzip.c b/runzip.c index d19407c..1002764 100644 --- a/runzip.c +++ b/runzip.c @@ -71,7 +71,7 @@ static i64 unzip_literal(void *ss, i64 len, int fd_out, uint32 *cksum) if (unlikely(len < 0)) fatal("len %lld is negative in unzip_literal!\n",len); - buf = malloc(len); + buf = (uchar *)malloc(len); if (unlikely(!buf)) fatal("Failed to malloc literal buffer of size %lld\n", len); @@ -110,7 +110,7 @@ static i64 unzip_match(void *ss, i64 len, int fd_out, int fd_hist, uint32 *cksum uchar *buf; n = MIN(len, offset); - buf = malloc(n); + buf = (uchar *)malloc(n); if (unlikely(!buf)) fatal("Failed to malloc match buffer of size %lld\n", n); diff --git a/stream.c b/stream.c index dbef321..2ea6502 100644 --- a/stream.c +++ b/stream.c @@ -606,7 +606,7 @@ ssize_t write_1g(int fd, void *buf, i64 len) else ret = len; ret = write(fd, offset_buf, (size_t)ret); - if (unlikely(ret < 0)) + if (unlikely(ret <= 0)) return ret; len -= ret; offset_buf += ret; @@ -629,7 +629,7 @@ ssize_t read_1g(int fd, void *buf, i64 len) else ret = len; ret = read(fd, offset_buf, (size_t)ret); - if (unlikely(ret < 0)) + if (unlikely(ret <= 0)) return ret; len -= ret; offset_buf += ret;