From 225e834b88a9f24e0e2f04b11a9a94ea0b508c68 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Fri, 2 Feb 2024 09:28:19 +0400 Subject: [PATCH 1/2] Fix some Coverity Scan complaints --- apps/mwiniimporter/importer.cpp | 2 +- apps/openmw/mwgui/journalwindow.cpp | 6 +++--- apps/openmw/mwlua/animationbindings.cpp | 2 +- apps/openmw/mwmechanics/character.cpp | 2 +- apps/openmw/mwrender/npcanimation.cpp | 2 +- apps/openmw/mwworld/globals.cpp | 2 +- apps/openmw/mwworld/magiceffects.cpp | 2 +- components/lua/scriptscontainer.cpp | 10 +++++----- components/shader/shadermanager.cpp | 6 +++--- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/apps/mwiniimporter/importer.cpp b/apps/mwiniimporter/importer.cpp index 7b3bcc3f1c..8c7c238b4a 100644 --- a/apps/mwiniimporter/importer.cpp +++ b/apps/mwiniimporter/importer.cpp @@ -584,7 +584,7 @@ void MwIniImporter::importGameFiles( reader.close(); } - auto sortedFiles = dependencySort(unsortedFiles); + auto sortedFiles = dependencySort(std::move(unsortedFiles)); // hard-coded dependency Morrowind - Tribunal - Bloodmoon if (findString(sortedFiles, "Morrowind.esm") != sortedFiles.end()) diff --git a/apps/openmw/mwgui/journalwindow.cpp b/apps/openmw/mwgui/journalwindow.cpp index 0cc5a00831..574c425d3e 100644 --- a/apps/openmw/mwgui/journalwindow.cpp +++ b/apps/openmw/mwgui/journalwindow.cpp @@ -126,7 +126,7 @@ namespace MWGui::BookPage::ClickCallback callback = [this](intptr_t linkId) { notifyTopicClicked(linkId); }; getPage(LeftBookPage)->adviseLinkClicked(callback); - getPage(RightBookPage)->adviseLinkClicked(callback); + getPage(RightBookPage)->adviseLinkClicked(std::move(callback)); getPage(LeftBookPage)->eventMouseWheel += MyGUI::newDelegate(this, &JournalWindowImpl::notifyMouseWheel); @@ -140,7 +140,7 @@ namespace getPage(LeftTopicIndex)->adviseLinkClicked(callback); getPage(CenterTopicIndex)->adviseLinkClicked(callback); - getPage(RightTopicIndex)->adviseLinkClicked(callback); + getPage(RightTopicIndex)->adviseLinkClicked(std::move(callback)); } adjustButton(PrevPageBTN); @@ -376,7 +376,7 @@ namespace setVisible(PageTwoNum, relPages > 1); getPage(LeftBookPage)->showPage((relPages > 0) ? book : Book(), page + 0); - getPage(RightBookPage)->showPage((relPages > 0) ? book : Book(), page + 1); + getPage(RightBookPage)->showPage((relPages > 0) ? std::move(book) : Book(), page + 1); setText(PageOneNum, page + 1); setText(PageTwoNum, page + 2); diff --git a/apps/openmw/mwlua/animationbindings.cpp b/apps/openmw/mwlua/animationbindings.cpp index ecd1e96dbb..a1f472908c 100644 --- a/apps/openmw/mwlua/animationbindings.cpp +++ b/apps/openmw/mwlua/animationbindings.cpp @@ -119,7 +119,7 @@ namespace MWLua if (asTable) { AnimationPriorities priorities = AnimationPriorities(Priority::Priority_Default); - for (auto entry : asTable.value()) + for (const auto& entry : asTable.value()) { if (!entry.first.is() || !entry.second.is()) throw std::runtime_error("Priority table must consist of BoneGroup-Priority pairs only"); diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index 8d69da2c43..7b305ac69a 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -711,7 +711,7 @@ namespace MWMechanics mMovementAnimationHasMovement = true; clearStateAnimation(mCurrentMovement); - mCurrentMovement = movementAnimName; + mCurrentMovement = std::move(movementAnimName); // For non-flying creatures, MW uses the Walk animation to calculate the animation velocity // even if we are running. This must be replicated, otherwise the observed speed would differ drastically. diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index b9ea257c9f..1467f8e737 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -844,7 +844,7 @@ namespace MWRender } } } - SceneUtil::ForceControllerSourcesVisitor assignVisitor(src); + SceneUtil::ForceControllerSourcesVisitor assignVisitor(std::move(src)); node->accept(assignVisitor); } else diff --git a/apps/openmw/mwworld/globals.cpp b/apps/openmw/mwworld/globals.cpp index 264109d17f..4977df56c0 100644 --- a/apps/openmw/mwworld/globals.cpp +++ b/apps/openmw/mwworld/globals.cpp @@ -99,7 +99,7 @@ namespace MWWorld global.load(reader, isDeleted); if (const auto iter = mVariables.find(global.mId); iter != mVariables.end()) - iter->second = global; + iter->second = std::move(global); return true; } diff --git a/apps/openmw/mwworld/magiceffects.cpp b/apps/openmw/mwworld/magiceffects.cpp index 8b7ad79db2..4ff0e60c46 100644 --- a/apps/openmw/mwworld/magiceffects.cpp +++ b/apps/openmw/mwworld/magiceffects.cpp @@ -133,7 +133,7 @@ namespace MWWorld continue; ESM::ActiveSpells::ActiveSpellParams params; params.mId = id; - params.mDisplayName = name; + params.mDisplayName = std::move(name); params.mCasterActorId = creatureStats.mActorId; params.mType = ESM::ActiveSpells::Type_Enchantment; params.mWorsenings = -1; diff --git a/components/lua/scriptscontainer.cpp b/components/lua/scriptscontainer.cpp index 2a1a755422..9b4a119ba4 100644 --- a/components/lua/scriptscontainer.cpp +++ b/components/lua/scriptscontainer.cpp @@ -115,20 +115,20 @@ namespace LuaUtil std::string_view handlerName = cast(key); sol::function fn = cast(handler); if (handlerName == HANDLER_INIT) - onInit = fn; + onInit = std::move(fn); else if (handlerName == HANDLER_LOAD) - onLoad = fn; + onLoad = std::move(fn); else if (handlerName == HANDLER_SAVE) - script.mOnSave = fn; + script.mOnSave = std::move(fn); else if (handlerName == HANDLER_INTERFACE_OVERRIDE) - script.mOnOverride = fn; + script.mOnOverride = std::move(fn); else { auto it = mEngineHandlers.find(handlerName); if (it == mEngineHandlers.end()) Log(Debug::Error) << "Not supported handler '" << handlerName << "' in " << debugName; else - insertHandler(it->second->mList, scriptId, fn); + insertHandler(it->second->mList, scriptId, std::move(fn)); } } } diff --git a/components/shader/shadermanager.cpp b/components/shader/shadermanager.cpp index 612552dabc..96d6346149 100644 --- a/components/shader/shadermanager.cpp +++ b/components/shader/shadermanager.cpp @@ -503,7 +503,7 @@ namespace Shader { break; } - shaderSource = source; + shaderSource = std::move(source); std::vector linkedShaderNames; if (!Manager.createSourceFromTemplate( @@ -554,7 +554,7 @@ namespace Shader if (!addLineDirectivesAfterConditionalBlocks(source) || !parseIncludes(mPath, source, templateName, fileNumber, {}, insertedPaths)) return nullptr; - mHotReloadManager->templateIncludedFiles[templateName] = insertedPaths; + mHotReloadManager->templateIncludedFiles[templateName] = std::move(insertedPaths); templateIt = mShaderTemplates.insert(std::make_pair(templateName, source)).first; } @@ -597,7 +597,7 @@ namespace Shader if (!vert || !frag) throw std::runtime_error("failed initializing shader: " + templateName); - return getProgram(vert, frag, programTemplate); + return getProgram(std::move(vert), std::move(frag), programTemplate); } osg::ref_ptr ShaderManager::getProgram(osg::ref_ptr vertexShader, From 69936f35376cb326b0590e198d0dab1eb8e41b2c Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Fri, 2 Feb 2024 09:45:42 +0400 Subject: [PATCH 2/2] Move TextureData --- apps/openmw/mwlua/uibindings.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwlua/uibindings.cpp b/apps/openmw/mwlua/uibindings.cpp index 30f190ad38..32d6db2539 100644 --- a/apps/openmw/mwlua/uibindings.cpp +++ b/apps/openmw/mwlua/uibindings.cpp @@ -242,7 +242,7 @@ namespace MWLua sol::object size = LuaUtil::getFieldOrNil(options, "size"); if (size.is()) data.mSize = size.as(); - return luaManager->uiResourceManager()->registerTexture(data); + return luaManager->uiResourceManager()->registerTexture(std::move(data)); }; api["screenSize"] = []() { return osg::Vec2f(Settings::video().mResolutionX, Settings::video().mResolutionY); };