diff options
author | François Degros <fdegros@chromium.org> | 2022-02-10 01:23:36 +0000 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2022-02-09 17:34:45 -0800 |
commit | 87b4a54c2a38d9a673831dd43c29ad0e5a48a856 (patch) | |
tree | 269ac6d68f6685c0e6c61f6654022b6b146fe109 | |
parent | 6e2ac2abe8769429111570802caf0a470794f980 (diff) | |
download | zlib-87b4a54c2a38d9a673831dd43c29ad0e5a48a856.tar.gz |
[zip] Simplify ZipReader::AdvanceToNextEntry
BUG=chromium:1295127
TEST=autoninja -C out/Default zlib_unittests && out/Default/zlib_unittests
Change-Id: Ie54cc0843eb0fa6f0bb89f738a09ddb9ecf58ee5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3450013
Reviewed-by: Noel Gordon <noel@chromium.org>
Commit-Queue: François Degros <fdegros@chromium.org>
Cr-Commit-Position: refs/heads/main@{#969222}
NOKEYCHECK=True
GitOrigin-RevId: 3649bcde642cbaa8c7dfc04977f1a6b154403495
-rw-r--r-- | google/zip_reader.cc | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/google/zip_reader.cc b/google/zip_reader.cc index bc2e01b..2e3f877 100644 --- a/google/zip_reader.cc +++ b/google/zip_reader.cc @@ -201,17 +201,9 @@ bool ZipReader::AdvanceToNextEntry() { if (reached_end_) return false; - unz_file_pos position = {}; - if (unzGetFilePos(zip_file_, &position) != UNZ_OK) - return false; - const int current_entry_index = position.num_of_file; - // If we are currently at the last entry, then the next position is the - // end of the ZIP archive, so mark that we reached the end. - if (current_entry_index + 1 == num_entries_) { + if (const int err = unzGoToNextFile(zip_file_); err != UNZ_OK) { reached_end_ = true; - } else { - DCHECK_LT(current_entry_index + 1, num_entries_); - if (const int err = unzGoToNextFile(zip_file_); err != UNZ_OK) { + if (err != UNZ_END_OF_LIST_OF_FILE) { LOG(ERROR) << "Cannot go to next entry in ZIP: " << UnzipError(err); return false; } |