diff options
author | Jukka Jylänki <jujjyl@gmail.com> | 2016-03-28 21:33:03 +0300 |
---|---|---|
committer | Jukka Jylänki <jujjyl@gmail.com> | 2016-03-28 21:40:45 +0300 |
commit | 246c58952f4f56ebc9614459b218cbc885dd13d4 (patch) | |
tree | 6225b3e6d808d7e4091d458b7bf1a092379c037e /src | |
parent | 4b019795697ddd33bd66089881b351f9f0549c78 (diff) | |
download | binaryen-246c58952f4f56ebc9614459b218cbc885dd13d4.tar.gz binaryen-246c58952f4f56ebc9614459b218cbc885dd13d4.tar.bz2 binaryen-246c58952f4f56ebc9614459b218cbc885dd13d4.zip |
Use std::numeric_limits<uint32_t>::max() instead of 0xFFFFFFFF.
Diffstat (limited to 'src')
-rw-r--r-- | src/support/file.cpp | 5 | ||||
-rw-r--r-- | src/wasm-s-parser.h | 3 |
2 files changed, 5 insertions, 3 deletions
diff --git a/src/support/file.cpp b/src/support/file.cpp index 0401ea724..da7054f7f 100644 --- a/src/support/file.cpp +++ b/src/support/file.cpp @@ -17,6 +17,7 @@ #include "support/file.h" #include <cstdlib> +#include <limits> template <typename T> T wasm::read_file(const std::string &filename, bool debug) { @@ -27,8 +28,8 @@ T wasm::read_file(const std::string &filename, bool debug) { exit(EXIT_FAILURE); } infile.seekg(0, std::ios::end); - std::streamoff insize = infile.tellg(); - if (sizeof(size_t) == 4 && insize >= 0xFFFFFFFFU) { + std::streampos insize = infile.tellg(); + if (insize >= std::numeric_limits<size_t>::max()) { // Building a 32-bit executable where size_t == 32 bits, we are not able to create strings larger than 2^32 bytes in length, so must abort here. std::cerr << "Failed opening '" << filename << "': Input file too large: " << insize << " bytes. Try rebuilding in 64-bit mode." << std::endl; exit(EXIT_FAILURE); diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h index 4c22fb1e3..c3f32e809 100644 --- a/src/wasm-s-parser.h +++ b/src/wasm-s-parser.h @@ -23,6 +23,7 @@ #define wasm_wasm_s_parser_h #include <cmath> +#include <limits> #include "wasm.h" #include "mixed_arena.h" @@ -825,7 +826,7 @@ private: ret->align = atoi(eq); } else if (str[0] == 'o') { uint64_t offset = atoll(eq); - if (offset > 0xffffffff) onError(); + if (offset > std::numeric_limits<uint32_t>::max()) onError(); ret->offset = (uint32_t)offset; } else onError(); i++; |