From: Tim Kientzle Date: Fri, 2 Dec 2011 04:40:42 +0000 (-0500) Subject: Initialize offset/size/buff once at the top of read_data. X-Git-Tag: v3.0.2~77 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=867d77b4ec3e7bc7748a5bbbf647dcb6aef780c3;p=thirdparty%2Flibarchive.git Initialize offset/size/buff once at the top of read_data. Since offset is very consistent, we can eliminate a lot of other places it was being set. SVN-Revision: 3895 --- diff --git a/libarchive/archive_read_support_format_zip.c b/libarchive/archive_read_support_format_zip.c index e94f898ae..58c8127c5 100644 --- a/libarchive/archive_read_support_format_zip.c +++ b/libarchive/archive_read_support_format_zip.c @@ -713,17 +713,17 @@ archive_read_format_zip_read_data(struct archive_read *a, struct zip *zip; zip = (struct zip *)(a->format->data); + *offset = zip->entry_uncompressed_bytes_read; + *size = 0; + *buff = NULL; - /* - * If we hit end-of-entry last time, clean up and return - * ARCHIVE_EOF this time. - */ - if (zip->end_of_entry) { - *offset = zip->entry_uncompressed_bytes_read; - *size = 0; - *buff = NULL; + /* If we hit end-of-entry last time, return ARCHIVE_EOF. */ + if (zip->end_of_entry) + return (ARCHIVE_EOF); + + /* Return EOF immediately if this is a non-regular file. */ + if (AE_IFREG != (zip->entry->mode & AE_IFMT)) return (ARCHIVE_EOF); - } __archive_read_consume(a, zip->unconsumed); zip->unconsumed = 0; @@ -739,9 +739,6 @@ archive_read_format_zip_read_data(struct archive_read *a, break; #endif default: /* Unsupported compression. */ - *buff = NULL; - *size = 0; - *offset = 0; /* Return a warning. */ archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, "Unsupported ZIP compression method (%s)", @@ -830,9 +827,6 @@ archive_read_format_zip_read_data(struct archive_read *a, } } - /* Return EOF immediately if this is a non-regular file. */ - if (AE_IFREG != (zip->entry->mode & AE_IFMT)) - return (ARCHIVE_EOF); return (ARCHIVE_OK); } @@ -868,9 +862,6 @@ zip_read_data_none(struct archive_read *a, const void **_buff, ssize_t bytes_avail; zip = (struct zip *)(a->format->data); - *_buff = NULL; - *size = 0; - *offset = zip->entry_uncompressed_bytes_read; if (zip->entry->flags & ZIP_LENGTH_AT_END) { const char *p; @@ -1031,7 +1022,6 @@ zip_read_data_deflate(struct archive_read *a, const void **buff, zip->entry_bytes_remaining -= bytes_avail; zip->entry_compressed_bytes_read += bytes_avail; - *offset = zip->entry_uncompressed_bytes_read; *size = zip->stream.total_out; zip->entry_uncompressed_bytes_read += *size; *buff = zip->uncompressed_buffer;