diff options
author | jackpoz <giacomopoz@gmail.com> | 2017-07-16 18:16:48 +0200 |
---|---|---|
committer | jackpoz <giacomopoz@gmail.com> | 2017-07-16 18:20:29 +0200 |
commit | 9cf4dd7345b7f05db834fd48a9f0a135f1884d70 (patch) | |
tree | 55067acd31a0cdd14d23f040a3ac77dd6fbd4f00 /src | |
parent | f44956b051030f57378489b8c82517919d59955e (diff) |
Core/Misc: Fix static analysis issues
Diffstat (limited to 'src')
-rw-r--r-- | src/common/Collision/Maps/MapTree.h | 2 | ||||
-rw-r--r-- | src/common/Debugging/WheatyExceptionReport.cpp | 13 | ||||
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartScript.cpp | 22 | ||||
-rw-r--r-- | src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp | 6 | ||||
-rw-r--r-- | src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp | 3 | ||||
-rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 8 | ||||
-rw-r--r-- | src/server/game/Globals/ObjectMgr.cpp | 2 | ||||
-rw-r--r-- | src/server/game/Groups/Group.cpp | 3 | ||||
-rw-r--r-- | src/server/game/Skills/SkillExtraItems.cpp | 7 | ||||
-rw-r--r-- | src/server/game/Spells/Spell.cpp | 1 | ||||
-rw-r--r-- | src/server/game/Spells/SpellInfo.cpp | 7 | ||||
-rw-r--r-- | src/server/scripts/Commands/cs_ban.cpp | 3 | ||||
-rw-r--r-- | src/server/scripts/Commands/cs_disable.cpp | 6 |
13 files changed, 35 insertions, 48 deletions
diff --git a/src/common/Collision/Maps/MapTree.h b/src/common/Collision/Maps/MapTree.h index 6dc32c1241a..3df75551018 100644 --- a/src/common/Collision/Maps/MapTree.h +++ b/src/common/Collision/Maps/MapTree.h @@ -34,7 +34,7 @@ namespace VMAP struct TC_COMMON_API LocationInfo { - LocationInfo(): hitInstance(nullptr), hitModel(nullptr), ground_Z(-G3D::finf()) { } + LocationInfo(): rootId(-1), hitInstance(nullptr), hitModel(nullptr), ground_Z(-G3D::finf()) { } int32 rootId; ModelInstance const* hitInstance; GroupModel const* hitModel; diff --git a/src/common/Debugging/WheatyExceptionReport.cpp b/src/common/Debugging/WheatyExceptionReport.cpp index 5b6e9e76ebc..8211f4d6151 100644 --- a/src/common/Debugging/WheatyExceptionReport.cpp +++ b/src/common/Debugging/WheatyExceptionReport.cpp @@ -126,7 +126,7 @@ PEXCEPTION_POINTERS pExceptionInfo) ++pos; TCHAR crash_folder_path[MAX_PATH]; - sprintf(crash_folder_path, "%s\\%s", module_folder_name, CrashFolder); + sprintf_s(crash_folder_path, "%s\\%s", module_folder_name, CrashFolder); if (!CreateDirectory(crash_folder_path, NULL)) { if (GetLastError() != ERROR_ALREADY_EXISTS) @@ -1385,12 +1385,15 @@ int __cdecl WheatyExceptionReport::StackLog(const TCHAR * format, va_list argptr int __cdecl WheatyExceptionReport::HeapLog(const TCHAR * format, va_list argptr) { - int retValue; + int retValue = 0; DWORD cbWritten; TCHAR* szBuff = (TCHAR*)malloc(sizeof(TCHAR) * WER_LARGE_BUFFER_SIZE); - retValue = vsprintf(szBuff, format, argptr); - WriteFile(m_hReportFile, szBuff, retValue * sizeof(TCHAR), &cbWritten, 0); - free(szBuff); + if (szBuff != nullptr) + { + retValue = vsprintf(szBuff, format, argptr); + WriteFile(m_hReportFile, szBuff, retValue * sizeof(TCHAR), &cbWritten, 0); + free(szBuff); + } return retValue; } diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 7b7bb00416d..03ad4df397a 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -1039,8 +1039,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u else creature->DespawnOrUnsummon(respawnDelay); } - else if (GameObject* go = target->ToGameObject()) - go->SetRespawnTime(respawnDelay); + else if (GameObject* goTarget = target->ToGameObject()) + goTarget->SetRespawnTime(respawnDelay); } break; } @@ -1588,10 +1588,10 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u if (IsSmart(creature)) ENSURE_AI(SmartAI, creature->AI())->SetScript9(e, e.action.timedActionList.id, GetLastInvoker()); } - else if (GameObject* go = target->ToGameObject()) + else if (GameObject* goTarget = target->ToGameObject()) { - if (IsSmartGO(go)) - ENSURE_AI(SmartGameObjectAI, go->AI())->SetScript9(e, e.action.timedActionList.id, GetLastInvoker()); + if (IsSmartGO(goTarget)) + ENSURE_AI(SmartGameObjectAI, goTarget->AI())->SetScript9(e, e.action.timedActionList.id, GetLastInvoker()); } } break; @@ -1675,10 +1675,10 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u if (IsSmart(creature)) ENSURE_AI(SmartAI, creature->AI())->SetScript9(e, id, GetLastInvoker()); } - else if (GameObject* go = target->ToGameObject()) + else if (GameObject* goTarget = target->ToGameObject()) { - if (IsSmartGO(go)) - ENSURE_AI(SmartGameObjectAI, go->AI())->SetScript9(e, id, GetLastInvoker()); + if (IsSmartGO(goTarget)) + ENSURE_AI(SmartGameObjectAI, goTarget->AI())->SetScript9(e, id, GetLastInvoker()); } } break; @@ -1699,10 +1699,10 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u if (IsSmart(creature)) ENSURE_AI(SmartAI, creature->AI())->SetScript9(e, id, GetLastInvoker()); } - else if (GameObject* go = target->ToGameObject()) + else if (GameObject* goTarget = target->ToGameObject()) { - if (IsSmartGO(go)) - ENSURE_AI(SmartGameObjectAI, go->AI())->SetScript9(e, id, GetLastInvoker()); + if (IsSmartGO(goTarget)) + ENSURE_AI(SmartGameObjectAI, goTarget->AI())->SetScript9(e, id, GetLastInvoker()); } } break; diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp index e1d1394cb05..a686d52cda2 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp @@ -529,8 +529,7 @@ bool BattlegroundEY::SetupBattleground() TC_LOG_ERROR("bg.battleground", "BattlegroundEY: Could not spawn Speedbuff Fel Reaver."); } - WorldSafeLocsEntry const* sg = nullptr; - sg = sWorldSafeLocsStore.LookupEntry(EY_GRAVEYARD_MAIN_ALLIANCE); + WorldSafeLocsEntry const* sg = sWorldSafeLocsStore.LookupEntry(EY_GRAVEYARD_MAIN_ALLIANCE); if (!sg || !AddSpiritGuide(EY_SPIRIT_MAIN_ALLIANCE, sg->x, sg->y, sg->z, 3.124139f, TEAM_ALLIANCE)) { TC_LOG_ERROR("sql.sql", "BatteGroundEY: Failed to spawn spirit guide. The battleground was not created."); @@ -774,8 +773,7 @@ void BattlegroundEY::EventTeamCapturedPoint(Player* player, uint32 Point) if (BgCreatures[Point]) DelCreature(Point); - WorldSafeLocsEntry const* sg = nullptr; - sg = sWorldSafeLocsStore.LookupEntry(m_CapturingPointTypes[Point].GraveyardId); + WorldSafeLocsEntry const* sg = sWorldSafeLocsStore.LookupEntry(m_CapturingPointTypes[Point].GraveyardId); if (!sg || !AddSpiritGuide(Point, sg->x, sg->y, sg->z, 3.124139f, GetTeamIndexByTeamId(Team))) TC_LOG_ERROR("bg.battleground", "BatteGroundEY: Failed to spawn spirit guide. point: %u, team: %u, graveyard_id: %u", Point, Team, m_CapturingPointTypes[Point].GraveyardId); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp index b28f31cd09c..90fd95b5780 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp @@ -198,8 +198,7 @@ bool BattlegroundSA::ResetObjs() //Graveyards for (uint8 i = 0; i < BG_SA_MAX_GY; i++) { - WorldSafeLocsEntry const* sg = nullptr; - sg = sWorldSafeLocsStore.LookupEntry(BG_SA_GYEntries[i]); + WorldSafeLocsEntry const* sg = sWorldSafeLocsStore.LookupEntry(BG_SA_GYEntries[i]); if (!sg) { diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 733c3231915..3e236c7266f 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -2607,7 +2607,7 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit* victim, SpellInfo const* spellInfo SpellMissInfo Unit::MagicSpellHitResult(Unit* victim, SpellInfo const* spellInfo) const { // Can`t miss on dead target (on skinning for example) - if ((!victim->IsAlive() && victim->GetTypeId() != TYPEID_PLAYER)) + if (!victim->IsAlive() && victim->GetTypeId() != TYPEID_PLAYER) return SPELL_MISS_NONE; SpellSchoolMask schoolMask = spellInfo->GetSchoolMask(); @@ -5675,8 +5675,6 @@ ReputationRank Unit::GetFactionReactionTo(FactionTemplateEntry const* factionTem return REP_NEUTRAL; FactionTemplateEntry const* targetFactionTemplateEntry = target->GetFactionTemplateEntry(); - if (!targetFactionTemplateEntry) - return REP_NEUTRAL; if (Player const* targetPlayerOwner = target->GetAffectingPlayer()) { @@ -5728,7 +5726,7 @@ bool Unit::IsFriendlyTo(Unit const* unit) const bool Unit::IsHostileToPlayers() const { FactionTemplateEntry const* my_faction = GetFactionTemplateEntry(); - if (!my_faction || !my_faction->faction) + if (!my_faction->faction) return false; FactionEntry const* raw_faction = sFactionStore.LookupEntry(my_faction->faction); @@ -5741,7 +5739,7 @@ bool Unit::IsHostileToPlayers() const bool Unit::IsNeutralToAll() const { FactionTemplateEntry const* my_faction = GetFactionTemplateEntry(); - if (!my_faction || !my_faction->faction) + if (!my_faction->faction) return true; FactionEntry const* raw_faction = sFactionStore.LookupEntry(my_faction->faction); diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 1b7713ab363..c6cb3c06b78 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -831,7 +831,7 @@ void ObjectMgr::CheckCreatureTemplate(CreatureTemplate const* cInfo) TC_LOG_ERROR("sql.sql", "Creature (Entry: %u) lists non-existing Modelid1 id (%u), this can crash the client.", cInfo->Entry, cInfo->Modelid1); const_cast<CreatureTemplate*>(cInfo)->Modelid1 = 0; } - else if (!displayScaleEntry) + else displayScaleEntry = displayEntry; CreatureModelInfo const* modelInfo = GetCreatureModelInfo(cInfo->Modelid1); diff --git a/src/server/game/Groups/Group.cpp b/src/server/game/Groups/Group.cpp index 76b7de68ea9..79df88b61a5 100644 --- a/src/server/game/Groups/Group.cpp +++ b/src/server/game/Groups/Group.cpp @@ -1534,8 +1534,7 @@ void Group::CountTheRoll(Rolls::iterator rollI, Map* allowedMap) // remove is_blocked so that the item is lootable by all players LootItem* item = &(roll->itemSlot >= roll->getLoot()->items.size() ? roll->getLoot()->quest_items[roll->itemSlot - roll->getLoot()->items.size()] : roll->getLoot()->items[roll->itemSlot]); - if (item) - item->is_blocked = false; + item->is_blocked = false; } RollId.erase(rollI); diff --git a/src/server/game/Skills/SkillExtraItems.cpp b/src/server/game/Skills/SkillExtraItems.cpp index 3b066e71b8b..48eda06756e 100644 --- a/src/server/game/Skills/SkillExtraItems.cpp +++ b/src/server/game/Skills/SkillExtraItems.cpp @@ -208,9 +208,6 @@ bool CanCreatePerfectItem(Player* player, uint32 spellId, float &perfectCreateCh return false; SkillPerfectItemEntry const* thisEntry = &ret->second; - // lack of entry means no perfection proc possible - if (!thisEntry) - return false; // if you don't have the spell needed, then no procs for you if (!player->HasSpell(thisEntry->requiredSpecialization)) @@ -233,10 +230,6 @@ bool CanCreateExtraItems(Player* player, uint32 spellId, float &additionalChance SkillExtraItemEntry const* specEntry = &ret->second; - // if no entry, then no extra items can be created - if (!specEntry) - return false; - // the player doesn't have the required specialization, return false if (!player->HasSpell(specEntry->requiredSpecialization)) return false; diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index e56c573a43c..48dddb23ca5 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -549,6 +549,7 @@ m_caster((info->HasAttribute(SPELL_ATTR6_CAST_BY_CHARMER) && caster->GetCharmerO m_referencedFromCurrentSpell = false; m_executedCurrently = false; m_needComboPoints = m_spellInfo->NeedsComboPoints(); + m_comboTarget = nullptr; m_comboPointGain = 0; m_delayStart = 0; m_delayAtDamageCount = 0; diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp index 9e393f2fcad..ff84ca7acca 100644 --- a/src/server/game/Spells/SpellInfo.cpp +++ b/src/server/game/Spells/SpellInfo.cpp @@ -1345,10 +1345,9 @@ bool SpellInfo::CanPierceImmuneAura(SpellInfo const* auraSpellInfo) const if (HasAttribute(SPELL_ATTR1_UNAFFECTED_BY_SCHOOL_IMMUNE) || HasAttribute(SPELL_ATTR2_UNAFFECTED_BY_AURA_SCHOOL_IMMUNE)) { // ...but not these (Divine shield, Ice block, Cyclone and Banish for example) - if (!auraSpellInfo || - (auraSpellInfo->Mechanic != MECHANIC_IMMUNE_SHIELD && - auraSpellInfo->Mechanic != MECHANIC_INVULNERABILITY && - (auraSpellInfo->Mechanic != MECHANIC_BANISH || (IsRankOf(auraSpellInfo) && auraSpellInfo->Dispel != DISPEL_NONE)))) // Banish shouldn't be immune to itself, but Cyclone should + if (auraSpellInfo->Mechanic != MECHANIC_IMMUNE_SHIELD && + auraSpellInfo->Mechanic != MECHANIC_INVULNERABILITY && + (auraSpellInfo->Mechanic != MECHANIC_BANISH || (IsRankOf(auraSpellInfo) && auraSpellInfo->Dispel != DISPEL_NONE)))) // Banish shouldn't be immune to itself, but Cyclone should return true; } diff --git a/src/server/scripts/Commands/cs_ban.cpp b/src/server/scripts/Commands/cs_ban.cpp index 5c390a34e11..137620123a6 100644 --- a/src/server/scripts/Commands/cs_ban.cpp +++ b/src/server/scripts/Commands/cs_ban.cpp @@ -587,8 +587,7 @@ public: static bool HandleBanListIPCommand(ChatHandler* handler, char const* args) { - PreparedStatement* stmt = nullptr; - stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_EXPIRED_IP_BANS); + PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_EXPIRED_IP_BANS); LoginDatabase.Execute(stmt); char* filterStr = strtok((char*)args, " "); diff --git a/src/server/scripts/Commands/cs_disable.cpp b/src/server/scripts/Commands/cs_disable.cpp index bc80d3d6fd0..b8d1116574d 100644 --- a/src/server/scripts/Commands/cs_disable.cpp +++ b/src/server/scripts/Commands/cs_disable.cpp @@ -187,8 +187,7 @@ public: break; } - PreparedStatement* stmt = nullptr; - stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_DISABLES); + PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_DISABLES); stmt->setUInt32(0, entry); stmt->setUInt8(1, disableType); PreparedQueryResult result = WorldDatabase.Query(stmt); @@ -313,8 +312,7 @@ public: break; } - PreparedStatement* stmt = nullptr; - stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_DISABLES); + PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_DISABLES); stmt->setUInt32(0, entry); stmt->setUInt8(1, disableType); PreparedQueryResult result = WorldDatabase.Query(stmt); |