diff options
author | gspencer@google.com <gspencer@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-21 23:33:17 +0000 |
---|---|---|
committer | gspencer@google.com <gspencer@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-21 23:33:17 +0000 |
commit | 1b2bfdd574d9c4e21251ec2214e41d8905da4541 (patch) | |
tree | 125a1781c38b840effa24926a16f9599c0631281 /o3d/import | |
parent | c7cc3f559ecc96849168432c7d3abcca4eeebb4f (diff) | |
download | chromium_src-1b2bfdd574d9c4e21251ec2214e41d8905da4541.zip chromium_src-1b2bfdd574d9c4e21251ec2214e41d8905da4541.tar.gz chromium_src-1b2bfdd574d9c4e21251ec2214e41d8905da4541.tar.bz2 |
This fixes a number of things that are warnings in the Mac compiler.
It fixes at least two real bugs, one in the tar generator, and one
in stream_bank.h.
Review URL: http://codereview.chromium.org/159168
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21227 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/import')
-rw-r--r-- | o3d/import/cross/collada.cc | 17 | ||||
-rw-r--r-- | o3d/import/cross/collada.h | 2 | ||||
-rw-r--r-- | o3d/import/cross/collada_conditioner.cc | 38 | ||||
-rw-r--r-- | o3d/import/cross/gz_compressor.cc | 4 | ||||
-rw-r--r-- | o3d/import/cross/memory_stream.h | 12 | ||||
-rw-r--r-- | o3d/import/cross/raw_data.cc | 2 | ||||
-rw-r--r-- | o3d/import/cross/tar_generator.cc | 5 | ||||
-rw-r--r-- | o3d/import/cross/tar_processor.cc | 2 | ||||
-rw-r--r-- | o3d/import/cross/targz_generator_test.cc | 22 | ||||
-rw-r--r-- | o3d/import/cross/zip_archive.cc | 2 | ||||
-rw-r--r-- | o3d/import/mac/collada_conditioner_mac.mm | 2 |
11 files changed, 63 insertions, 45 deletions
diff --git a/o3d/import/cross/collada.cc b/o3d/import/cross/collada.cc index c9a6537a..fa06c70 100644 --- a/o3d/import/cross/collada.cc +++ b/o3d/import/cross/collada.cc @@ -165,10 +165,10 @@ Collada::Collada(Pack* pack, const Options& options) dummy_effect_(NULL), dummy_material_(NULL), instance_root_(NULL), + collada_zip_archive_(NULL), cull_enabled_(false), cull_front_(false), front_cw_(false), - collada_zip_archive_(NULL), unique_filename_counter_(0) { } @@ -508,7 +508,7 @@ bool Collada::BuildFloatAnimation(ParamFloat* result, curve->set_pre_infinity(ConvertInfinity(fcd_curve->GetPreInfinity())); curve->set_post_infinity(ConvertInfinity(fcd_curve->GetPostInfinity())); - for (int i = 0; i != fcd_curve->GetKeyCount(); ++i) { + for (unsigned int i = 0; i != fcd_curve->GetKeyCount(); ++i) { FCDAnimationKey* fcd_key = fcd_curve->GetKey(i); switch (fcd_key->interpolation) { case FUDaeInterpolation::STEP: @@ -1512,6 +1512,9 @@ Shape* Collada::BuildSkinnedShape(FCDocument* doc, return NULL; } } + default: + // do nothing + break; } } if (!copied) { @@ -1600,6 +1603,9 @@ Shape* Collada::BuildSkinnedShape(FCDocument* doc, source_stream.semantic_index()); break; } + default: + // do nothing + break; } } if (!copied) { @@ -2414,6 +2420,9 @@ void Collada::AddRenderState(FCDEffectPassState* pass_state, State* state) { << "FRONT_AND_BACK culling is unsupported"; break; } + case FUDaePassStateFaceType::INVALID: + O3D_ERROR(service_locator_) << "INVALID culling type"; + break; } UpdateCullingState(state); break; @@ -2605,6 +2614,9 @@ void Collada::AddRenderState(FCDEffectPassState* pass_state, State* state) { SetBoolState(state, State::kStencilEnableParamName, value); break; } + default: + // do nothing + break; } } @@ -2783,7 +2795,6 @@ void Collada::SetParamsFromMaterial(FCDMaterial* material, LOG_ASSERT(p); String param_name(p->GetReference()); // Check for an effect binding - FCDEffect* effect = material->GetEffect(); FCDEffectProfileFX* profile_fx = FindProfileFX(material->GetEffect()); if (profile_fx) { FCDEffectTechnique* technique = profile_fx->GetTechnique(0); diff --git a/o3d/import/cross/collada.h b/o3d/import/cross/collada.h index 77382d8..a102e08 100644 --- a/o3d/import/cross/collada.h +++ b/o3d/import/cross/collada.h @@ -132,8 +132,8 @@ class Collada { struct Options { Options() : generate_mipmaps(true), - condition_document(false), keep_original_data(false), + condition_document(false), up_axis(0.0f, 0.0f, 0.0f), base_path(FilePath::kCurrentDirectory) {} // Whether or not to generate mip-maps on the textures we load. diff --git a/o3d/import/cross/collada_conditioner.cc b/o3d/import/cross/collada_conditioner.cc index 8ba9661..c5ec51c 100644 --- a/o3d/import/cross/collada_conditioner.cc +++ b/o3d/import/cross/collada_conditioner.cc @@ -53,19 +53,19 @@ FUDaeTextureFilterFunction::FilterFunction LookupFilterFunction( const char* name; FUDaeTextureFilterFunction::FilterFunction func; } functions[] = { - "None", FUDaeTextureFilterFunction::NONE, - "Linear", FUDaeTextureFilterFunction::LINEAR, - "Point", FUDaeTextureFilterFunction::NEAREST, // DX - "Nearest", FUDaeTextureFilterFunction::NEAREST, // GL - "LinearMipmapLinear", FUDaeTextureFilterFunction::LINEAR_MIPMAP_LINEAR, - "LinearMipmapNearest", FUDaeTextureFilterFunction::LINEAR_MIPMAP_NEAREST, - "NearestMipmapNearest", FUDaeTextureFilterFunction::LINEAR_MIPMAP_NEAREST, - "NearestMipmapLinear", FUDaeTextureFilterFunction::NEAREST_MIPMAP_LINEAR, + {"None", FUDaeTextureFilterFunction::NONE}, + {"Linear", FUDaeTextureFilterFunction::LINEAR}, + {"Point", FUDaeTextureFilterFunction::NEAREST}, // DX + {"Nearest", FUDaeTextureFilterFunction::NEAREST}, // GL + {"LinearMipmapLinear", FUDaeTextureFilterFunction::LINEAR_MIPMAP_LINEAR}, + {"LinearMipmapNearest", FUDaeTextureFilterFunction::LINEAR_MIPMAP_NEAREST}, + {"NearestMipmapNearest", FUDaeTextureFilterFunction::LINEAR_MIPMAP_NEAREST}, + {"NearestMipmapLinear", FUDaeTextureFilterFunction::NEAREST_MIPMAP_LINEAR}, // TODO: Once FCollada supports the COLLADA v1.5 spec, // turn this on. // "Anisotropic", FUDaeTextureFilterFunction::ANISOTROPIC, }; - for (int i = 0; i < sizeof(functions) / sizeof(functions[0]); ++i) { + for (size_t i = 0; i < sizeof(functions) / sizeof(functions[0]); ++i) { if (!base::strcasecmp(functions[i].name, name)) { return functions[i].func; } @@ -80,19 +80,19 @@ FUDaeTextureWrapMode::WrapMode LookupWrapMode(const char* name) { const char* name; FUDaeTextureWrapMode::WrapMode mode; } modes[] = { - "None", FUDaeTextureWrapMode::NONE, + {"None", FUDaeTextureWrapMode::NONE}, // DX-style names: - "Wrap", FUDaeTextureWrapMode::WRAP, - "Mirror", FUDaeTextureWrapMode::MIRROR, - "Clamp", FUDaeTextureWrapMode::CLAMP, - "Border", FUDaeTextureWrapMode::BORDER, + {"Wrap", FUDaeTextureWrapMode::WRAP}, + {"Mirror", FUDaeTextureWrapMode::MIRROR}, + {"Clamp", FUDaeTextureWrapMode::CLAMP}, + {"Border", FUDaeTextureWrapMode::BORDER}, // GL-style names: - "Repeat", FUDaeTextureWrapMode::WRAP, - "MirroredRepeat", FUDaeTextureWrapMode::MIRROR, - "ClampToEdge", FUDaeTextureWrapMode::CLAMP, - "ClampToBorder", FUDaeTextureWrapMode::BORDER, + {"Repeat", FUDaeTextureWrapMode::WRAP}, + {"MirroredRepeat", FUDaeTextureWrapMode::MIRROR}, + {"ClampToEdge", FUDaeTextureWrapMode::CLAMP}, + {"ClampToBorder", FUDaeTextureWrapMode::BORDER}, }; - for (int i = 0; i < sizeof(modes) / sizeof(modes[0]); ++i) { + for (size_t i = 0; i < sizeof(modes) / sizeof(modes[0]); ++i) { if (!base::strcasecmp(modes[i].name, name)) { return modes[i].mode; } diff --git a/o3d/import/cross/gz_compressor.cc b/o3d/import/cross/gz_compressor.cc index 6c853e1..e42f2e7 100644 --- a/o3d/import/cross/gz_compressor.cc +++ b/o3d/import/cross/gz_compressor.cc @@ -47,8 +47,8 @@ namespace o3d { // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GzCompressor::GzCompressor(StreamProcessor *callback_client) - : callback_client_(callback_client), - stream_is_closed_(false) { + : stream_is_closed_(false), + callback_client_(callback_client) { strm_.zalloc = Z_NULL; strm_.zfree = Z_NULL; strm_.opaque = Z_NULL; diff --git a/o3d/import/cross/memory_stream.h b/o3d/import/cross/memory_stream.h index 00585b6..e71379a 100644 --- a/o3d/import/cross/memory_stream.h +++ b/o3d/import/cross/memory_stream.h @@ -55,13 +55,13 @@ namespace o3d { class MemoryReadStream { public: MemoryReadStream(const uint8 *memory, size_t n) - : memory_(memory), length_(n), read_index_(0) {} + : memory_(memory), read_index_(0), length_(n) {} // Explicit copy constructor MemoryReadStream(const MemoryReadStream &stream) : memory_(stream.memory_), - length_(stream.length_), - read_index_(stream.read_index_) {} + read_index_(stream.read_index_), + length_(stream.length_) {} virtual ~MemoryReadStream() {} @@ -179,13 +179,13 @@ class MemoryWriteStream { MemoryWriteStream() : memory_(NULL), write_index_(0), length_(0) {} MemoryWriteStream(uint8 *memory, size_t n) - : memory_(memory), length_(n), write_index_(0) {} + : memory_(memory), write_index_(0), length_(n) {} // Explicit copy constructor MemoryWriteStream(const MemoryWriteStream &stream) : memory_(stream.memory_), - length_(stream.length_), - write_index_(stream.write_index_) {} + write_index_(stream.write_index_), + length_(stream.length_) {} virtual ~MemoryWriteStream() {} diff --git a/o3d/import/cross/raw_data.cc b/o3d/import/cross/raw_data.cc index deabe37..66e0109 100644 --- a/o3d/import/cross/raw_data.cc +++ b/o3d/import/cross/raw_data.cc @@ -396,7 +396,7 @@ bool RawData::GetTempFilePathFromURI(const String &uri, String filename; // try to retain the original file suffix (.jpg, etc.) - int dot_position = uri.rfind('.'); + std::string::size_type dot_position = uri.rfind('.'); if (dot_position != std::string::npos) { filename = uuid_string + uri.substr(dot_position); } else { diff --git a/o3d/import/cross/tar_generator.cc b/o3d/import/cross/tar_generator.cc index 0b71e69..ed72e05 100644 --- a/o3d/import/cross/tar_generator.cc +++ b/o3d/import/cross/tar_generator.cc @@ -119,7 +119,8 @@ void TarGenerator::WriteHeader(const String& file_name, ::snprintf(p + kGroupIDOffset, 8, "%07o", group_id); // File size - ::snprintf(p + kFileSizeOffset, 12, "%011o", file_size); + ::snprintf(p + kFileSizeOffset, 12, "%011o", + static_cast<unsigned int>(file_size)); // Modification time // TODO: write the correct current time here... @@ -189,7 +190,7 @@ void TarGenerator::ComputeCheckSum(uint8 *header) { checksum += header[i]; } snprintf(reinterpret_cast<char*>(header + kHeaderCheckSumOffset), - 8, "%06o\0\0", checksum); + 8, "%06o%c%c", checksum, 0, 0); } // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/o3d/import/cross/tar_processor.cc b/o3d/import/cross/tar_processor.cc index d126788..7b14c22 100644 --- a/o3d/import/cross/tar_processor.cc +++ b/o3d/import/cross/tar_processor.cc @@ -64,7 +64,7 @@ int TarProcessor::ProcessBytes(MemoryReadStream *stream, size_t n) { if (header_bytes_read_ == TAR_HEADER_SIZE) { // The tar format stupidly represents size_t values as octal strings!! - size_t file_size = 0; + unsigned int file_size = 0u; sscanf(header_ + kFileSizeOffset, "%o", &file_size); // Check if it's a long filename diff --git a/o3d/import/cross/targz_generator_test.cc b/o3d/import/cross/targz_generator_test.cc index 8715933..3104890 100644 --- a/o3d/import/cross/targz_generator_test.cc +++ b/o3d/import/cross/targz_generator_test.cc @@ -74,15 +74,13 @@ class TarGzTestClient : public StreamProcessor { // Checks that the data from the reference tar.gz file matches the tar.gz // stream we just ge5nerated - void Validate(uint8 *reference_data) { + uint8* compressed_data() { uint8 *received_data = compressed_data_; + return received_data; + } - // on Windows the platform field is different than our reference file - received_data[9] = 3; // Force platform in header to 'UNIX'. - - EXPECT_EQ(0, memcmp(reference_data, - received_data, - compressed_data_.GetLength())); + size_t compressed_data_length() { + return compressed_data_.GetLength(); } #if defined(GENERATE_GOLDEN) @@ -155,7 +153,15 @@ TEST_F(TarGzGeneratorTest, GenerateTarGz) { #endif - test_client.Validate(targz_data); + uint8 *received_data = test_client.compressed_data(); + + // The platform header in our reference file is set to UNIX, so + // force received data to match for all platforms. + received_data[9] = 3; + + EXPECT_EQ(0, memcmp(targz_data, + received_data, + test_client.compressed_data_length())); free(targz_data); free(image_data); diff --git a/o3d/import/cross/zip_archive.cc b/o3d/import/cross/zip_archive.cc index cd7f0455..946915c 100644 --- a/o3d/import/cross/zip_archive.cc +++ b/o3d/import/cross/zip_archive.cc @@ -863,7 +863,7 @@ bool ZipArchive::GetTempFileFromFile(const string &filename, #else // get just the final path component - int pos = filename.rfind('/'); + string::size_type pos = filename.rfind('/'); if (pos != string::npos) { // TODO : need to get "proper" temp dir for user // TODO : need to append GUID to filename diff --git a/o3d/import/mac/collada_conditioner_mac.mm b/o3d/import/mac/collada_conditioner_mac.mm index 97f98fa..cb39e85 100644 --- a/o3d/import/mac/collada_conditioner_mac.mm +++ b/o3d/import/mac/collada_conditioner_mac.mm @@ -99,7 +99,7 @@ bool ColladaConditioner::PreprocessShaderFile(const FilePath& in_filename, NSPipe *pipe = [NSPipe pipe]; [task setStandardOutput:pipe]; [task launch]; - NSData *data = [[pipe fileHandleForReading] readDataToEndOfFile]; + [[pipe fileHandleForReading] readDataToEndOfFile]; return true; } } // end namespace o3d |