From a68d9aed4c86157f15ac2d360edb1a7e6b65839d Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Sat, 4 Apr 2020 17:45:26 +0400 Subject: [PATCH] Fix issues, found by CoverityScan --- apps/opencs/view/render/instancemode.cpp | 10 ++++------ apps/openmw/mwgui/alchemywindow.cpp | 9 +++++---- apps/openmw/mwinput/inputmanagerimp.cpp | 2 -- components/esm/loadscpt.cpp | 6 ++++-- components/terrain/cellborder.hpp | 1 - 5 files changed, 13 insertions(+), 15 deletions(-) diff --git a/apps/opencs/view/render/instancemode.cpp b/apps/opencs/view/render/instancemode.cpp index 7c0020f1e..0d221beb1 100644 --- a/apps/opencs/view/render/instancemode.cpp +++ b/apps/opencs/view/render/instancemode.cpp @@ -719,16 +719,14 @@ void CSVRender::InstanceMode::dropInstance(DropMode dropMode, CSVRender::Object* mParentNode->accept(visitor); - for (osgUtil::LineSegmentIntersector::Intersections::iterator it = intersector->getIntersections().begin(); - it != intersector->getIntersections().end(); ++it) + osgUtil::LineSegmentIntersector::Intersections::iterator it = intersector->getIntersections().begin(); + if (it != intersector->getIntersections().end()) { osgUtil::LineSegmentIntersector::Intersection intersection = *it; ESM::Position position = object->getPosition(); object->setEdited (Object::Override_Position); position.pos[2] = intersection.getWorldIntersectPoint().z() + objectHeight; object->setPosition(position.pos); - - return; } } @@ -753,8 +751,8 @@ float CSVRender::InstanceMode::getDropHeight(DropMode dropMode, CSVRender::Objec mParentNode->accept(visitor); - for (osgUtil::LineSegmentIntersector::Intersections::iterator it = intersector->getIntersections().begin(); - it != intersector->getIntersections().end(); ++it) + osgUtil::LineSegmentIntersector::Intersections::iterator it = intersector->getIntersections().begin(); + if (it != intersector->getIntersections().end()) { osgUtil::LineSegmentIntersector::Intersection intersection = *it; float collisionLevel = intersection.getWorldIntersectPoint().z(); diff --git a/apps/openmw/mwgui/alchemywindow.cpp b/apps/openmw/mwgui/alchemywindow.cpp index 8dc44059f..bacd1c769 100644 --- a/apps/openmw/mwgui/alchemywindow.cpp +++ b/apps/openmw/mwgui/alchemywindow.cpp @@ -31,6 +31,7 @@ namespace MWGui { AlchemyWindow::AlchemyWindow() : WindowBase("openmw_alchemy_window.layout") + , mCurrentFilter(FilterType::ByName) , mModel(nullptr) , mSortModel(nullptr) , mAlchemy(new MWMechanics::Alchemy()) @@ -192,16 +193,16 @@ namespace MWGui std::set itemNames, itemEffects; for (size_t i = 0; i < mModel->getItemCount(); ++i) { - auto const& base = mModel->getItem(i).mBase; - if (base.getTypeName() != typeid(ESM::Ingredient).name()) + MWWorld::Ptr item = mModel->getItem(i).mBase; + if (item.getTypeName() != typeid(ESM::Ingredient).name()) continue; - itemNames.insert(base.getClass().getName(base)); + itemNames.insert(item.getClass().getName(item)); MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr(); auto const alchemySkill = player.getClass().getSkill(player, ESM::Skill::Alchemy); - auto const effects = MWMechanics::Alchemy::effectsDescription(base, alchemySkill); + auto const effects = MWMechanics::Alchemy::effectsDescription(item, alchemySkill); itemEffects.insert(effects.begin(), effects.end()); } diff --git a/apps/openmw/mwinput/inputmanagerimp.cpp b/apps/openmw/mwinput/inputmanagerimp.cpp index bef578ab6..acfe4f8cd 100644 --- a/apps/openmw/mwinput/inputmanagerimp.cpp +++ b/apps/openmw/mwinput/inputmanagerimp.cpp @@ -1146,8 +1146,6 @@ namespace MWInput default: return 0.f; } - - return 0.f; } void InputManager::displayOrientationChanged() diff --git a/components/esm/loadscpt.cpp b/components/esm/loadscpt.cpp index 8db284e1f..a7f348cb1 100644 --- a/components/esm/loadscpt.cpp +++ b/components/esm/loadscpt.cpp @@ -30,9 +30,11 @@ namespace ESM // The tmp buffer is a null-byte separated string list, we // just have to pick out one string at a time. char* str = tmp.data(); - if (!str && mVarNames.size() > 0) + if (!str) { - Log(Debug::Warning) << "SCVR with no variable names"; + if (mVarNames.size() > 0) + Log(Debug::Warning) << "SCVR with no variable names"; + return; } diff --git a/components/terrain/cellborder.hpp b/components/terrain/cellborder.hpp index 7770204e1..49759671f 100644 --- a/components/terrain/cellborder.hpp +++ b/components/terrain/cellborder.hpp @@ -31,7 +31,6 @@ namespace Terrain osg::Group *mRoot; CellGrid mCellBorderNodes; - int mBorderMask; }; }