summaryrefslogtreecommitdiff
path: root/libziparchive
diff options
context:
space:
mode:
authorDmitriy Ivanov <dimitry@google.com>2015-03-06 11:48:47 -0800
committerDmitriy Ivanov <dimitry@google.com>2015-03-06 12:45:03 -0800
commit3ea93da3c21c9f35d658f4760064a404fce3b43b (patch)
tree396acafaa2828cf3310b51104816d6b9afda5b31 /libziparchive
parent8b1a94c07cb02a0398238ebaab4a2a0a23f7d28c (diff)
Remove some gotos
Change-Id: I0e162c8e0a700940f4302786b8523e5b2f5e5c27
Diffstat (limited to 'libziparchive')
-rw-r--r--libziparchive/zip_archive.cc21
1 files changed, 8 insertions, 13 deletions
diff --git a/libziparchive/zip_archive.cc b/libziparchive/zip_archive.cc
index 7ae9af858..f96cba643 100644
--- a/libziparchive/zip_archive.cc
+++ b/libziparchive/zip_archive.cc
@@ -579,7 +579,6 @@ static int32_t MapCentralDirectory(int fd, const char* debug_file_name,
* Returns 0 on success.
*/
static int32_t ParseZipArchive(ZipArchive* archive) {
- int32_t result = -1;
const uint8_t* const cd_ptr =
reinterpret_cast<const uint8_t*>(archive->directory_map.getDataPtr());
const size_t cd_length = archive->directory_map.getDataLength();
@@ -605,19 +604,19 @@ static int32_t ParseZipArchive(ZipArchive* archive) {
reinterpret_cast<const CentralDirectoryRecord*>(ptr);
if (cdr->record_signature != CentralDirectoryRecord::kSignature) {
ALOGW("Zip: missed a central dir sig (at %" PRIu16 ")", i);
- goto bail;
+ return -1;
}
if (ptr + sizeof(CentralDirectoryRecord) > cd_end) {
ALOGW("Zip: ran off the end (at %" PRIu16 ")", i);
- goto bail;
+ return -1;
}
const off64_t local_header_offset = cdr->local_file_header_offset;
if (local_header_offset >= archive->directory_offset) {
ALOGW("Zip: bad LFH offset %" PRId64 " at entry %" PRIu16,
static_cast<int64_t>(local_header_offset), i);
- goto bail;
+ return -1;
}
const uint16_t file_name_length = cdr->file_name_length;
@@ -627,7 +626,7 @@ static int32_t ParseZipArchive(ZipArchive* archive) {
/* check that file name is valid UTF-8 and doesn't contain NUL (U+0000) characters */
if (!IsValidEntryName(file_name, file_name_length)) {
- goto bail;
+ return -1;
}
/* add the CDE filename to the hash table */
@@ -636,25 +635,21 @@ static int32_t ParseZipArchive(ZipArchive* archive) {
entry_name.name_length = file_name_length;
const int add_result = AddToHash(archive->hash_table,
archive->hash_table_size, entry_name);
- if (add_result) {
+ if (add_result != 0) {
ALOGW("Zip: Error adding entry to hash table %d", add_result);
- result = add_result;
- goto bail;
+ return add_result;
}
ptr += sizeof(CentralDirectoryRecord) + file_name_length + extra_length + comment_length;
if ((ptr - cd_ptr) > static_cast<int64_t>(cd_length)) {
ALOGW("Zip: bad CD advance (%tu vs %zu) at entry %" PRIu16,
ptr - cd_ptr, cd_length, i);
- goto bail;
+ return -1;
}
}
ALOGV("+++ zip good scan %" PRIu16 " entries", num_entries);
- result = 0;
-
-bail:
- return result;
+ return 0;
}
static int32_t OpenArchiveInternal(ZipArchive* archive,