Fix compiler warnings + one review finding.
authorKim Kulling <kim.kulling@googlemail.com>
Sun, 9 Jul 2017 20:17:35 +0000 (22:17 +0200)
committerKim Kulling <kim.kulling@googlemail.com>
Sun, 9 Jul 2017 20:17:35 +0000 (22:17 +0200)
code/BaseImporter.cpp
code/BlenderDNA.h
code/FBXBinaryTokenizer.cpp
code/PlyLoader.cpp
code/PlyParser.cpp
test/unit/utBatchLoader.cpp
test/unit/utglTFImportExport.cpp

index 9598e8e..09b32e3 100644 (file)
@@ -358,7 +358,6 @@ void BaseImporter::ConvertToUTF8(std::vector<char>& data)
         DefaultLogger::get()->debug("Found UTF-16 BOM ...");
 
         std::vector<unsigned char> output;
-        int16_t *ptr = (int16_t*) &data[ 0 ];
         utf8::utf16to8(data.begin(), data.end(), back_inserter(output));
         return;
     }
index c09f1ca..de0a5a6 100644 (file)
@@ -253,10 +253,7 @@ public:
      *  a compiler complain is the result.
      *  @param dest Destination value to be written
      *  @param db File database, including input stream. */
-    template <typename T> inline void Convert (T& dest,
-        const FileDatabase& db) const;
-
-
+    template <typename T> inline void Convert (T& dest, const FileDatabase& db) const;
 
     // --------------------------------------------------------
     // generic converter
index 17cb942..a02458f 100644 (file)
@@ -161,8 +161,7 @@ uint32_t ReadWord(const char* input, const char*& cursor, const char* end)
 }
 
 // ------------------------------------------------------------------------------------------------
-uint64_t ReadDoubleWord(const char* input, const char*& cursor, const char* end)
-{
+uint64_t ReadDoubleWord(const char* input, const char*& cursor, const char* end) {
     const size_t k_to_read = sizeof(uint64_t);
     if(Offset(cursor, end) < k_to_read) {
         TokenizeError("cannot ReadDoubleWord, out of bounds",input, cursor);
@@ -176,7 +175,6 @@ uint64_t ReadDoubleWord(const char* input, const char*& cursor, const char* end)
     return dword;
 }
 
-
 // ------------------------------------------------------------------------------------------------
 uint8_t ReadByte(const char* input, const char*& cursor, const char* end)
 {
@@ -447,8 +445,9 @@ void TokenizeBinary(TokenList& output_tokens, const char* input, unsigned int le
     const uint32_t flags = ReadWord(input, cursor, input + length);
 
     const uint8_t padding_0 = ReadByte(input, cursor, input + length); // unused
+    (void) padding_0;
     const uint8_t padding_1 = ReadByte(input, cursor, input + length); // unused
-
+    (void) padding_1;
     while (cursor < input + length)
     {
         if(!ReadScope(output_tokens, input, cursor, input + length, flags)) {
index b62b373..46def8c 100644 (file)
@@ -159,6 +159,9 @@ void PLYImporter::InternReadFile(const std::string& pFile,
 
   // Get the file-size
   size_t fileSize = fileStream->FileSize();
+  if ( 0 == fileSize ) {
+      throw DeadlyImportError("File " + pFile + " is empty.");
+  }
 
   IOStreamBuffer<char> streamedBuffer(1024 * 1024);
   streamedBuffer.open(fileStream.get());
index e290050..d978b51 100644 (file)
@@ -935,30 +935,6 @@ bool PLY::PropertyInstance::ParseValue(const char* &pCur,
   ai_assert(NULL != out);
   
   //calc element size
-  unsigned int lsize = 0;
-  switch (eType)
-  {
-  case EDT_Char:
-  case EDT_UChar:
-    lsize = 1;
-    break;
-
-  case EDT_UShort:
-  case EDT_Short:
-    lsize = 2;
-    break;
-
-  case EDT_UInt:
-  case EDT_Int:
-  case EDT_Float:
-    lsize = 4;
-    break;
-
-  case EDT_Double:
-    lsize = 8;
-    break;
-  }
-
   bool ret = true;
   switch (eType)
   {
@@ -990,6 +966,7 @@ bool PLY::PropertyInstance::ParseValue(const char* &pCur,
     out->fDouble = (double)d;
     break;
 
+  case EDT_INVALID:
   default:
     ret = false;
     break;
@@ -1032,6 +1009,10 @@ bool PLY::PropertyInstance::ParseValueBinary(IOStreamBuffer<char> &streamBuffer,
   case EDT_Double:
     lsize = 8;
     break;
+
+  case EDT_INVALID:
+  default:
+      break;
   }
 
   //read the next file block if needed
index 32ec870..56862f9 100644 (file)
@@ -66,6 +66,7 @@ TEST_F( BatchLoaderTest, createTest ) {
     } catch ( ... ) {
         ok = false;
     }
+    EXPECT_TRUE( ok );
 }
 
 TEST_F( BatchLoaderTest, validateAccessTest ) {
index 3dc1104..349ddda 100644 (file)
@@ -50,10 +50,8 @@ class utglTFImportExport : public AbstractImportExportBase {
 public:
     virtual bool importerTest() {
         Assimp::Importer importer;
-        const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/glFT/TwoBoxes/TwoBoxes.gltf", 0 );
-        //return nullptr != scene;
-
-        return true;
+        const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/glTF/TwoBoxes/TwoBoxes.gltf", 0 );
+        return nullptr != scene;
     }
 };