From 51a7a6e6e773788fa862a13dac9a2c0cde699d17 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Wed, 6 Mar 2013 17:01:56 +0100 Subject: [PATCH] Bug 848270 - Various fixups for Android builds on OSX after bug 847479. r=nfroyd --- mozglue/linker/SeekableZStream.h | 6 ------ mozglue/linker/szip.cpp | 10 +++++++--- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/mozglue/linker/SeekableZStream.h b/mozglue/linker/SeekableZStream.h index 884d675ca77..be2f4cacdb2 100644 --- a/mozglue/linker/SeekableZStream.h +++ b/mozglue/linker/SeekableZStream.h @@ -49,12 +49,6 @@ struct SeekableZStreamHeader: public Zip::SignedEntity /* Filter Id */ unsigned char filter; - - /* Maximum supported size for chunkSize */ - /* Can't use std::min here because it's not constexpr */ - static const size_t maxChunkSize = - 1 << ((sizeof(chunkSize) < sizeof(lastChunkSize) ? - sizeof(chunkSize) : sizeof(lastChunkSize)) - 1); }; #pragma pack() diff --git a/mozglue/linker/szip.cpp b/mozglue/linker/szip.cpp index 88145ae0e08..586c53dcfbe 100644 --- a/mozglue/linker/szip.cpp +++ b/mozglue/linker/szip.cpp @@ -16,13 +16,18 @@ #include "Utils.h" #include "Logging.h" +/* Maximum supported size for chunkSize */ +static const size_t maxChunkSize = + 1 << (8 * std::min(sizeof(((SeekableZStreamHeader *)NULL)->chunkSize), + sizeof(((SeekableZStreamHeader *)NULL)->lastChunkSize)) - 1); + class Buffer: public MappedPtr { public: virtual bool Resize(size_t size) { void *buf = mmap(NULL, size, PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + MAP_PRIVATE | MAP_ANON, -1, 0); if (buf == MAP_FAILED) return false; if (*this != MAP_FAILED) @@ -334,8 +339,7 @@ int main(int argc, char* argv[]) if (!firstArg[0]) break; if (!GetSize(firstArg[0], &chunkSize) || !chunkSize || - (chunkSize % 4096) || - (chunkSize > SeekableZStreamHeader::maxChunkSize)) { + (chunkSize % 4096) || (chunkSize > maxChunkSize)) { log("Invalid chunk size"); return 1; }