diff options
author | pkasting <pkasting@chromium.org> | 2014-10-03 11:52:29 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-03 18:52:42 +0000 |
commit | 8e3a26aaf2392d784ba6d5cbb696da926230a722 (patch) | |
tree | c6556382e51d205e9d704072e8b07c007d8bc651 /courgette/encoded_program.cc | |
parent | 1bd4f75c6522dc81b8ba30ca4174e2c312c43d83 (diff) | |
download | chromium_src-8e3a26aaf2392d784ba6d5cbb696da926230a722.zip chromium_src-8e3a26aaf2392d784ba6d5cbb696da926230a722.tar.gz chromium_src-8e3a26aaf2392d784ba6d5cbb696da926230a722.tar.bz2 |
Fix more MSVC warnings, courgette/ edition.
This is mostly about changing types and inserting casts so as to avoid implicit
value truncations.
BUG=81439
TEST=none
Review URL: https://codereview.chromium.org/613893002
Cr-Commit-Position: refs/heads/master@{#298069}
Diffstat (limited to 'courgette/encoded_program.cc')
-rw-r--r-- | courgette/encoded_program.cc | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/courgette/encoded_program.cc b/courgette/encoded_program.cc index b78e7fe..b120246 100644 --- a/courgette/encoded_program.cc +++ b/courgette/encoded_program.cc @@ -46,8 +46,6 @@ CheckBool WriteVector(const V& items, SinkStream* buffer) { size_t count = items.size(); bool ok = buffer->WriteSizeVarint32(count); for (size_t i = 0; ok && i < count; ++i) { - COMPILE_ASSERT(sizeof(items[0]) <= sizeof(uint32), // NOLINT - T_must_fit_in_uint32); ok = buffer->WriteSizeVarint32(items[i]); } return ok; @@ -196,7 +194,7 @@ CheckBool EncodedProgram::AddOrigin(RVA origin) { return ops_.push_back(ORIGIN) && origins_.push_back(origin); } -CheckBool EncodedProgram::AddCopy(uint32 count, const void* bytes) { +CheckBool EncodedProgram::AddCopy(size_t count, const void* bytes) { const uint8* source = static_cast<const uint8*>(bytes); bool ok = true; @@ -214,7 +212,7 @@ CheckBool EncodedProgram::AddCopy(uint32 count, const void* bytes) { } if (ok && ops_.back() == COPY) { copy_counts_.back() += count; - for (uint32 i = 0; ok && i < count; ++i) { + for (size_t i = 0; ok && i < count; ++i) { ok = copy_bytes_.push_back(source[i]); } return ok; @@ -226,7 +224,7 @@ CheckBool EncodedProgram::AddCopy(uint32 count, const void* bytes) { ok = ops_.push_back(COPY1) && copy_bytes_.push_back(source[0]); } else { ok = ops_.push_back(COPY) && copy_counts_.push_back(count); - for (uint32 i = 0; ok && i < count; ++i) { + for (size_t i = 0; ok && i < count; ++i) { ok = copy_bytes_.push_back(source[i]); } } @@ -427,7 +425,7 @@ CheckBool EncodedProgram::EvaluateRel32ARM(OP op, &decompressed_op)) { return false; } - uint16 op16 = decompressed_op; + uint16 op16 = static_cast<uint16>(decompressed_op); if (!output->Write(&op16, 2)) return false; current_rva += 2; @@ -447,7 +445,7 @@ CheckBool EncodedProgram::EvaluateRel32ARM(OP op, &decompressed_op)) { return false; } - uint16 op16 = decompressed_op; + uint16 op16 = static_cast<uint16>(decompressed_op); if (!output->Write(&op16, 2)) return false; current_rva += 2; @@ -556,11 +554,11 @@ CheckBool EncodedProgram::AssembleTo(SinkStream* final_buffer) { } case COPY: { - uint32 count; + size_t count; if (!VectorAt(copy_counts_, ix_copy_counts, &count)) return false; ++ix_copy_counts; - for (uint32 i = 0; i < count; ++i) { + for (size_t i = 0; i < count; ++i) { uint8 b; if (!VectorAt(copy_bytes_, ix_copy_bytes, &b)) return false; @@ -568,7 +566,7 @@ CheckBool EncodedProgram::AssembleTo(SinkStream* final_buffer) { if (!output->Write(&b, 1)) return false; } - current_rva += count; + current_rva += static_cast<RVA>(count); break; } |