From 09175df729ebf3ee0cf79bb01577744674dd24c2 Mon Sep 17 00:00:00 2001 From: "maf@google.com" Date: Thu, 6 Aug 2009 04:09:16 +0000 Subject: Lots of changes required to build on GCC in full paranoia mode with no warnings generated. Review URL: http://codereview.chromium.org/165013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22581 0039d316-1c4b-4281-b951-d872f2087c98 --- o3d/import/cross/gz_compressor_test.cc | 2 +- o3d/import/cross/gz_decompressor_test.cc | 4 +-- o3d/import/cross/memory_buffer_test.cc | 6 ++-- o3d/import/cross/memory_stream_test.cc | 34 +++++++++++++--------- o3d/import/cross/raw_data_test.cc | 2 +- o3d/import/cross/tar_generator.cc | 2 +- o3d/import/cross/tar_generator_test.cc | 4 +-- o3d/import/cross/tar_processor_test.cc | 4 +-- o3d/import/cross/targz_generator_test.cc | 2 +- o3d/import/cross/threaded_stream_processor_test.cc | 4 +-- 10 files changed, 35 insertions(+), 29 deletions(-) (limited to 'o3d/import') diff --git a/o3d/import/cross/gz_compressor_test.cc b/o3d/import/cross/gz_compressor_test.cc index 4cebb004..cd39499 100644 --- a/o3d/import/cross/gz_compressor_test.cc +++ b/o3d/import/cross/gz_compressor_test.cc @@ -80,7 +80,7 @@ class DecompressorClient : public o3d::StreamProcessor { void VerifyDecompressedOutput(uint8 *original_data) { // Make sure we filled up the output buffer - EXPECT_EQ(0, write_stream_.GetRemainingByteCount()); + EXPECT_EQ(0U, write_stream_.GetRemainingByteCount()); // Verify decompressed data with the original data we fed into the // compressor diff --git a/o3d/import/cross/gz_decompressor_test.cc b/o3d/import/cross/gz_decompressor_test.cc index 4bb71d6..ec79ad9 100644 --- a/o3d/import/cross/gz_decompressor_test.cc +++ b/o3d/import/cross/gz_decompressor_test.cc @@ -124,11 +124,11 @@ TEST_F(GzDecompressorTest, LoadGzFile) { const int kChunkSize = 512; MemoryReadStream compressed_stream(compressed_data, compressed_size); - size_t bytes_to_process = compressed_size; + int bytes_to_process = compressed_size; StreamProcessor::Status status = StreamProcessor::SUCCESS; while (bytes_to_process > 0) { - size_t bytes_this_time = + int bytes_this_time = bytes_to_process < kChunkSize ? bytes_to_process : kChunkSize; status = decompressor.ProcessBytes(&compressed_stream, bytes_this_time); diff --git a/o3d/import/cross/memory_buffer_test.cc b/o3d/import/cross/memory_buffer_test.cc index 59cb721..47797bb 100644 --- a/o3d/import/cross/memory_buffer_test.cc +++ b/o3d/import/cross/memory_buffer_test.cc @@ -48,12 +48,12 @@ TEST_F(MemoryBufferTest, Basic) { int i; MemoryBuffer buffer; // Check that initially the buffer is not allocated - ASSERT_EQ(0, buffer.GetLength()); + ASSERT_EQ(0U, buffer.GetLength()); // Allocate and check the length is good const int kBufferLength = 1024; buffer.Allocate(kBufferLength); - ASSERT_EQ(kBufferLength, buffer.GetLength()); + ASSERT_EQ(kBufferLength, static_cast(buffer.GetLength())); // Once allocated, the initial contents should be zero // Check that the buffer contents are zeroed out @@ -92,7 +92,7 @@ TEST_F(MemoryBufferTest, Basic) { // Deallocate the buffer and verify its length buffer.Deallocate(); - ASSERT_EQ(0, buffer.GetLength()); + ASSERT_EQ(0U, buffer.GetLength()); } } // namespace o3d diff --git a/o3d/import/cross/memory_stream_test.cc b/o3d/import/cross/memory_stream_test.cc index 77ae95c..f72d7f0 100644 --- a/o3d/import/cross/memory_stream_test.cc +++ b/o3d/import/cross/memory_stream_test.cc @@ -46,8 +46,9 @@ namespace o3d { -static char *kTestString = - "Tests functionality of the MemoryReadStream and MemoryWriteStream classes"; +static char *kTestString = const_cast + ("Tests functionality of the MemoryReadStream and MemoryWriteStream classes"); + // Test fixture for MemoryReadStream and MemoryWriteStream. class MemoryStreamTest : public testing::Test { @@ -70,7 +71,8 @@ TEST_F(MemoryStreamTest, Read) { MemoryReadStream read_stream(buffer, buffer.GetLength()); EXPECT_EQ(buffer.GetLength(), read_stream.GetTotalStreamLength()); - EXPECT_EQ(kStringLength, read_stream.GetTotalStreamLength()); + EXPECT_EQ(kStringLength, + static_cast(read_stream.GetTotalStreamLength())); // Read one byte at a time and verify uint8 c; @@ -96,8 +98,9 @@ TEST_F(MemoryStreamTest, Read) { // Verify bytes read, stream position and remaining byte count EXPECT_EQ(5, bytes_read); - EXPECT_EQ(5, read_stream2.GetStreamPosition()); - EXPECT_EQ(kStringLength - 5, read_stream2.GetRemainingByteCount()); + EXPECT_EQ(5U, read_stream2.GetStreamPosition()); + EXPECT_EQ(kStringLength - 5, + static_cast(read_stream2.GetRemainingByteCount())); // Next read the remaining bytes bytes_read = read_stream2.Read(read_buffer + 5, kStringLength - 5); @@ -131,7 +134,7 @@ TEST_F(MemoryStreamTest, Write) { MemoryWriteStream empty_stream; // Verfify length is zero - EXPECT_EQ(0, empty_stream.GetTotalStreamLength()); + EXPECT_EQ(0U, empty_stream.GetTotalStreamLength()); // Now, assign it to the string (OK, we can't really write to // this memory, but we're just checking the API here @@ -139,27 +142,30 @@ TEST_F(MemoryStreamTest, Write) { empty_stream.Assign(reinterpret_cast(kTestString), kStringLength); // Sanity check on length, position, remaining - EXPECT_EQ(kStringLength, empty_stream.GetTotalStreamLength()); - EXPECT_EQ(0, empty_stream.GetStreamPosition()); - EXPECT_EQ(kStringLength, empty_stream.GetRemainingByteCount()); + EXPECT_EQ(kStringLength, + static_cast(empty_stream.GetTotalStreamLength())); + EXPECT_EQ(0U, empty_stream.GetStreamPosition()); + EXPECT_EQ(kStringLength, + static_cast(empty_stream.GetRemainingByteCount())); // Create a write stream on a buffer we can write to MemoryBuffer buffer(kStringLength); MemoryWriteStream write_stream(buffer, buffer.GetLength()); - EXPECT_EQ(buffer.GetLength(), kStringLength); + EXPECT_EQ(static_cast(buffer.GetLength()), kStringLength); // Write 5 bytes uint8 *p = reinterpret_cast(kTestString); int bytes_written = write_stream.Write(p, 5); EXPECT_EQ(5, bytes_written); - EXPECT_EQ(5, write_stream.GetStreamPosition()); - EXPECT_EQ(kStringLength - 5, write_stream.GetRemainingByteCount()); + EXPECT_EQ(5U, write_stream.GetStreamPosition()); + EXPECT_EQ(kStringLength - 5, + static_cast(write_stream.GetRemainingByteCount())); // Write the remaining bytes in the string bytes_written = write_stream.Write(p + 5, kStringLength - 5); EXPECT_EQ(kStringLength - 5, bytes_written); - EXPECT_EQ(kStringLength, write_stream.GetStreamPosition()); - EXPECT_EQ(0, write_stream.GetRemainingByteCount()); + EXPECT_EQ(kStringLength, static_cast(write_stream.GetStreamPosition())); + EXPECT_EQ(0U, write_stream.GetRemainingByteCount()); // Verify we wrote the correct data EXPECT_EQ(0, memcmp(buffer, kTestString, kStringLength)); diff --git a/o3d/import/cross/raw_data_test.cc b/o3d/import/cross/raw_data_test.cc index 4ab0955..4399cd9 100644 --- a/o3d/import/cross/raw_data_test.cc +++ b/o3d/import/cross/raw_data_test.cc @@ -118,7 +118,7 @@ TEST_F(RawDataTest, CreateFromFile) { size_t file_length = static_cast(file_size64); ASSERT_TRUE(file_length > 0); scoped_array data(new uint8[file_length]); - ASSERT_EQ(fread(data.get(), file_length, 1, file), 1); + ASSERT_EQ(fread(data.get(), file_length, 1, file), 1U); CloseFile(file); ASSERT_EQ(file_length, ref->GetLength()); diff --git a/o3d/import/cross/tar_generator.cc b/o3d/import/cross/tar_generator.cc index cbfab24..6c21ac0 100644 --- a/o3d/import/cross/tar_generator.cc +++ b/o3d/import/cross/tar_generator.cc @@ -158,7 +158,7 @@ bool TarGenerator::AddEntry(const String &file_name, bool is_directory) { // If filename is longer 99 chars, use the GNU format to write out a longer // filename. - if (file_name.size() >= kMaxFilenameSizeOldFormat) { + if (file_name.size() >= static_cast(kMaxFilenameSizeOldFormat)) { WriteHeader(kLongLink, file_name.size(), 'L', diff --git a/o3d/import/cross/tar_generator_test.cc b/o3d/import/cross/tar_generator_test.cc index 0e6dccb..5fdec8a 100644 --- a/o3d/import/cross/tar_generator_test.cc +++ b/o3d/import/cross/tar_generator_test.cc @@ -335,7 +335,7 @@ void CallbackClient::ValidateHeader(uint8 *header, // Validate length int length_in_header; sscanf((const char*)header + kFileSizeOffset, "%o", &length_in_header); - EXPECT_EQ(file_length, length_in_header); + EXPECT_EQ(file_length, static_cast(length_in_header)); EXPECT_EQ(0, header[kMaxFilenameSize - 1]); @@ -425,7 +425,7 @@ TEST_F(TarGeneratorTest, CreateSimpleArchive) { // Verify that the tar byte stream produced is exactly divisible by // the block size size_t bytes_received = client.GetTotalBytesReceived(); - EXPECT_EQ(0, bytes_received % kBlockSize); + EXPECT_EQ(0U, bytes_received % kBlockSize); // Make sure the state machine is in the expected state EXPECT_EQ(CallbackClient::FINISHED, client.GetState()); diff --git a/o3d/import/cross/tar_processor_test.cc b/o3d/import/cross/tar_processor_test.cc index 77a2522..2e1f0bd 100644 --- a/o3d/import/cross/tar_processor_test.cc +++ b/o3d/import/cross/tar_processor_test.cc @@ -155,10 +155,10 @@ TEST_F(TarProcessorTest, LoadTarFile) { const int kChunkSize = 32; MemoryReadStream tar_stream(tar_data, file_size); - size_t bytes_to_process = file_size; + int bytes_to_process = file_size; while (bytes_to_process > 0) { - size_t bytes_this_time = + int bytes_this_time = bytes_to_process < kChunkSize ? bytes_to_process : kChunkSize; StreamProcessor::Status status = tar_processor.ProcessBytes( diff --git a/o3d/import/cross/targz_generator_test.cc b/o3d/import/cross/targz_generator_test.cc index 2e1cf7b..7911387 100644 --- a/o3d/import/cross/targz_generator_test.cc +++ b/o3d/import/cross/targz_generator_test.cc @@ -145,7 +145,7 @@ TEST_F(TarGzGeneratorTest, GenerateTarGz) { ASSERT_TRUE(audio_data != NULL); ASSERT_TRUE(shader_data != NULL); - ASSERT_NE(0, targz_reference_size); + ASSERT_NE(0U, targz_reference_size); TarGzTestClient test_client(targz_reference_size); TarGzGenerator targz_generator(&test_client); diff --git a/o3d/import/cross/threaded_stream_processor_test.cc b/o3d/import/cross/threaded_stream_processor_test.cc index 44698ad3..0a4530f 100644 --- a/o3d/import/cross/threaded_stream_processor_test.cc +++ b/o3d/import/cross/threaded_stream_processor_test.cc @@ -89,7 +89,7 @@ TEST_F(ThreadedStreamProcessorTest, CanForwardZeroBuffers) { processor.Close(true); processor.StopThread(); - EXPECT_EQ(0, receiver.GetResultLength()); + EXPECT_EQ(0U, receiver.GetResultLength()); EXPECT_TRUE(receiver.closed()); EXPECT_TRUE(receiver.success()); } @@ -104,7 +104,7 @@ TEST_F(ThreadedStreamProcessorTest, CanForwardOneBufferOfZeroBytes) { processor.Close(true); processor.StopThread(); - EXPECT_EQ(0, receiver.GetResultLength()); + EXPECT_EQ(0U, receiver.GetResultLength()); EXPECT_TRUE(receiver.closed()); EXPECT_TRUE(receiver.success()); } -- cgit v1.1