Core/Misc: Fix static analysis issues reported by Coverity

This commit is contained in:
jackpoz
2019-05-18 16:12:23 +02:00
parent a0d41c314f
commit a0bd68cf46
8 changed files with 10 additions and 3 deletions

View File

@@ -117,6 +117,7 @@ GameObject::GameObject() : WorldObject(false), MapObject(),
m_respawnTime = 0;
m_respawnDelayTime = 300;
m_despawnDelay = 0;
m_despawnRespawnTime = 0s;
m_lootState = GO_NOT_READY;
m_spawnedByDefault = true;
m_usetimes = 0;

View File

@@ -965,7 +965,7 @@ void MovementInfo::OutDebug()
WorldObject::WorldObject(bool isWorldObject) : Object(), WorldLocation(), LastUsedScriptID(0),
m_movementInfo(), m_name(), m_isActive(false), m_isFarVisible(false), m_isWorldObject(isWorldObject), m_zoneScript(nullptr),
m_transport(nullptr), m_zoneId(0), m_areaId(0), m_staticFloorZ(VMAP_INVALID_HEIGHT), m_currMap(nullptr), m_InstanceId(0),
m_transport(nullptr), m_zoneId(0), m_areaId(0), m_staticFloorZ(VMAP_INVALID_HEIGHT), m_outdoors(false), m_currMap(nullptr), m_InstanceId(0),
m_phaseMask(PHASEMASK_NORMAL), m_notifyflags(0)
{
m_serverSideVisibility.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_ALIVE | GHOST_VISIBILITY_GHOST);

View File

@@ -15748,7 +15748,7 @@ bool Player::GiveQuestSourceItem(Quest const* quest)
if (srcitem > 0)
{
// Don't give source item if it is the same item used to start the quest
ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(srcitem);
ItemTemplate const* itemTemplate = ASSERT_NOTNULL(sObjectMgr->GetItemTemplate(srcitem));
if (quest->GetQuestId() == itemTemplate->StartQuest)
return true;

View File

@@ -10934,6 +10934,7 @@ bool Unit::InitTamedPet(Pet* pet, uint8 level, uint32 spell_id)
else // creature died
{
TC_LOG_DEBUG("entities.unit", "DealDamageNotPlayer");
ASSERT_NODEBUGINFO(creature);
if (!creature->IsPet())
{

View File

@@ -378,6 +378,7 @@ WorldSocket::ReadDataHandlerResult WorldSocket::ReadDataHandler()
if (!_worldSession)
{
TC_LOG_ERROR("network.opcode", "ProcessIncoming: Client not authed opcode = %u", uint32(opcode));
delete packetToQueue;
return ReadDataHandlerResult::Error;
}
@@ -385,6 +386,7 @@ WorldSocket::ReadDataHandlerResult WorldSocket::ReadDataHandler()
if (!handler)
{
TC_LOG_ERROR("network.opcode", "No defined handler for opcode %s sent by %s", GetOpcodeNameForLogging(static_cast<OpcodeClient>(packet.GetOpcode())).c_str(), _worldSession->GetPlayerInfo().c_str());
delete packetToQueue;
return ReadDataHandlerResult::Error;
}

View File

@@ -2714,6 +2714,7 @@ DynObjAura::DynObjAura(AuraCreateInfo const& createInfo)
LoadScripts();
ASSERT(GetDynobjOwner());
ASSERT(GetDynobjOwner()->IsInWorld());
ASSERT(createInfo.Caster);
ASSERT(GetDynobjOwner()->GetMap() == createInfo.Caster->GetMap());
_InitEffects(createInfo._auraEffectMask, createInfo.Caster, createInfo.BaseAmount);
GetDynobjOwner()->SetAura(this);

View File

@@ -49,6 +49,8 @@ uint32 UpdateTime::GetTimeWeightedAverageUpdateTime() const
sum += diff * diff;
weightsum += diff;
}
if (weightsum == 0)
return 0;
return sum / weightsum;
}

View File

@@ -3729,7 +3729,7 @@ class spell_item_mirrens_drinking_hat : public SpellScript
void HandleScriptEffect(SpellEffIndex /* effIndex */)
{
uint32 spellId;
uint32 spellId = 0;
switch (urand(1, 6))
{
case 1: