Fix a warning about comparing signed and unsigned values PiperOrigin-RevId: 190977545
diff --git a/third_party/ijar/mapped_file.h b/third_party/ijar/mapped_file.h index 7653638..874db8b 100644 --- a/third_party/ijar/mapped_file.h +++ b/third_party/ijar/mapped_file.h
@@ -62,10 +62,10 @@ const char* errmsg_; bool opened_; u1* buffer_; - u8 estimated_size_; + size_t estimated_size_; public: - MappedOutputFile(const char* name, u8 estimated_size); + MappedOutputFile(const char* name, size_t estimated_size); virtual ~MappedOutputFile(); // If opening the file succeeded or not. @@ -76,7 +76,7 @@ // The mapped contents of the file. u1* Buffer() const { return buffer_; } - int Close(int size); + int Close(size_t size); }; } // namespace devtools_ijar
diff --git a/third_party/ijar/mapped_file_unix.cc b/third_party/ijar/mapped_file_unix.cc index ccb8787..ced7d87 100644 --- a/third_party/ijar/mapped_file_unix.cc +++ b/third_party/ijar/mapped_file_unix.cc
@@ -90,7 +90,7 @@ int mmap_length_; }; -MappedOutputFile::MappedOutputFile(const char* name, u8 estimated_size) +MappedOutputFile::MappedOutputFile(const char* name, size_t estimated_size) : estimated_size_(estimated_size) { impl_ = NULL; opened_ = false; @@ -111,7 +111,7 @@ // Ensure that any buffer overflow in JarStripper will result in // SIGSEGV or SIGBUS by over-allocating beyond the end of the file. size_t mmap_length = std::min(estimated_size + sysconf(_SC_PAGESIZE), - (u8) std::numeric_limits<size_t>::max()); + std::numeric_limits<size_t>::max()); void* mapped = mmap(NULL, mmap_length, PROT_WRITE, MAP_SHARED, fd, 0); if (mapped == MAP_FAILED) { snprintf(errmsg, MAX_ERROR, "mmap(): %s", strerror(errno)); @@ -131,9 +131,9 @@ delete impl_; } -int MappedOutputFile::Close(int size) { +int MappedOutputFile::Close(size_t size) { if (size > estimated_size_) { - snprintf(errmsg, MAX_ERROR, "size %d > estimated size %lld", size, + snprintf(errmsg, MAX_ERROR, "size %zu > estimated size %zu", size, estimated_size_); errmsg_ = errmsg; return -1;
diff --git a/third_party/ijar/mapped_file_windows.cc b/third_party/ijar/mapped_file_windows.cc index 6fb8b36..6292605 100644 --- a/third_party/ijar/mapped_file_windows.cc +++ b/third_party/ijar/mapped_file_windows.cc
@@ -125,7 +125,7 @@ } }; -MappedOutputFile::MappedOutputFile(const char* name, u8 estimated_size) { +MappedOutputFile::MappedOutputFile(const char* name, size_t estimated_size) { impl_ = NULL; opened_ = false; errmsg_ = errmsg; @@ -169,7 +169,7 @@ delete impl_; } -int MappedOutputFile::Close(int size) { +int MappedOutputFile::Close(size_t size) { if (!UnmapViewOfFile(buffer_)) { blaze_util::die(255, "MappedOutputFile::Close: UnmapViewOfFile failed: %s", blaze_util::GetLastErrorString().c_str());
diff --git a/third_party/ijar/zip.cc b/third_party/ijar/zip.cc index 9a719db..93136e5 100644 --- a/third_party/ijar/zip.cc +++ b/third_party/ijar/zip.cc
@@ -71,7 +71,7 @@ namespace devtools_ijar { // In the absence of ZIP64 support, zip files are limited to 4GB. // http://www.info-zip.org/FAQ.html#limits -static const u8 kMaximumOutputSize = std::numeric_limits<uint32_t>::max(); +static const size_t kMaximumOutputSize = std::numeric_limits<uint32_t>::max(); static const u4 kDefaultTimestamp = 30 << 25 | 1 << 21 | 1 << 16; // January 1, 2010 in DOS time @@ -199,11 +199,11 @@ // class OutputZipFile : public ZipBuilder { public: - OutputZipFile(const char* filename, u8 estimated_size) : - output_file_(NULL), - filename_(filename), - estimated_size_(estimated_size), - finished_(false) { + OutputZipFile(const char *filename, size_t estimated_size) + : output_file_(NULL), + filename_(filename), + estimated_size_(estimated_size), + finished_(false) { errmsg[0] = 0; } @@ -257,7 +257,7 @@ MappedOutputFile* output_file_; const char* filename_; - u8 estimated_size_; + size_t estimated_size_; bool finished_; // OutputZipFile is responsible for maintaining the following @@ -1078,8 +1078,8 @@ bool OutputZipFile::Open() { if (estimated_size_ > kMaximumOutputSize) { fprintf(stderr, - "Uncompressed input jar has size %llu, " - "which exceeds the maximum supported output size %llu.\n" + "Uncompressed input jar has size %lu, " + "which exceeds the maximum supported output size %lu.\n" "Assuming that ijar will be smaller and hoping for the best.\n", estimated_size_, kMaximumOutputSize); estimated_size_ = kMaximumOutputSize; @@ -1099,7 +1099,7 @@ return true; } -ZipBuilder* ZipBuilder::Create(const char* zip_file, u8 estimated_size) { +ZipBuilder *ZipBuilder::Create(const char *zip_file, size_t estimated_size) { OutputZipFile* result = new OutputZipFile(zip_file, estimated_size); if (!result->Open()) { fprintf(stderr, "%s\n", result->GetError());
diff --git a/third_party/ijar/zip.h b/third_party/ijar/zip.h index dfd3595..b41d07c 100644 --- a/third_party/ijar/zip.h +++ b/third_party/ijar/zip.h
@@ -93,7 +93,7 @@ // ZipExtractor::CalculateOuputLength() to have an estimated_size depending on // a list of file to store. // On failure, returns NULL. Refer to errno for error code. - static ZipBuilder* Create(const char* zip_file, u8 estimated_size); + static ZipBuilder* Create(const char* zip_file, size_t estimated_size); // Estimate the maximum size of the ZIP files containing files in the "files" // null-terminated array.