Fix compiler warnings + one review finding.

pull/1337/head
Kim Kulling 2017-07-09 22:17:35 +02:00
parent 647b59b7fa
commit d40b6089e8
7 changed files with 15 additions and 37 deletions

View File

@ -358,7 +358,6 @@ void BaseImporter::ConvertToUTF8(std::vector<char>& data)
DefaultLogger::get()->debug("Found UTF-16 BOM ..."); DefaultLogger::get()->debug("Found UTF-16 BOM ...");
std::vector<unsigned char> output; std::vector<unsigned char> output;
int16_t *ptr = (int16_t*) &data[ 0 ];
utf8::utf16to8(data.begin(), data.end(), back_inserter(output)); utf8::utf16to8(data.begin(), data.end(), back_inserter(output));
return; return;
} }

View File

@ -253,10 +253,7 @@ public:
* a compiler complain is the result. * a compiler complain is the result.
* @param dest Destination value to be written * @param dest Destination value to be written
* @param db File database, including input stream. */ * @param db File database, including input stream. */
template <typename T> inline void Convert (T& dest, template <typename T> inline void Convert (T& dest, const FileDatabase& db) const;
const FileDatabase& db) const;
// -------------------------------------------------------- // --------------------------------------------------------
// generic converter // generic converter

View 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); const size_t k_to_read = sizeof(uint64_t);
if(Offset(cursor, end) < k_to_read) { if(Offset(cursor, end) < k_to_read) {
TokenizeError("cannot ReadDoubleWord, out of bounds",input, cursor); 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; return dword;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
uint8_t ReadByte(const char* input, const char*& cursor, const char* end) 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 uint32_t flags = ReadWord(input, cursor, input + length);
const uint8_t padding_0 = ReadByte(input, cursor, input + length); // unused 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 const uint8_t padding_1 = ReadByte(input, cursor, input + length); // unused
(void) padding_1;
while (cursor < input + length) while (cursor < input + length)
{ {
if(!ReadScope(output_tokens, input, cursor, input + length, flags)) { if(!ReadScope(output_tokens, input, cursor, input + length, flags)) {

View File

@ -159,6 +159,9 @@ void PLYImporter::InternReadFile(const std::string& pFile,
// Get the file-size // Get the file-size
size_t fileSize = fileStream->FileSize(); size_t fileSize = fileStream->FileSize();
if ( 0 == fileSize ) {
throw DeadlyImportError("File " + pFile + " is empty.");
}
IOStreamBuffer<char> streamedBuffer(1024 * 1024); IOStreamBuffer<char> streamedBuffer(1024 * 1024);
streamedBuffer.open(fileStream.get()); streamedBuffer.open(fileStream.get());

View File

@ -935,30 +935,6 @@ bool PLY::PropertyInstance::ParseValue(const char* &pCur,
ai_assert(NULL != out); ai_assert(NULL != out);
//calc element size //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; bool ret = true;
switch (eType) switch (eType)
{ {
@ -990,6 +966,7 @@ bool PLY::PropertyInstance::ParseValue(const char* &pCur,
out->fDouble = (double)d; out->fDouble = (double)d;
break; break;
case EDT_INVALID:
default: default:
ret = false; ret = false;
break; break;
@ -1032,6 +1009,10 @@ bool PLY::PropertyInstance::ParseValueBinary(IOStreamBuffer<char> &streamBuffer,
case EDT_Double: case EDT_Double:
lsize = 8; lsize = 8;
break; break;
case EDT_INVALID:
default:
break;
} }
//read the next file block if needed //read the next file block if needed

View File

@ -66,6 +66,7 @@ TEST_F( BatchLoaderTest, createTest ) {
} catch ( ... ) { } catch ( ... ) {
ok = false; ok = false;
} }
EXPECT_TRUE( ok );
} }
TEST_F( BatchLoaderTest, validateAccessTest ) { TEST_F( BatchLoaderTest, validateAccessTest ) {

View File

@ -50,10 +50,8 @@ class utglTFImportExport : public AbstractImportExportBase {
public: public:
virtual bool importerTest() { virtual bool importerTest() {
Assimp::Importer importer; Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/glFT/TwoBoxes/TwoBoxes.gltf", 0 ); const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/glTF/TwoBoxes/TwoBoxes.gltf", 0 );
//return nullptr != scene; return nullptr != scene;
return true;
} }
}; };