From 33139d7b5cdbe58b60132f6846f969fecdf993e2 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Tue, 28 Jul 2015 14:52:33 -0500 Subject: [PATCH] fix some cppcheck detected issues --- .../sharedDebug/src/shared/DataLint.cpp | 40 +++++++++---------- .../sharedDebug/src/shared/Profiler.cpp | 8 ++-- .../sharedMath/src/shared/PolySolver.cpp | 2 +- .../src/linux/NetworkGetHostName.cpp | 2 +- .../shared/core/TemplateDefinitionFile.cpp | 3 +- 5 files changed, 29 insertions(+), 26 deletions(-) diff --git a/engine/shared/library/sharedDebug/src/shared/DataLint.cpp b/engine/shared/library/sharedDebug/src/shared/DataLint.cpp index a826923d..5190728f 100644 --- a/engine/shared/library/sharedDebug/src/shared/DataLint.cpp +++ b/engine/shared/library/sharedDebug/src/shared/DataLint.cpp @@ -323,26 +323,6 @@ void DataLint::report() writeError(assetErrorFileAllWarning, *warningListIter, totalErrorCountAllWarning); } } - - if (assetErrorFileAll) { fclose(assetErrorFileAll); } - if (assetErrorFileAllFatal) { fclose(assetErrorFileAllFatal); } - if (assetErrorFileAllWarning) { fclose(assetErrorFileAllWarning); } - if (assetErrorFileObjectTemplate) { fclose(assetErrorFileObjectTemplate); } - - if (m_mode == M_client) - { - if (assetErrorFileAppearance) { fclose(assetErrorFileAppearance); } - if (assetErrorFileArrangementDescriptor) { fclose(assetErrorFileArrangementDescriptor); } - if (assetErrorFileLocalizedStringTable) { fclose(assetErrorFileLocalizedStringTable); } - if (assetErrorFilePortalProperty) { fclose(assetErrorFilePortalProperty); } - if (assetErrorFileShaderTemplate) { fclose(assetErrorFileShaderTemplate); } - if (assetErrorFileSkyBox) { fclose(assetErrorFileSkyBox); } - if (assetErrorFileSlotDescriptor) { fclose(assetErrorFileSlotDescriptor); } - if (assetErrorFileSoundTemplate) { fclose(assetErrorFileSoundTemplate); } - if (assetErrorFileTerrain) { fclose(assetErrorFileTerrain); } - if (assetErrorFileTexture) { fclose(assetErrorFileTexture); } - if (assetErrorFileTextureRenderer) { fclose(assetErrorFileTextureRenderer); } - } } // UnSupported Assets @@ -411,6 +391,26 @@ void DataLint::report() fclose(fp); } + + if (assetErrorFileAll) { fclose(assetErrorFileAll); } + if (assetErrorFileAllFatal) { fclose(assetErrorFileAllFatal); } + if (assetErrorFileAllWarning) { fclose(assetErrorFileAllWarning); } + if (assetErrorFileObjectTemplate) { fclose(assetErrorFileObjectTemplate); } + + if (m_mode == M_client) + { + if (assetErrorFileAppearance) { fclose(assetErrorFileAppearance); } + if (assetErrorFileArrangementDescriptor) { fclose(assetErrorFileArrangementDescriptor); } + if (assetErrorFileLocalizedStringTable) { fclose(assetErrorFileLocalizedStringTable); } + if (assetErrorFilePortalProperty) { fclose(assetErrorFilePortalProperty); } + if (assetErrorFileShaderTemplate) { fclose(assetErrorFileShaderTemplate); } + if (assetErrorFileSkyBox) { fclose(assetErrorFileSkyBox); } + if (assetErrorFileSlotDescriptor) { fclose(assetErrorFileSlotDescriptor); } + if (assetErrorFileSoundTemplate) { fclose(assetErrorFileSoundTemplate); } + if (assetErrorFileTerrain) { fclose(assetErrorFileTerrain); } + if (assetErrorFileTexture) { fclose(assetErrorFileTexture); } + if (assetErrorFileTextureRenderer) { fclose(assetErrorFileTextureRenderer); } + } } } diff --git a/engine/shared/library/sharedDebug/src/shared/Profiler.cpp b/engine/shared/library/sharedDebug/src/shared/Profiler.cpp index a0bd3089..eb484451 100644 --- a/engine/shared/library/sharedDebug/src/shared/Profiler.cpp +++ b/engine/shared/library/sharedDebug/src/shared/Profiler.cpp @@ -215,14 +215,16 @@ VisibleExpandableEntry * VisibleExpandableEntry::findOrAddExpandableChild(char c bool VisibleExpandableEntry::pruneInvisibleChildren() { for (Children::iterator i = m_children.begin(); i != m_children.end(); ) + { if ((*i)->m_visible == false) { - delete *i; - m_children.erase(i); + i = m_children.erase(i); } else + { ++i; - + } + } bool const result = ms_destroyedSelected; ms_destroyedSelected = false; return result; diff --git a/engine/shared/library/sharedMath/src/shared/PolySolver.cpp b/engine/shared/library/sharedMath/src/shared/PolySolver.cpp index 06515452..872057d1 100644 --- a/engine/shared/library/sharedMath/src/shared/PolySolver.cpp +++ b/engine/shared/library/sharedMath/src/shared/PolySolver.cpp @@ -154,7 +154,7 @@ double evaluateQuarticDerivative ( double x, const double c[5] ) return ((4.0*x*c[4] + 3.0*c[3]) * x + 2.0*c[2]) * x + c[1]; } -double cleanQuarticRoot( double x, const double c[4] ) +double cleanQuarticRoot( double x, const double c[5] ) { double e; diff --git a/engine/shared/library/sharedNetwork/src/linux/NetworkGetHostName.cpp b/engine/shared/library/sharedNetwork/src/linux/NetworkGetHostName.cpp index a68bba8d..f9884aca 100644 --- a/engine/shared/library/sharedNetwork/src/linux/NetworkGetHostName.cpp +++ b/engine/shared/library/sharedNetwork/src/linux/NetworkGetHostName.cpp @@ -96,7 +96,7 @@ addrList() if (errno != EINVAL || lastReqSize != 0) { WARNING(true, ("Error getting interface list: %s", strerror(errno))); - delete buf; + delete[] buf; return; } } diff --git a/engine/shared/library/sharedTemplateDefinition/src/shared/core/TemplateDefinitionFile.cpp b/engine/shared/library/sharedTemplateDefinition/src/shared/core/TemplateDefinitionFile.cpp index d57d342b..518b632b 100644 --- a/engine/shared/library/sharedTemplateDefinition/src/shared/core/TemplateDefinitionFile.cpp +++ b/engine/shared/library/sharedTemplateDefinition/src/shared/core/TemplateDefinitionFile.cpp @@ -180,7 +180,8 @@ void TemplateDefinitionFile::writeTemplateId(File &fp) const void TemplateDefinitionFile::writeClassHeaderBegin(File &fp) const { const char * name = getTemplateName().c_str(); - const char * baseName = getBaseName().c_str(); + const char * baseName = getBaseName(); + baseName = baseName.c_str(); const char * baseNamePath = ""; if (baseName[0] == '\0' && m_templateLocation != LOC_NONE) {