Core/Misc: Fix GCC 8 warnings

This commit is contained in:
jackpoz authored and Ovahlord committed 2020-01-31 21:19:25 +01:00
1 parent 8714c2be57
commit 183789053e
20 files changed
+55 -49

No files matched your search

+4 -4
View File
@@ -85,12 +85,12 @@ T ConfigMgr::GetValueDefault(std::string const& name, T def) const
{
return _config.get<T>(bpt::ptree::path_type(name, '/'));
}
catch (bpt::ptree_bad_path)
catch (bpt::ptree_bad_path const&)
{
TC_LOG_WARN("server.loading", "Missing name %s in config file %s, add \"%s = %s\" to this file",
name.c_str(), _filename.c_str(), name.c_str(), std::to_string(def).c_str());
}
catch (bpt::ptree_bad_data)
catch (bpt::ptree_bad_data const&)
{
TC_LOG_ERROR("server.loading", "Bad value defined for name %s in config file %s, going to use %s instead",
name.c_str(), _filename.c_str(), std::to_string(def).c_str());
@@ -106,12 +106,12 @@ std::string ConfigMgr::GetValueDefault<std::string>(std::string const& name, std
{
return _config.get<std::string>(bpt::ptree::path_type(name, '/'));
}
catch (bpt::ptree_bad_path)
catch (bpt::ptree_bad_path const&)
{
TC_LOG_WARN("server.loading", "Missing name %s in config file %s, add \"%s = %s\" to this file",
name.c_str(), _filename.c_str(), name.c_str(), def.c_str());
}
catch (bpt::ptree_bad_data)
catch (bpt::ptree_bad_data const&)
{
TC_LOG_ERROR("server.loading", "Bad value defined for name %s in config file %s, going to use %s instead",
name.c_str(), _filename.c_str(), def.c_str());
+2 -2
View File
@@ -38,8 +38,8 @@
ULONG_PTR execeptionArgs[] = { reinterpret_cast<ULONG_PTR>(strdup(message)), reinterpret_cast<ULONG_PTR>(_ReturnAddress()) }; \
RaiseException(EXCEPTION_ASSERTION_FAILURE, 0, 2, execeptionArgs);
#else
// should be easily accessible in gdb
extern "C" TC_COMMON_API char const* TrinityAssertionFailedMessage = nullptr;
// should be easily accessible in gdb
extern "C" { TC_COMMON_API char const* TrinityAssertionFailedMessage = nullptr; }
#define Crash(message) \
TrinityAssertionFailedMessage = strdup(message); \
*((volatile int*)nullptr) = 0; \
+4 -3
View File
@@ -184,10 +184,11 @@ void AppenderConsole::_write(LogMessage const* message)
case LOG_LEVEL_FATAL:
index = 0;
break;
case LOG_LEVEL_ERROR: // No break on purpose
case LOG_LEVEL_ERROR:
/* fallthrough */
default:
index = 1;
break;
index = 1;
break;
}
SetColor(stdout_stream, _colors[index]);
+20 -20
View File
@@ -254,7 +254,7 @@ size_t utf8length(std::string& utf8str)
{
return utf8::distance(utf8str.c_str(), utf8str.c_str()+utf8str.size());
}
catch(std::exception)
catch(std::exception const&)
{
utf8str.clear();
return 0;
@@ -276,7 +276,7 @@ void utf8truncate(std::string& utf8str, size_t len)
char* oend = utf8::utf16to8(wstr.c_str(), wstr.c_str()+wstr.size(), &utf8str[0]);
utf8str.resize(oend-(&utf8str[0])); // remove unused tail
}
catch(std::exception)
catch(std::exception const&)
{
utf8str.clear();
}
@@ -291,7 +291,7 @@ bool Utf8toWStr(char const* utf8str, size_t csize, wchar_t* wstr, size_t& wsize)
wsize -= out.remaining(); // remaining unused space
wstr[wsize] = L'\0';
}
catch (std::exception)
catch (std::exception const&)
{
// Replace the converted string with an error message if there is enough space
// Otherwise just return an empty string
@@ -323,7 +323,7 @@ bool Utf8toWStr(const std::string& utf8str, std::wstring& wstr)
{
utf8::utf8to16(utf8str.c_str(), utf8str.c_str() + utf8str.size(), std::back_inserter(wstr));
}
catch (std::exception)
catch (std::exception const&)
{
wstr.clear();
return false;
@@ -346,7 +346,7 @@ bool WStrToUtf8(wchar_t* wstr, size_t size, std::string& utf8str)
}
utf8str = utf8str2;
}
catch(std::exception)
catch(std::exception const&)
{
utf8str.clear();
return false;
@@ -369,7 +369,7 @@ bool WStrToUtf8(std::wstring const& wstr, std::string& utf8str)
}
utf8str = utf8str2;
}
catch(std::exception)
catch(std::exception const&)
{
utf8str.clear();
return false;
@@ -397,31 +397,31 @@ std::wstring GetMainPartOfName(std::wstring const& wname, uint32 declension)
return wname;
// Important: end length must be <= MAX_INTERNAL_PLAYER_NAME-MAX_PLAYER_NAME (3 currently)
static std::wstring const a_End = { wchar_t(0x0430), wchar_t(0x0000) };
static std::wstring const o_End = { wchar_t(0x043E), wchar_t(0x0000) };
static std::wstring const ya_End = { wchar_t(0x044F), wchar_t(0x0000) };
static std::wstring const ie_End = { wchar_t(0x0435), wchar_t(0x0000) };
static std::wstring const i_End = { wchar_t(0x0438), wchar_t(0x0000) };
static std::wstring const a_End = { wchar_t(0x0430), wchar_t(0x0000) };
static std::wstring const o_End = { wchar_t(0x043E), wchar_t(0x0000) };
static std::wstring const ya_End = { wchar_t(0x044F), wchar_t(0x0000) };
static std::wstring const ie_End = { wchar_t(0x0435), wchar_t(0x0000) };
static std::wstring const i_End = { wchar_t(0x0438), wchar_t(0x0000) };
static std::wstring const yeru_End = { wchar_t(0x044B), wchar_t(0x0000) };
static std::wstring const u_End = { wchar_t(0x0443), wchar_t(0x0000) };
static std::wstring const yu_End = { wchar_t(0x044E), wchar_t(0x0000) };
static std::wstring const oj_End = { wchar_t(0x043E), wchar_t(0x0439), wchar_t(0x0000) };
static std::wstring const u_End = { wchar_t(0x0443), wchar_t(0x0000) };
static std::wstring const yu_End = { wchar_t(0x044E), wchar_t(0x0000) };
static std::wstring const oj_End = { wchar_t(0x043E), wchar_t(0x0439), wchar_t(0x0000) };
static std::wstring const ie_j_End = { wchar_t(0x0435), wchar_t(0x0439), wchar_t(0x0000) };
static std::wstring const io_j_End = { wchar_t(0x0451), wchar_t(0x0439), wchar_t(0x0000) };
static std::wstring const o_m_End = { wchar_t(0x043E), wchar_t(0x043C), wchar_t(0x0000) };
static std::wstring const o_m_End = { wchar_t(0x043E), wchar_t(0x043C), wchar_t(0x0000) };
static std::wstring const io_m_End = { wchar_t(0x0451), wchar_t(0x043C), wchar_t(0x0000) };
static std::wstring const ie_m_End = { wchar_t(0x0435), wchar_t(0x043C), wchar_t(0x0000) };
static std::wstring const soft_End = { wchar_t(0x044C), wchar_t(0x0000) };
static std::wstring const j_End = { wchar_t(0x0439), wchar_t(0x0000) };
static std::wstring const j_End = { wchar_t(0x0439), wchar_t(0x0000) };
static std::array<std::array<std::wstring const*, 7>, 6> const dropEnds = { {
static std::array<std::array<std::wstring const*, 7>, 6> const dropEnds = {{
{ &a_End, &o_End, &ya_End, &ie_End, &soft_End, &j_End, nullptr },
{ &a_End, &ya_End, &yeru_End, &i_End, nullptr, nullptr, nullptr },
{ &ie_End, &u_End, &yu_End, &i_End, nullptr, nullptr, nullptr },
{ &u_End, &yu_End, &o_End, &ie_End, &soft_End, &ya_End, &a_End },
{ &oj_End, &io_j_End, &ie_j_End, &o_m_End, &io_m_End, &ie_m_End, &yu_End },
{ &ie_End, &i_End, nullptr, nullptr, nullptr, nullptr, nullptr }
} };
}};
std::size_t const thisLen = wname.length();
std::array<std::wstring const*, 7> const& endings = dropEnds[declension];
@@ -432,8 +432,8 @@ std::wstring GetMainPartOfName(std::wstring const& wname, uint32 declension)
if (!(endLen <= thisLen))
continue;
if (wname.substr(thisLen - endLen, thisLen) == ending)
return wname.substr(0, thisLen - endLen);
if (wname.substr(thisLen-endLen, thisLen) == ending)
return wname.substr(0, thisLen-endLen);
}
return wname;
@@ -512,9 +512,8 @@ bool MySQLConnection::_HandleMySQLErrno(uint32 errNo, uint8 attempts /*= 5*/)
mysql_close(GetHandle());
m_Mysql = nullptr;
}
/*no break*/
}
/* fallthrough */
case CR_CONN_HOST_ERROR:
{
TC_LOG_INFO("sql.sql", "Attempting to reconnect to the MySQL server...");
@@ -306,7 +306,7 @@ UpdateResult UpdateFetcher::Update(bool const redundancyChecks,
{
case MODE_APPLY:
speed = Apply(availableQuery.first);
/*no break*/
/* fallthrough */
case MODE_REHASH:
UpdateEntry(file, speed);
break;
@@ -1196,7 +1196,7 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry %d SourceType %u Event %u Action %u has invoker cast action, but event does not provide any invoker!", e.entryOrGuid, e.GetScriptType(), e.GetEventType(), e.GetActionType());
return false;
}
// no break
/* fallthrough */
case SMART_ACTION_SELF_CAST:
case SMART_ACTION_ADD_AURA:
if (!IsSpellValid(e, e.action.cast.spell))
@@ -203,6 +203,7 @@ void BattlegroundAV::HandleQuestComplete(uint32 questid, Player* player)
case AV_QUEST_A_BOSS1:
case AV_QUEST_H_BOSS1:
m_Team_QuestStatus[team][4] += 9; //you can turn in 10 or 1 item..
/* fallthrough */
case AV_QUEST_A_BOSS2:
case AV_QUEST_H_BOSS2:
m_Team_QuestStatus[team][4]++;
@@ -746,11 +746,11 @@ bool BattlegroundSA::CanInteractWithObject(uint32 objectId)
case BG_SA_TITAN_RELIC:
if (GateStatus[BG_SA_ANCIENT_GATE] != BG_SA_GATE_DESTROYED || GateStatus[BG_SA_YELLOW_GATE] != BG_SA_GATE_DESTROYED)
return false;
// no break
/* fallthrough */
case BG_SA_CENTRAL_FLAG:
if (GateStatus[BG_SA_RED_GATE] != BG_SA_GATE_DESTROYED && GateStatus[BG_SA_PURPLE_GATE] != BG_SA_GATE_DESTROYED)
return false;
// no break
/* fallthrough */
case BG_SA_LEFT_FLAG:
case BG_SA_RIGHT_FLAG:
if (GateStatus[BG_SA_GREEN_GATE] != BG_SA_GATE_DESTROYED && GateStatus[BG_SA_BLUE_GATE] != BG_SA_GATE_DESTROYED)
+1 -1
View File
@@ -1983,7 +1983,7 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond) const
TC_LOG_ERROR("sql.sql", "%s has invalid state mask (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue2);
return false;
}
// intentional missing break
/* fallthrough */
case CONDITION_QUESTREWARDED:
case CONDITION_QUESTTAKEN:
case CONDITION_QUEST_NONE:
@@ -40,10 +40,11 @@ void LfgGroupData::SetState(LfgState state)
case LFG_STATE_NONE:
m_Dungeon = 0;
m_KicksLeft = LFG_GROUP_MAX_KICKS;
/* fallthrough */
case LFG_STATE_FINISHED_DUNGEON:
case LFG_STATE_DUNGEON:
m_OldState = state;
// No break on purpose
/* fallthrough */
default:
m_State = state;
}
+1 -1
View File
@@ -535,7 +535,7 @@ void LFGMgr::JoinLfg(Player* player, uint8 roles, LfgDungeonSet& dungeons, const
joinData.result = LFG_JOIN_DUNGEON_INVALID;
else
rDungeonId = (*dungeons.begin());
// No break on purpose (Random can only be dungeon or heroic dungeon)
/* fallthrough - Random can only be dungeon or heroic dungeon */
case LFG_TYPE_HEROIC:
case LFG_TYPE_DUNGEON:
if (isRaid)
@@ -40,10 +40,10 @@ void LfgPlayerData::SetState(LfgState state)
m_Roles = 0;
m_SelectedDungeons.clear();
m_Comment.clear();
// No break on purpose
/* fallthrough */
case LFG_STATE_DUNGEON:
m_OldState = state;
// No break on purpose
/* fallthrough */
default:
m_State = state;
}
@@ -433,6 +433,7 @@ void GameObject::Update(uint32 diff)
}
// NO BREAK for switch (m_lootState)
}
/* fallthrough */
case GO_READY:
{
if (m_respawnCompatibilityMode)
+1 -1
View File
@@ -7251,7 +7251,7 @@ float Unit::GetUnitSpellCriticalChance(Unit* victim, SpellInfo const* spellProto
break;
}
}
/// Intentional fallback. Calculate critical strike chance for both Ranged and Melee spells
/* fallthrough - Calculate critical strike chance for both Ranged and Melee spells*/
case SPELL_DAMAGE_CLASS_RANGED:
{
if (victim)
+1 -1
View File
@@ -291,7 +291,7 @@ void WorldSession::HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint32 spe
case REACT_PASSIVE: //passive
pet->AttackStop();
pet->ClearInPetCombat();
// no break;
/* fallthrough */
case REACT_DEFENSIVE: //recovery
case REACT_AGGRESSIVE: //activete
case REACT_ASSIST:
+1 -1
View File
@@ -2341,7 +2341,7 @@ void UnitAura::FillTargetMap(std::unordered_map<Unit*, uint8>& targets, Unit* ca
case SPELL_EFFECT_APPLY_AREA_AURA_PET:
if (!condList || sConditionMgr->IsObjectMeetToConditions(GetUnitOwner(), ref, *condList))
units.push_back(GetUnitOwner());
// no break
/* fallthrough */
case SPELL_EFFECT_APPLY_AREA_AURA_OWNER:
{
if (Unit* owner = GetUnitOwner()->GetCharmerOrOwner())
+4 -4
View File
@@ -3237,7 +3237,7 @@ void Spell::cancel()
{
case SPELL_STATE_PREPARING:
CancelGlobalCooldown();
// no break
/* fallthrough */
case SPELL_STATE_DELAYED:
SendInterrupted(0);
SendCastResult(SPELL_FAILED_INTERRUPTED);
@@ -5838,7 +5838,7 @@ SpellCastResult Spell::CheckCast(bool strict, uint32* param1 /*= nullptr*/, uint
case SUMMON_CATEGORY_PET:
if (!m_spellInfo->HasAttribute(SPELL_ATTR1_DISMISS_PET) && m_caster->GetPetGUID())
return SPELL_FAILED_ALREADY_HAVE_SUMMON;
// intentional missing break, check both GetPetGUID() and GetCharmGUID for SUMMON_CATEGORY_PET
/* fallthrough - check both GetPetGUID() and GetCharmGUID for SUMMON_CATEGORY_PET*/
case SUMMON_CATEGORY_PUPPET:
if (m_caster->GetCharmGUID())
return SPELL_FAILED_ALREADY_HAVE_CHARM;
@@ -6783,7 +6783,7 @@ SpellCastResult Spell::CheckItems(uint32* param1 /*= nullptr*/, uint32* param2 /
return SPELL_FAILED_DONT_REPORT;
}
}
// no break
/* fallthrough */
case SPELL_EFFECT_ENCHANT_ITEM_PRISMATIC:
{
Item* targetItem = m_targets.GetItemTarget();
@@ -8137,7 +8137,7 @@ bool WorldObjectSpellTargetCheck::operator()(WorldObject* target)
case TARGET_CHECK_RAID_CLASS:
if (_referer->getClass() != unitTarget->getClass())
return false;
// nobreak;
/* fallthrough */
case TARGET_CHECK_RAID:
if (unitTarget->IsTotem())
return false;
+3 -2
View File
@@ -184,7 +184,7 @@ uint32 SpellImplicitTargetInfo::GetExplicitTargetMask(bool& srcSet, bool& dstSet
targetMask = TARGET_FLAG_UNIT_PASSENGER;
break;
case TARGET_CHECK_RAID_CLASS:
// nobreak;
/* fallthrough */
default:
targetMask = TARGET_FLAG_UNIT;
break;
@@ -2363,6 +2363,7 @@ void SpellInfo::_LoadSpellSpecific()
/// @workaround For non-stacking tracking spells (We need generic solution)
if (Id == 30645) // Gas Cloud Tracking
return SPELL_SPECIFIC_NORMAL;
/* fallthrough */
case SPELL_AURA_TRACK_RESOURCES:
case SPELL_AURA_TRACK_STEALTHED:
return SPELL_SPECIFIC_TRACKER;
@@ -2755,7 +2756,7 @@ void SpellInfo::_LoadImmunityInfo()
immuneInfo.AuraTypeImmune.insert(SPELL_AURA_MOD_ROOT);
immuneInfo.AuraTypeImmune.insert(SPELL_AURA_MOD_CONFUSE);
immuneInfo.AuraTypeImmune.insert(SPELL_AURA_MOD_FEAR);
// no break intended
/* fallthrough */
case 61869: // Overload
case 63481:
case 61887: // Lightning Tendrils
@@ -57,6 +57,7 @@ void AddSC_tele_commandscript();
void AddSC_ticket_commandscript();
void AddSC_titles_commandscript();
void AddSC_wp_commandscript();
void AddSC_dev_commandscript();
// The name of this function should match:
// void Add${NameOfDirectory}Scripts()
@@ -103,4 +104,5 @@ void AddCommandsScripts()
AddSC_ticket_commandscript();
AddSC_titles_commandscript();
AddSC_wp_commandscript();
AddSC_dev_commandscript();
}