aboutsummaryrefslogtreecommitdiff
path: root/src/server/shared
diff options
context:
space:
mode:
authorDDuarte <dnpd.dd@gmail.com>2014-09-19 03:30:02 +0100
committerDDuarte <dnpd.dd@gmail.com>2014-09-19 03:30:02 +0100
commitcefcde9ba9a4d951500ffb267134eaebaad6b928 (patch)
tree7082078a89fa484c798b8ee89eccb9b5afb1f434 /src/server/shared
parente6b7de8c9762b47be3e20feb65164c8c72523fe4 (diff)
Core/Misc: Multiple static analysis issues fixed (small optimizations and clear code)
Diffstat (limited to 'src/server/shared')
-rw-r--r--src/server/shared/DataStores/DBCFileLoader.cpp6
-rw-r--r--src/server/shared/Database/DatabaseWorkerPool.h3
-rw-r--r--src/server/shared/Database/MySQLConnection.cpp3
-rw-r--r--src/server/shared/Debugging/WheatyExceptionReport.cpp2
-rw-r--r--src/server/shared/Threading/ProcessPriority.h2
-rw-r--r--src/server/shared/Utilities/ServiceWin32.cpp3
-rw-r--r--src/server/shared/Utilities/Util.cpp16
-rw-r--r--src/server/shared/Utilities/Util.h6
8 files changed, 19 insertions, 22 deletions
diff --git a/src/server/shared/DataStores/DBCFileLoader.cpp b/src/server/shared/DataStores/DBCFileLoader.cpp
index d027d7539ad..1b7d34464f6 100644
--- a/src/server/shared/DataStores/DBCFileLoader.cpp
+++ b/src/server/shared/DataStores/DBCFileLoader.cpp
@@ -112,11 +112,9 @@ bool DBCFileLoader::Load(const char* filename, const char* fmt)
DBCFileLoader::~DBCFileLoader()
{
- if (data)
- delete [] data;
+ delete[] data;
- if (fieldsOffset)
- delete [] fieldsOffset;
+ delete[] fieldsOffset;
}
DBCFileLoader::Record DBCFileLoader::getRecord(size_t id)
diff --git a/src/server/shared/Database/DatabaseWorkerPool.h b/src/server/shared/Database/DatabaseWorkerPool.h
index 5548e44c925..61385d92437 100644
--- a/src/server/shared/Database/DatabaseWorkerPool.h
+++ b/src/server/shared/Database/DatabaseWorkerPool.h
@@ -76,13 +76,12 @@ class DatabaseWorkerPool
bool Open(const std::string& infoString, uint8 async_threads, uint8 synch_threads)
{
- bool res = true;
_connectionInfo = new MySQLConnectionInfo(infoString);
TC_LOG_INFO("sql.driver", "Opening DatabasePool '%s'. Asynchronous connections: %u, synchronous connections: %u.",
GetDatabaseName(), async_threads, synch_threads);
- res = OpenConnections(IDX_ASYNC, async_threads);
+ bool res = OpenConnections(IDX_ASYNC, async_threads);
if (!res)
return res;
diff --git a/src/server/shared/Database/MySQLConnection.cpp b/src/server/shared/Database/MySQLConnection.cpp
index abdf2a2cc3c..24290009625 100644
--- a/src/server/shared/Database/MySQLConnection.cpp
+++ b/src/server/shared/Database/MySQLConnection.cpp
@@ -57,8 +57,7 @@ m_connectionFlags(CONNECTION_ASYNC)
MySQLConnection::~MySQLConnection()
{
- if (m_worker)
- delete m_worker;
+ delete m_worker;
for (size_t i = 0; i < m_stmts.size(); ++i)
delete m_stmts[i];
diff --git a/src/server/shared/Debugging/WheatyExceptionReport.cpp b/src/server/shared/Debugging/WheatyExceptionReport.cpp
index 2eb456ddd02..66b7929514c 100644
--- a/src/server/shared/Debugging/WheatyExceptionReport.cpp
+++ b/src/server/shared/Debugging/WheatyExceptionReport.cpp
@@ -1043,7 +1043,7 @@ bool logChildren)
offset, bHandled, Name, "", false, false);
// Set Value back to an empty string since the Array object itself has no value, only its elements have
- symbolDetails.top().Value = "";
+ symbolDetails.top().Valu.clear();
DWORD elementsCount;
if (SymGetTypeInfo(m_hProcess, modBase, dwTypeIndex, TI_GET_COUNT, &elementsCount))
diff --git a/src/server/shared/Threading/ProcessPriority.h b/src/server/shared/Threading/ProcessPriority.h
index 23238c94ace..6446820e32d 100644
--- a/src/server/shared/Threading/ProcessPriority.h
+++ b/src/server/shared/Threading/ProcessPriority.h
@@ -26,7 +26,7 @@
#define PROCESS_HIGH_PRIORITY -15 // [-20, 19], default is 0
#endif
-void SetProcessPriority(const std::string logChannel)
+void SetProcessPriority(const std::string& logChannel)
{
// Suppresses Mac OS X Warning since logChannel isn't used.
#if PLATFORM_APPLE
diff --git a/src/server/shared/Utilities/ServiceWin32.cpp b/src/server/shared/Utilities/ServiceWin32.cpp
index ecf403423f7..6e5309d70d7 100644
--- a/src/server/shared/Utilities/ServiceWin32.cpp
+++ b/src/server/shared/Utilities/ServiceWin32.cpp
@@ -204,7 +204,8 @@ void WINAPI ServiceMain(DWORD argc, char *argv[])
GetModuleFileName(0, path, sizeof(path)/sizeof(path[0]));
- for (i = 0; i < std::strlen(path); i++)
+ size_t pathLen = std::strlen(path);
+ for (i = 0; i < pathLen; i++)
{
if (path[i] == '\\') last_slash = i;
}
diff --git a/src/server/shared/Utilities/Util.cpp b/src/server/shared/Utilities/Util.cpp
index f2c02510ed4..e577797d3e0 100644
--- a/src/server/shared/Utilities/Util.cpp
+++ b/src/server/shared/Utilities/Util.cpp
@@ -294,7 +294,7 @@ size_t utf8length(std::string& utf8str)
}
catch(std::exception)
{
- utf8str = "";
+ utf8str.clear();
return 0;
}
}
@@ -316,7 +316,7 @@ void utf8truncate(std::string& utf8str, size_t len)
}
catch(std::exception)
{
- utf8str = "";
+ utf8str.clear();
}
}
@@ -360,7 +360,7 @@ bool Utf8toWStr(const std::string& utf8str, std::wstring& wstr)
}
catch(std::exception)
{
- wstr = L"";
+ wstr.clear();
return false;
}
@@ -383,14 +383,14 @@ bool WStrToUtf8(wchar_t* wstr, size_t size, std::string& utf8str)
}
catch(std::exception)
{
- utf8str = "";
+ utf8str.clear();
return false;
}
return true;
}
-bool WStrToUtf8(std::wstring wstr, std::string& utf8str)
+bool WStrToUtf8(std::wstring const& wstr, std::string& utf8str)
{
try
{
@@ -406,7 +406,7 @@ bool WStrToUtf8(std::wstring wstr, std::string& utf8str)
}
catch(std::exception)
{
- utf8str = "";
+ utf8str.clear();
return false;
}
@@ -415,7 +415,7 @@ bool WStrToUtf8(std::wstring wstr, std::string& utf8str)
typedef wchar_t const* const* wstrlist;
-std::wstring GetMainPartOfName(std::wstring wname, uint32 declension)
+std::wstring GetMainPartOfName(std::wstring const& wname, uint32 declension)
{
// supported only Cyrillic cases
if (wname.size() < 1 || !isCyrillicCharacter(wname[0]) || declension > 5)
@@ -492,7 +492,7 @@ bool consoleToUtf8(const std::string& conStr, std::string& utf8str)
#endif
}
-bool Utf8FitTo(const std::string& str, std::wstring search)
+bool Utf8FitTo(const std::string& str, std::wstring const& search)
{
std::wstring temp;
diff --git a/src/server/shared/Utilities/Util.h b/src/server/shared/Utilities/Util.h
index 6370b9fda09..d88ad3be8e1 100644
--- a/src/server/shared/Utilities/Util.h
+++ b/src/server/shared/Utilities/Util.h
@@ -147,7 +147,7 @@ inline bool Utf8toWStr(const std::string& utf8str, wchar_t* wstr, size_t& wsize)
return Utf8toWStr(utf8str.c_str(), utf8str.size(), wstr, wsize);
}
-bool WStrToUtf8(std::wstring wstr, std::string& utf8str);
+bool WStrToUtf8(std::wstring const& wstr, std::string& utf8str);
// size==real string size
bool WStrToUtf8(wchar_t* wstr, size_t size, std::string& utf8str);
@@ -331,11 +331,11 @@ inline void wstrToLower(std::wstring& str)
std::transform( str.begin(), str.end(), str.begin(), wcharToLower );
}
-std::wstring GetMainPartOfName(std::wstring wname, uint32 declension);
+std::wstring GetMainPartOfName(std::wstring const& wname, uint32 declension);
bool utf8ToConsole(const std::string& utf8str, std::string& conStr);
bool consoleToUtf8(const std::string& conStr, std::string& utf8str);
-bool Utf8FitTo(const std::string& str, std::wstring search);
+bool Utf8FitTo(const std::string& str, std::wstring const& search);
void utf8printf(FILE* out, const char *str, ...);
void vutf8printf(FILE* out, const char *str, va_list* ap);