Core/Log: Fix some issues detected by static analysis.

* Either inefficient or wrong usage of string::find(). string::compare() will
  be faster if string::find's result is compared with 0, because it will not scan the whole string.
  If your intention is to check that there are no findings in the string,
  you should compare with std::string::npos.

* C-style pointer casting detected. C++ offers four different kinds of casts as replacements:
  static_cast, const_cast, dynamic_cast and reinterpret_cast.
This commit is contained in:
Naios
2015-03-11 08:17:37 +01:00
parent 678c307db6
commit 8882a6ca78
2 changed files with 2 additions and 2 deletions

View File

@@ -26,7 +26,7 @@ AppenderDB::~AppenderDB() { }
void AppenderDB::_write(LogMessage const& message)
{
// Avoid infinite loop, PExecute triggers Logging with "sql.sql" type
if (!enabled || !message.type.find("sql"))
if (!enabled || (message.type.find("sql") != std::string::npos))
return;
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_LOG);

View File

@@ -376,7 +376,7 @@ void Log::SetRealmId(uint32 id)
{
for (AppenderMap::iterator it = appenders.begin(); it != appenders.end(); ++it)
if (it->second && it->second->getType() == APPENDER_DB)
((AppenderDB *)it->second)->setRealmId(id);
static_cast<AppenderDB*>(it->second)->setRealmId(id);
}
void Log::Close()