From 3a8c0b66897225c6f82371a406819a763d1a32b1 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 14 Mar 2011 21:51:27 +1100 Subject: [PATCH] Remove seeks that aren't required and don't work on tmp input buffers. Clean up open_stream_in. --- runzip.c | 7 +++++-- stream.c | 11 +++++++---- stream.h | 2 +- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/runzip.c b/runzip.c index d54794f..75d92c3 100644 --- a/runzip.c +++ b/runzip.c @@ -299,7 +299,7 @@ static i64 runzip_chunk(rzip_control *control, int fd_in, int fd_out, int fd_his print_maxverbose("Checksum for block: 0x%08x\n", cksum); } - if (unlikely(close_stream_in(control, ss))) + if (unlikely(close_stream_in(ss))) fatal("Failed to close stream!\n"); return total; @@ -336,9 +336,12 @@ i64 runzip_fd(rzip_control *control, int fd_in, int fd_out, int fd_hist, i64 exp md5_finish_ctx (&control->ctx, md5_resblock); if (HAS_MD5) { +#if 0 + /* Unnecessary, we should already be there */ if (unlikely(lseek(fd_in, -MD5_DIGEST_SIZE, SEEK_END)) == -1) fatal("Failed to seek to md5 data in runzip_fd\n"); - if (unlikely(read(fd_in, md5_stored, MD5_DIGEST_SIZE) != MD5_DIGEST_SIZE)) +#endif + if (unlikely(read_1g(control, fd_in, md5_stored, MD5_DIGEST_SIZE) != MD5_DIGEST_SIZE)) fatal("Failed to read md5 data in runzip_fd\n"); for (i = 0; i < MD5_DIGEST_SIZE; i++) if (md5_stored[i] != md5_resblock[i]) { diff --git a/stream.c b/stream.c index a7eb574..d7a92c2 100644 --- a/stream.c +++ b/stream.c @@ -1539,14 +1539,17 @@ int close_stream_out(rzip_control *control, void *ss) } /* close down an input stream */ -int close_stream_in(rzip_control *control, void *ss) +int close_stream_in(void *ss) { struct stream_info *sinfo = ss; int i; - if (unlikely(read_seekto(control, sinfo, sinfo->initial_pos + sinfo->total_read))) - return -1; - +#if 0 + /* Unnecessary, we should already be here */ + if (unlikely(lseek(sinfo->fd, sinfo->initial_pos + sinfo->total_read, + SEEK_SET) != sinfo->initial_pos + sinfo->total_read)) + return -1; +#endif for (i = 0; i < sinfo->num_streams; i++) free(sinfo->s[i].buf); diff --git a/stream.h b/stream.h index d56b735..3ba8c55 100644 --- a/stream.h +++ b/stream.h @@ -36,7 +36,7 @@ void flush_buffer(rzip_control *control, struct stream_info *sinfo, int stream); int write_stream(rzip_control *control, void *ss, int streamno, uchar *p, i64 len); i64 read_stream(rzip_control *control, void *ss, int streamno, uchar *p, i64 len); int close_stream_out(rzip_control *control, void *ss); -int close_stream_in(rzip_control *control, void *ss); +int close_stream_in(void *ss); const i64 one_g; #endif