2
0
Эх сурвалжийг харах

Fix some coverity findings.

kimkulling 6 жил өмнө
parent
commit
61ffe017e8

+ 3 - 1
code/ImproveCacheLocality.cpp

@@ -112,7 +112,9 @@ void ImproveCacheLocalityProcess::Execute( aiScene* pScene)
         }
         }
     }
     }
     if (!DefaultLogger::isNullLogger()) {
     if (!DefaultLogger::isNullLogger()) {
-        ASSIMP_LOG_INFO_F("Cache relevant are ", numm, " meshes (", numf," faces). Average output ACMR is ", out / numf );
+        if (numf > 0) {
+            ASSIMP_LOG_INFO_F("Cache relevant are ", numm, " meshes (", numf, " faces). Average output ACMR is ", out / numf);
+        }
         ASSIMP_LOG_DEBUG("ImproveCacheLocalityProcess finished. ");
         ASSIMP_LOG_DEBUG("ImproveCacheLocalityProcess finished. ");
     }
     }
 }
 }

+ 18 - 26
tools/assimp_cmd/Info.cpp

@@ -51,27 +51,26 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include <string>
 #include <string>
 
 
 const char* AICMD_MSG_INFO_HELP_E =
 const char* AICMD_MSG_INFO_HELP_E =
-"assimp info <file> [-r] [-v]\n"
-"\tPrint basic structure of a 3D model\n"
-"\t-r,--raw: No postprocessing, do a raw import\n"
-"\t-v,--verbose: Print verbose info such as node transform data\n"
-"\t-s, --silent: Print only minimal info\n";
-
-const std::string TREE_BRANCH_ASCII = "|-";
-const std::string TREE_BRANCH_UTF8 = "\xe2\x94\x9c\xe2\x95\xb4";
-const std::string TREE_STOP_ASCII = "'-";
-const std::string TREE_STOP_UTF8 = "\xe2\x94\x94\xe2\x95\xb4";
-const std::string TREE_CONTINUE_ASCII = "| ";
-const std::string TREE_CONTINUE_UTF8 = "\xe2\x94\x82 ";
-
-// note: by default this is outputing utf-8 text.
+    "assimp info <file> [-r] [-v]\n"
+    "\tPrint basic structure of a 3D model\n"
+    "\t-r,--raw: No postprocessing, do a raw import\n"
+    "\t-v,--verbose: Print verbose info such as node transform data\n"
+    "\t-s, --silent: Print only minimal info\n";
+
+const char *TREE_BRANCH_ASCII = "|-";
+const char *TREE_BRANCH_UTF8 = "\xe2\x94\x9c\xe2\x95\xb4";
+const char *TREE_STOP_ASCII = "'-";
+const char *TREE_STOP_UTF8 = "\xe2\x94\x94\xe2\x95\xb4";
+const char *TREE_CONTINUE_ASCII = "| ";
+const char *TREE_CONTINUE_UTF8 = "\xe2\x94\x82 ";
+
+// note: by default this is using utf-8 text.
 // this is well supported on pretty much any linux terminal.
 // this is well supported on pretty much any linux terminal.
 // if this causes problems on some platform,
 // if this causes problems on some platform,
 // put an #ifdef to use the ascii version for that platform.
 // put an #ifdef to use the ascii version for that platform.
-const std::string TREE_BRANCH = TREE_BRANCH_UTF8;
-const std::string TREE_STOP = TREE_STOP_UTF8;
-const std::string TREE_CONTINUE = TREE_CONTINUE_UTF8;
-
+const char *TREE_BRANCH = TREE_BRANCH_UTF8;
+const char *TREE_STOP = TREE_STOP_UTF8;
+const char *TREE_CONTINUE = TREE_CONTINUE_UTF8;
 
 
 // -----------------------------------------------------------------------------------
 // -----------------------------------------------------------------------------------
 unsigned int CountNodes(const aiNode* root)
 unsigned int CountNodes(const aiNode* root)
@@ -280,14 +279,7 @@ void PrintHierarchy(
 
 
 // -----------------------------------------------------------------------------------
 // -----------------------------------------------------------------------------------
 // Implementation of the assimp info utility to print basic file info
 // Implementation of the assimp info utility to print basic file info
-int Assimp_Info (const char* const* params, unsigned int num)
-{
-	if (num < 1) {
-		printf("assimp info: Invalid number of arguments. "
-			"See \'assimp info --help\'\n");
-		return 1;
-	}
-
+int Assimp_Info (const char* const* params, unsigned int num) {
 	// --help
 	// --help
 	if (!strcmp( params[0],"-h")||!strcmp( params[0],"--help")||!strcmp( params[0],"-?") ) {
 	if (!strcmp( params[0],"-h")||!strcmp( params[0],"--help")||!strcmp( params[0],"-?") ) {
 		printf("%s",AICMD_MSG_INFO_HELP_E);
 		printf("%s",AICMD_MSG_INFO_HELP_E);

+ 6 - 7
tools/assimp_cmd/WriteDumb.cpp

@@ -276,9 +276,12 @@ inline uint32_t WriteBounds(const T* in, unsigned int size)
 void ChangeInteger(uint32_t ofs,uint32_t n)
 void ChangeInteger(uint32_t ofs,uint32_t n)
 {
 {
 	const uint32_t cur = ftell(out);
 	const uint32_t cur = ftell(out);
-	fseek(out,ofs,SEEK_SET);
-	fwrite(&n,4,1,out);
-	fseek(out,cur,SEEK_SET);
+    int retCode;
+    retCode = fseek(out, ofs, SEEK_SET);
+    ai_assert(0 == retCode);
+	fwrite(&n, 4, 1, out);
+    retCode = fseek(out, cur, SEEK_SET);
+    ai_assert(0 == retCode);
 }
 }
 
 
 // -----------------------------------------------------------------------------------
 // -----------------------------------------------------------------------------------
@@ -1333,10 +1336,6 @@ int Assimp_Dump (const char* const* params, unsigned int num)
 {
 {
 	const char* fail = "assimp dump: Invalid number of arguments. "
 	const char* fail = "assimp dump: Invalid number of arguments. "
 			"See \'assimp dump --help\'\r\n";
 			"See \'assimp dump --help\'\r\n";
-	if (num < 1) {
-		printf("%s", fail);
-		return 1;
-	}
 
 
 	// --help
 	// --help
 	if (!strcmp( params[0], "-h") || !strcmp( params[0], "--help") || !strcmp( params[0], "-?") ) {
 	if (!strcmp( params[0], "-h") || !strcmp( params[0], "--help") || !strcmp( params[0], "-?") ) {