diff --git a/runzip.c b/runzip.c index a3915a6..5a2c238 100644 --- a/runzip.c +++ b/runzip.c @@ -135,7 +135,7 @@ static i64 unzip_literal(rzip_control *control, void *ss, i64 len, int fd_out, u if (unlikely(stream_read == -1 )) fatal("Failed to read_stream in unzip_literal\n"); - if (unlikely(write_1g(control, fd_out, buf, (size_t)stream_read) != (ssize_t)stream_read)) + if (unlikely(write_1g(control, buf, (size_t)stream_read) != (ssize_t)stream_read)) fatal("Failed to write literal buffer of size %lld\n", stream_read); if (!HAS_MD5) @@ -189,7 +189,7 @@ static i64 unzip_match(rzip_control *control, void *ss, i64 len, int fd_out, int if (unlikely(read_fdhist(control, off_buf, (size_t)n) != (ssize_t)n)) fatal("Failed to read %d bytes in unzip_match\n", n); - if (unlikely(write_1g(control, fd_out, off_buf, (size_t)n) != (ssize_t)n)) + if (unlikely(write_1g(control, off_buf, (size_t)n) != (ssize_t)n)) fatal("Failed to write %d bytes in unzip_match\n", n); if (!HAS_MD5) diff --git a/rzip.c b/rzip.c index da65740..9725d5d 100644 --- a/rzip.c +++ b/rzip.c @@ -975,7 +975,7 @@ retry: print_output("%02x", md5_resblock[j] & 0xFF); print_output("\n"); } - if (unlikely(write_1g(control, control->fd_out, md5_resblock, MD5_DIGEST_SIZE) != MD5_DIGEST_SIZE)) + if (unlikely(write_1g(control, md5_resblock, MD5_DIGEST_SIZE) != MD5_DIGEST_SIZE)) fatal("Failed to write md5 in rzip_fd\n"); if (TMP_OUTBUF) diff --git a/stream.c b/stream.c index f788b33..8b1b43d 100644 --- a/stream.c +++ b/stream.c @@ -635,10 +635,10 @@ out: const i64 one_g = 1000 * 1024 * 1024; -ssize_t put_fdout(rzip_control *control, int fd, void *offset_buf, ssize_t ret) +ssize_t put_fdout(rzip_control *control, void *offset_buf, ssize_t ret) { if (!TMP_OUTBUF) - return write(fd, offset_buf, (size_t)ret); + return write(control->fd_out, offset_buf, (size_t)ret); if (unlikely(control->out_ofs + ret > control->out_maxlen)) failure("Tried to write beyond temporary output buffer. Need a larger out_maxlen\n"); @@ -652,7 +652,7 @@ ssize_t put_fdout(rzip_control *control, int fd, void *offset_buf, ssize_t ret) /* This is a custom version of write() which writes in 1GB chunks to avoid the overflows at the >= 2GB mark thanks to 32bit fuckage. This should help even on the rare occasion write() fails to write 1GB as well. */ -ssize_t write_1g(rzip_control *control, int fd, void *buf, i64 len) +ssize_t write_1g(rzip_control *control,void *buf, i64 len) { uchar *offset_buf = buf; ssize_t ret; @@ -664,7 +664,7 @@ ssize_t write_1g(rzip_control *control, int fd, void *buf, i64 len) ret = one_g; else ret = len; - ret = put_fdout(control, fd, offset_buf, (size_t)ret); + ret = put_fdout(control, offset_buf, (size_t)ret); if (unlikely(ret <= 0)) return ret; len -= ret; @@ -702,7 +702,7 @@ static int write_buf(rzip_control *control, int f, uchar *p, i64 len) { ssize_t ret; - ret = write_1g(control, f, p, (size_t)len); + ret = write_1g(control, p, (size_t)len); if (unlikely(ret == -1)) { print_err("Write of length %lld failed - %s\n", len, strerror(errno)); return -1; diff --git a/stream.h b/stream.h index af4db59..e659b26 100644 --- a/stream.h +++ b/stream.h @@ -26,7 +26,7 @@ void create_pthread(pthread_t *thread, pthread_attr_t *attr, void * (*start_routine)(void *), void *arg); void join_pthread(pthread_t th, void **thread_return); -ssize_t write_1g(rzip_control *control, int fd, void *buf, i64 len); +ssize_t write_1g(rzip_control *control, void *buf, i64 len); ssize_t read_1g(int fd, void *buf, i64 len); void prepare_streamout_threads(rzip_control *control); void close_streamout_threads(rzip_control *control);