diff options
author | sra@google.com <sra@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-18 03:28:40 +0000 |
---|---|---|
committer | sra@google.com <sra@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-18 03:28:40 +0000 |
commit | 54f1b829fe53c48b82440e7c8482e2b6ca397995 (patch) | |
tree | 5600358a8d8fac77ea4a7730fca9c4b6cbe09108 | |
parent | 4efe77c3fd39df0dc03b0d73ca0ba24c6e66ff28 (diff) | |
download | chromium_src-54f1b829fe53c48b82440e7c8482e2b6ca397995.zip chromium_src-54f1b829fe53c48b82440e7c8482e2b6ca397995.tar.gz chromium_src-54f1b829fe53c48b82440e7c8482e2b6ca397995.tar.bz2 |
Code changes to get the code to compile under GCC.
Courgette still only knows how to compress Windows x86 executables.
But now you can compress them on linux.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/149597
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21042 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | build/all.gyp | 1 | ||||
-rw-r--r-- | courgette/adjustment_method_2.cc | 21 | ||||
-rw-r--r-- | courgette/assembly_program.cc | 9 | ||||
-rw-r--r-- | courgette/courgette.h | 13 | ||||
-rw-r--r-- | courgette/courgette_minimal_tool.cc | 4 | ||||
-rw-r--r-- | courgette/courgette_tool.cc | 19 | ||||
-rw-r--r-- | courgette/difference_estimator_unittest.cc | 8 | ||||
-rw-r--r-- | courgette/encode_decode_unittest.cc | 2 | ||||
-rw-r--r-- | courgette/encoded_program.cc | 46 | ||||
-rw-r--r-- | courgette/encoded_program.h | 15 | ||||
-rw-r--r-- | courgette/encoded_program_fuzz_unittest.cc | 8 | ||||
-rw-r--r-- | courgette/encoded_program_unittest.cc | 2 | ||||
-rw-r--r-- | courgette/ensemble_apply.cc | 8 | ||||
-rw-r--r-- | courgette/image_info_unittest.cc | 4 | ||||
-rw-r--r-- | courgette/streams.cc | 24 | ||||
-rw-r--r-- | courgette/streams.h | 2 | ||||
-rw-r--r-- | courgette/streams_unittest.cc | 21 | ||||
-rw-r--r-- | courgette/third_party/bsdiff_create.cc | 1 |
18 files changed, 106 insertions, 102 deletions
diff --git a/build/all.gyp b/build/all.gyp index 3ef6f6d..14befd5 100644 --- a/build/all.gyp +++ b/build/all.gyp @@ -53,6 +53,7 @@ '../third_party/harfbuzz/harfbuzz.gyp:*', '../tools/gtk_clipboard_dump/gtk_clipboard_dump.gyp:*', '../tools/xdisplaycheck/xdisplaycheck.gyp:*', + '../courgette/courgette.gyp:*', ], }], ['OS=="win"', { diff --git a/courgette/adjustment_method_2.cc b/courgette/adjustment_method_2.cc index 17868ba..976dfc9 100644 --- a/courgette/adjustment_method_2.cc +++ b/courgette/adjustment_method_2.cc @@ -208,7 +208,7 @@ class LabelInfo { // output. The pair (is_model_, debug_index_) is // unique. - uint32 refs_; // Number of times this Label is referenced. + int refs_; // Number of times this Label is referenced. LabelInfo* assignment_; // Label from other program corresponding to this. @@ -403,10 +403,14 @@ class Shingle { OwningSet* owning_set) { std::pair<OwningSet::iterator, bool> pair = owning_set->insert(Shingle(trace, position)); - // pair.first is the newly inserted Shingle or the previouly inserted one - // that looks the same according to the comparator. - pair.first->add_position(position); - return &*pair.first; + // pair.first iterator 'points' to the newly inserted Shingle or the + // previouly inserted one that looks the same according to the comparator. + + // const_cast required because key is const. We modify the Shingle + // extensively but not in a way that affects InterningLess. + Shingle* shingle = const_cast<Shingle*>(&*pair.first); + shingle->add_position(position); + return shingle; } LabelInfo* at(size_t i) const { return trace_[exemplar_position_ + i]; } @@ -957,7 +961,8 @@ class AssignmentProblem { for (Shingle::OwningSet::iterator p = shingle_instances_.begin(); p != shingle_instances_.end(); ++p) { - Reclassify(&*p); + // GCC's set<T>::iterator::operator *() returns a const object. + Reclassify(const_cast<Shingle*>(&*p)); } } @@ -1035,8 +1040,6 @@ class AssignmentProblem { void AddPatternToLabelQueue(const ShinglePattern* pattern, int sign) { // For each possible assignment in this pattern, update the potential // contributions to the LabelInfo queues. - size_t model_histogram_size = pattern->model_histogram_.size(); - size_t program_histogram_size = pattern->program_histogram_.size(); // We want to find for each symbol (LabelInfo) the maximum contribution that // could be achieved by making shingle-wise assignments between shingles in @@ -1053,7 +1056,7 @@ class AssignmentProblem { // assignments are blocked by previous incompatible assignments. We want to // avoid a combinatorial search, so we ignore the blocking. - const int kUnwieldy = 5; + const size_t kUnwieldy = 5; typedef std::map<LabelInfo*, int> LabelToScore; typedef std::map<LabelInfo*, LabelToScore > ScoreSet; diff --git a/courgette/assembly_program.cc b/courgette/assembly_program.cc index e40f38f..a0575a1 100644 --- a/courgette/assembly_program.cc +++ b/courgette/assembly_program.cc @@ -85,8 +85,8 @@ class InstructionWithLabel : public Instruction { } // namespace AssemblyProgram::AssemblyProgram() - : image_base_(0), - byte_instruction_cache_(NULL) { + : byte_instruction_cache_(NULL), + image_base_(0) { } static void DeleteContainedLabels(const RVAToLabel& labels) { @@ -209,9 +209,9 @@ void AssemblyProgram::AssignRemainingIndexes(RVAToLabel* labels) { int used = 0; for (RVAToLabel::iterator p = labels->begin(); p != labels->end(); ++p) { - size_t index = p->second->index_; + int index = p->second->index_; if (index != Label::kNoIndex) { - while (index >= available.size()) + while (static_cast<size_t>(index) >= available.size()) available.push_back(true); available.at(index) = false; ++used; @@ -244,7 +244,6 @@ void AssemblyProgram::AssignRemainingIndexes(RVAToLabel* labels) { // label? // int fill_backward_count = 0; - int backward_refs = 0; prev = 0; for (RVAToLabel::reverse_iterator p = labels->rbegin(); p != labels->rend(); diff --git a/courgette/courgette.h b/courgette/courgette.h index 7375c10..521053e 100644 --- a/courgette/courgette.h +++ b/courgette/courgette.h @@ -5,6 +5,10 @@ #ifndef COURGETTE_COURGETTE_H_ #define COURGETTE_COURGETTE_H_ +#include <stddef.h> // Required to define size_t on GCC + +#include "base/file_path.h" + namespace courgette { // Status codes for Courgette APIs. @@ -44,8 +48,6 @@ enum Status { C_DISASSEMBLY_FAILED = 25, // C_ASSEMBLY_FAILED = 26, // C_ADJUSTMENT_FAILED = 27, // - - }; class SinkStream; @@ -67,9 +69,10 @@ Status ApplyEnsemblePatch(SourceStream* old, SourceStream* patch, // Returns C_OK unless something went wrong. // This function first validates that the patch file has a proper header, so the // function can be used to 'try' a patch. -Status ApplyEnsemblePatch(const wchar_t* old_file_name, - const wchar_t* patch_file_name, - const wchar_t* new_file_name); + +Status ApplyEnsemblePatch(const FilePath::CharType* old_file_name, + const FilePath::CharType* patch_file_name, + const FilePath::CharType* new_file_name); // Generates a patch that will transform the bytes in |old| into the bytes in // |target|. diff --git a/courgette/courgette_minimal_tool.cc b/courgette/courgette_minimal_tool.cc index 84de068..2f99ca9 100644 --- a/courgette/courgette_minimal_tool.cc +++ b/courgette/courgette_minimal_tool.cc @@ -33,7 +33,11 @@ void Problem(const char* message) { exit(1); } +#if defined(OS_WIN) int wmain(int argc, const wchar_t* argv[]) { +#else +int main(int argc, const char* argv[]) { +#endif if (argc != 4) UsageProblem("bad args"); diff --git a/courgette/courgette_tool.cc b/courgette/courgette_tool.cc index 96a5af4..47b2dc6 100644 --- a/courgette/courgette_tool.cc +++ b/courgette/courgette_tool.cc @@ -45,7 +45,11 @@ void Problem(const char* format, ...) { } std::string ReadOrFail(const std::wstring& file_name, const char* kind) { +#if defined(OS_WIN) FilePath file_path(file_name); +#else + FilePath file_path(WideToASCII(file_name)); +#endif std::string buffer; if (!file_util::ReadFileToString(file_path, &buffer)) Problem("Can't read %s file.", kind); @@ -54,14 +58,18 @@ std::string ReadOrFail(const std::wstring& file_name, const char* kind) { void WriteSinkToFile(const courgette::SinkStream *sink, const std::wstring& output_file) { +#if defined(OS_WIN) FilePath output_path(output_file); +#else + FilePath output_path(WideToASCII(output_file)); +#endif int count = file_util::WriteFile(output_path, reinterpret_cast<const char*>(sink->Buffer()), sink->Length()); if (count == -1) - Problem("Cant write output."); - if (count != sink->Length()) + Problem("Can't write output."); + if (static_cast<size_t>(count) != sink->Length()) Problem("Incomplete write."); } @@ -330,6 +338,11 @@ void ApplyBSDiffPatch(const std::wstring& old_file, WriteSinkToFile(&new_stream, new_file); } +bool WideStringToInt(const std::wstring& str, int *output) { + string16 copy(str.begin(), str.end()); + return StringToInt(copy, output); +} + int main(int argc, const char* argv[]) { base::AtExitManager at_exit_manager; CommandLine::Init(argc, argv); @@ -352,7 +365,7 @@ int main(int argc, const char* argv[]) { int repeat_count = 1; std::wstring repeat_switch = command_line.GetSwitchValue(L"repeat"); if (!repeat_switch.empty()) - if (!StringToInt(repeat_switch, &repeat_count)) + if (!WideStringToInt(repeat_switch, &repeat_count)) repeat_count = 1; if (cmd_dis + cmd_asm + cmd_disadj + cmd_make_patch + cmd_apply_patch + diff --git a/courgette/difference_estimator_unittest.cc b/courgette/difference_estimator_unittest.cc index 913752b..3932e04 100644 --- a/courgette/difference_estimator_unittest.cc +++ b/courgette/difference_estimator_unittest.cc @@ -21,7 +21,7 @@ TEST(DifferenceEstimatorTest, TestSame) { difference_estimator.MakeBase(Region(kString1, sizeof(kString1))); DifferenceEstimator::Subject* subject = difference_estimator.MakeSubject(Region(kString2, sizeof(kString2))); - EXPECT_EQ(0, difference_estimator.Measure(base, subject)); + EXPECT_EQ(0U, difference_estimator.Measure(base, subject)); } TEST(DifferenceEstimatorTest, TestDifferent) { @@ -32,7 +32,7 @@ TEST(DifferenceEstimatorTest, TestDifferent) { difference_estimator.MakeBase(Region(kString1, sizeof(kString1))); DifferenceEstimator::Subject* subject = difference_estimator.MakeSubject(Region(kString2, sizeof(kString2))); - EXPECT_EQ(10, difference_estimator.Measure(base, subject)); + EXPECT_EQ(10U, difference_estimator.Measure(base, subject)); } TEST(DifferenceEstimatorTest, TestDifferentSuperstring) { @@ -43,7 +43,7 @@ TEST(DifferenceEstimatorTest, TestDifferentSuperstring) { difference_estimator.MakeBase(Region(kString1, sizeof(kString1)-1)); DifferenceEstimator::Subject* subject = difference_estimator.MakeSubject(Region(kString2, sizeof(kString2)-1)); - EXPECT_EQ(1, difference_estimator.Measure(base, subject)); + EXPECT_EQ(1U, difference_estimator.Measure(base, subject)); } TEST(DifferenceEstimatorTest, TestDifferentSubstring) { @@ -54,5 +54,5 @@ TEST(DifferenceEstimatorTest, TestDifferentSubstring) { difference_estimator.MakeBase(Region(kString1, sizeof(kString1)-1)); DifferenceEstimator::Subject* subject = difference_estimator.MakeSubject(Region(kString2, sizeof(kString2)-1)); - EXPECT_EQ(1, difference_estimator.Measure(base, subject)); + EXPECT_EQ(1U, difference_estimator.Measure(base, subject)); } diff --git a/courgette/encode_decode_unittest.cc b/courgette/encode_decode_unittest.cc index 436479d8..3246f3c 100644 --- a/courgette/encode_decode_unittest.cc +++ b/courgette/encode_decode_unittest.cc @@ -76,7 +76,7 @@ void EncodeDecodeTest::TestExe(const char* file_name) const { const void* buffer = sink.Buffer(); size_t length = sink.Length(); - EXPECT_EQ(971850, length); + EXPECT_EQ(971850U, length); courgette::SourceStreamSet sources; bool can_get_source_streams = sources.Init(buffer, length); diff --git a/courgette/encoded_program.cc b/courgette/encoded_program.cc index f606f96..98d70c9 100644 --- a/courgette/encoded_program.cc +++ b/courgette/encoded_program.cc @@ -30,20 +30,6 @@ const int kStreamOriginAddresses = kStreamMisc; const int kStreamLimit = 9; -// Binary assembly language operations. -enum EncodedProgram::OP { - ORIGIN, // ORIGIN <rva> - set address for subsequent assembly. - COPY, // COPY <count> <bytes> - copy bytes to output. - COPY1, // COPY1 <byte> - same as COPY 1 <byte>. - REL32, // REL32 <index> - emit rel32 encoded reference to address at - // address table offset <index> - ABS32, // ABS32 <index> - emit abs32 encoded reference to address at - // address table offset <index> - MAKE_BASE_RELOCATION_TABLE, // Emit base relocation table blocks. - OP_LAST -}; - - // Constructor is here rather than in the header. Although the constructor // appears to do nothing it is fact quite large because of the implict calls to // field constructors. Ditto for the destructor. @@ -499,32 +485,38 @@ bool EncodedProgram::AssembleTo(SinkStream* final_buffer) { // RelocBlock has the layout of a block of relocations in the base relocation // table file format. // -class RelocBlock { - public: +struct RelocBlockPOD { uint32 page_rva; uint32 block_size; uint16 relocs[4096]; // Allow up to one relocation per byte of a 4k page. +}; - RelocBlock() : page_rva(~0), block_size(8) {} +COMPILE_ASSERT(offsetof(RelocBlockPOD, relocs) == 8, reloc_block_header_size); + +class RelocBlock { + public: + RelocBlock() { + pod.page_rva = ~0; + pod.block_size = 8; + } void Add(uint16 item) { - relocs[(block_size-8)/2] = item; - block_size += 2; + pod.relocs[(pod.block_size-8)/2] = item; + pod.block_size += 2; } void Flush(SinkStream* buffer) { - if (block_size != 8) { - if (block_size % 4 != 0) { // Pad to make size multiple of 4 bytes. + if (pod.block_size != 8) { + if (pod.block_size % 4 != 0) { // Pad to make size multiple of 4 bytes. Add(0); } - buffer->Write(this, block_size); - block_size = 8; + buffer->Write(&pod, pod.block_size); + pod.block_size = 8; } } + RelocBlockPOD pod; }; -COMPILE_ASSERT(offsetof(RelocBlock, relocs) == 8, reloc_block_header_size); - void EncodedProgram::GenerateBaseRelocations(SinkStream* buffer) { std::sort(abs32_relocs_.begin(), abs32_relocs_.end()); @@ -533,9 +525,9 @@ void EncodedProgram::GenerateBaseRelocations(SinkStream* buffer) { for (size_t i = 0; i < abs32_relocs_.size(); ++i) { uint32 rva = abs32_relocs_[i]; uint32 page_rva = rva & ~0xFFF; - if (page_rva != block.page_rva) { + if (page_rva != block.pod.page_rva) { block.Flush(buffer); - block.page_rva = page_rva; + block.pod.page_rva = page_rva; } block.Add(0x3000 | (rva & 0xFFF)); } diff --git a/courgette/encoded_program.h b/courgette/encoded_program.h index df1119c..25bc075 100644 --- a/courgette/encoded_program.h +++ b/courgette/encoded_program.h @@ -54,7 +54,18 @@ class EncodedProgram { bool AssembleTo(SinkStream *buffer); private: - enum OP; // Binary assembly language operations. + // Binary assembly language operations. + enum OP { + ORIGIN, // ORIGIN <rva> - set address for subsequent assembly. + COPY, // COPY <count> <bytes> - copy bytes to output. + COPY1, // COPY1 <byte> - same as COPY 1 <byte>. + REL32, // REL32 <index> - emit rel32 encoded reference to address at + // address table offset <index> + ABS32, // ABS32 <index> - emit abs32 encoded reference to address at + // address table offset <index> + MAKE_BASE_RELOCATION_TABLE, // Emit base relocation table blocks. + OP_LAST + }; void DebuggingSummary(); void GenerateBaseRelocations(SinkStream *buffer); @@ -80,4 +91,4 @@ class EncodedProgram { }; } // namespace courgette -#endif // COURGETTE_ENCODED_FORMAT_H_ +#endif // COURGETTE_ENCODED_PROGRAM_H_ diff --git a/courgette/encoded_program_fuzz_unittest.cc b/courgette/encoded_program_fuzz_unittest.cc index adc09d9..aa82919 100644 --- a/courgette/encoded_program_fuzz_unittest.cc +++ b/courgette/encoded_program_fuzz_unittest.cc @@ -30,8 +30,8 @@ class DecodeFuzzTest : public testing::Test { private: virtual void SetUp() { PathService::Get(base::DIR_SOURCE_ROOT, &testdata_dir_); - testdata_dir_ = testdata_dir_.Append(L"courgette"); - testdata_dir_ = testdata_dir_.Append(L"testdata"); + testdata_dir_ = testdata_dir_.AppendASCII("courgette"); + testdata_dir_ = testdata_dir_.AppendASCII("testdata"); } virtual void TearDown() { } @@ -188,10 +188,10 @@ void DecodeFuzzTest::FuzzBits(const std::string& base_buffer, } if (index > 60) { // Beyond the origin addresses ... - EXPECT_NE(0, changed_byte_count); // ... we expect some difference. + EXPECT_NE(0U, changed_byte_count); // ... we expect some difference. } // Currently all changes are smaller than this number: - EXPECT_GE(45000u, changed_byte_count); + EXPECT_GE(45000U, changed_byte_count); } } diff --git a/courgette/encoded_program_unittest.cc b/courgette/encoded_program_unittest.cc index aedb838..fb3fd17 100644 --- a/courgette/encoded_program_unittest.cc +++ b/courgette/encoded_program_unittest.cc @@ -53,7 +53,7 @@ TEST(EncodedProgramTest, Test) { const void* assembled_buffer = assembled.Buffer(); size_t assembled_length = assembled.Length(); - EXPECT_EQ(8, assembled_length); + EXPECT_EQ(8U, assembled_length); static const uint8 golden[] = { 0x04, 0x00, 0x90, 0x00, // ABS32 to base + 4 diff --git a/courgette/ensemble_apply.cc b/courgette/ensemble_apply.cc index 5a9edfd4..7ab6ff1 100644 --- a/courgette/ensemble_apply.cc +++ b/courgette/ensemble_apply.cc @@ -351,9 +351,9 @@ Status ApplyEnsemblePatch(SourceStream* base, return C_OK; } -Status ApplyEnsemblePatch(const wchar_t* old_file_name, - const wchar_t* patch_file_name, - const wchar_t* new_file_name) { +Status ApplyEnsemblePatch(const FilePath::CharType* old_file_name, + const FilePath::CharType* patch_file_name, + const FilePath::CharType* new_file_name) { Status status; // First read enough of the patch file to validate the header is well-formed. @@ -403,7 +403,7 @@ Status ApplyEnsemblePatch(const wchar_t* old_file_name, new_sink_stream.Length()); if (written == -1) return C_WRITE_OPEN_ERROR; - if (written != new_sink_stream.Length()) + if (static_cast<size_t>(written) != new_sink_stream.Length()) return C_WRITE_ERROR; return C_OK; diff --git a/courgette/image_info_unittest.cc b/courgette/image_info_unittest.cc index bf0ca6e..377b95b 100644 --- a/courgette/image_info_unittest.cc +++ b/courgette/image_info_unittest.cc @@ -64,7 +64,7 @@ void ImageInfoTest::TestExe() const { EXPECT_EQ(file1.length(), info->length()); ExpectExecutable(info.get()); - EXPECT_EQ(449536, info->size_of_code()); + EXPECT_EQ(449536U, info->size_of_code()); EXPECT_EQ(SectionName(info->RVAToSection(0x00401234 - 0x00400000)), std::string(".text")); @@ -97,7 +97,7 @@ void ImageInfoTest::TestResourceDll() const { EXPECT_TRUE(info->ok()); EXPECT_FALSE(info->has_text_section()); - EXPECT_EQ(0u, info->size_of_code()); + EXPECT_EQ(0U, info->size_of_code()); } TEST_F(ImageInfoTest, All) { diff --git a/courgette/streams.cc b/courgette/streams.cc index 365a416..fec16fa 100644 --- a/courgette/streams.cc +++ b/courgette/streams.cc @@ -18,7 +18,6 @@ #include "courgette/streams.h" -#include <io.h> #include <memory.h> #include "base/basictypes.h" @@ -255,7 +254,7 @@ bool SourceStreamSet::Init(const void* source, size_t byte_count) { } // Remaining bytes should add up to sum of lengths. - if (end - finger != accumulated_length) + if (static_cast<size_t>(end - finger) != accumulated_length) return false; accumulated_length = finger - start; @@ -335,27 +334,6 @@ bool SinkStreamSet::CopyTo(SinkStream *combined_stream) { return true; } -namespace { -bool Write(int file_descriptor, SinkStream* sink) { - size_t length = sink->Length(); - const void *buffer = sink->Buffer(); - int bytes_written = _write(file_descriptor, buffer, length); - return bytes_written == length; -} -} - -bool SinkStreamSet::CopyToFileDescriptor(int file_descriptor) { - SinkStream header; - CopyHeaderTo(&header); - if (!Write(file_descriptor, &header)) - return false; - for (size_t i = 0; i < count_; ++i) { - if (!Write(file_descriptor, stream(i))) - return false; - } - return true; -} - bool SinkStreamSet::WriteSet(SinkStreamSet* set) { uint32 lengths[kMaxStreams]; // 'stream_count' includes all non-empty streams and all empty stream numbered diff --git a/courgette/streams.h b/courgette/streams.h index 2fb824f..3309571 100644 --- a/courgette/streams.h +++ b/courgette/streams.h @@ -199,8 +199,6 @@ class SinkStreamSet { // stream or file. The serialized format may be re-read by initializing a // SourceStreamSet with a buffer containing the data. bool CopyTo(SinkStream* combined_stream); - bool CopyToFile(FILE* file); - bool CopyToFileDescriptor(int file_descriptor); // Writes the streams of |set| into the corresponding streams of |this|. // Stream zero first has some metadata written to it. |set| becomes retired. diff --git a/courgette/streams_unittest.cc b/courgette/streams_unittest.cc index dd330ce..63393a3 100644 --- a/courgette/streams_unittest.cc +++ b/courgette/streams_unittest.cc @@ -4,6 +4,8 @@ #include "courgette/streams.h" +#include <vector> + #include "testing/gtest/include/gtest/gtest.h" TEST(StreamsTest, SimpleWriteRead) { @@ -22,7 +24,7 @@ TEST(StreamsTest, SimpleWriteRead) { bool can_read = source.ReadVarint32(&value); EXPECT_EQ(true, can_read); EXPECT_EQ(kValue1, value); - EXPECT_EQ(0, source.Remaining()); + EXPECT_EQ(0U, source.Remaining()); } TEST(StreamsTest, SimpleWriteRead2) { @@ -40,7 +42,7 @@ TEST(StreamsTest, SimpleWriteRead2) { bool can_read = source.Read(text, 5); EXPECT_EQ(true, can_read); EXPECT_EQ(0, memcmp("Hello", text, 5)); - EXPECT_EQ(0, source.Remaining()); + EXPECT_EQ(0U, source.Remaining()); } TEST(StreamsTest, StreamSetWriteRead) { @@ -66,8 +68,8 @@ TEST(StreamsTest, StreamSetWriteRead) { bool can_read = in.stream(3)->ReadVarint32(&value); EXPECT_EQ(true, can_read); EXPECT_EQ(kValue1, value); - EXPECT_EQ(0, in.stream(3)->Remaining()); - EXPECT_EQ(0, in.stream(2)->Remaining()); + EXPECT_EQ(0U, in.stream(3)->Remaining()); + EXPECT_EQ(0U, in.stream(2)->Remaining()); } TEST(StreamsTest, StreamSetWriteRead2) { @@ -109,7 +111,7 @@ TEST(StreamsTest, StreamSetWriteRead2) { } for (size_t i = 0; i < kNumberOfStreams; ++i) { - EXPECT_EQ(0, in.stream(i)->Remaining()); + EXPECT_EQ(0U, in.stream(i)->Remaining()); } } @@ -141,6 +143,7 @@ TEST(StreamsTest, SignedVarint32) { int written_value = values[i]; int32 datum; bool can_read = in.ReadVarint32Signed(&datum); + EXPECT_EQ(true, can_read); EXPECT_EQ(written_value, datum); } @@ -187,14 +190,14 @@ TEST(StreamsTest, StreamSetReadWrite) { uint32 datum; EXPECT_EQ(true, subset1.stream(3)->ReadVarint32(&datum)); - EXPECT_EQ(30000, datum); + EXPECT_EQ(30000U, datum); EXPECT_EQ(true, subset1.stream(5)->ReadVarint32(&datum)); - EXPECT_EQ(50000, datum); + EXPECT_EQ(50000U, datum); EXPECT_EQ(true, subset1.Empty()); EXPECT_EQ(true, subset2.stream(2)->ReadVarint32(&datum)); - EXPECT_EQ(20000, datum); + EXPECT_EQ(20000U, datum); EXPECT_EQ(true, subset2.stream(6)->ReadVarint32(&datum)); - EXPECT_EQ(60000, datum); + EXPECT_EQ(60000U, datum); EXPECT_EQ(true, subset2.Empty()); } diff --git a/courgette/third_party/bsdiff_create.cc b/courgette/third_party/bsdiff_create.cc index 0212093..fc0ce25 100644 --- a/courgette/third_party/bsdiff_create.cc +++ b/courgette/third_party/bsdiff_create.cc @@ -232,7 +232,6 @@ BSDiffStatus CreateBinaryPatch(SourceStream* old_stream, int diff_bytes_length = 0; int diff_bytes_nonzero = 0; int extra_bytes_length = 0; - int eblen = 0; // The patch format is a sequence of triples <copy,extra,seek> where 'copy' is // the number of bytes to copy from the old file (possibly with mistakes), |