From a06046264c3a35b039f307faf3825c79cb0c084c Mon Sep 17 00:00:00 2001 From: firewave Date: Thu, 7 Aug 2025 14:08:07 +0200 Subject: [PATCH] fixed some `Variable copied when it could be moved` Coverity warnings --- lib/library.cpp | 3 ++- lib/symboldatabase.cpp | 3 ++- lib/valueflow.cpp | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/library.cpp b/lib/library.cpp index 1000b4d77f6..f786584bdf2 100644 --- a/lib/library.cpp +++ b/lib/library.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include "xml.h" @@ -241,7 +242,7 @@ Library::Error Library::load(const char exename[], const char path[], bool debug if (mData->mFiles.find(absolute_path) == mData->mFiles.end()) { Error err = load(doc); if (err.errorcode == ErrorCode::OK) - mData->mFiles.insert(absolute_path); + mData->mFiles.insert(std::move(absolute_path)); return err; } diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index f547d028bbc..6d723b60246 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -51,6 +51,7 @@ #include #include #include +#include //--------------------------------------------------------------------------- SymbolDatabase::SymbolDatabase(Tokenizer& tokenizer) @@ -2212,7 +2213,7 @@ void SymbolDatabase::debugSymbolDatabase() const } errorPath.emplace_back(tok, ""); mErrorLogger.reportErr( - {errorPath, &mTokenizer.list, Severity::debug, "valueType", msg, CWE{0}, Certainty::normal}); + {std::move(errorPath), &mTokenizer.list, Severity::debug, "valueType", msg, CWE{0}, Certainty::normal}); } } } diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 6ec2df39b57..070aa56742e 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -128,6 +128,7 @@ #include #include #include +#include #include static void bailoutInternal(const std::string& type, @@ -7275,7 +7276,7 @@ static void valueFlowDebug(TokenList& tokenlist, ErrorLogger& errorLogger, const ErrorPath errorPath = v.errorPath; errorPath.insert(errorPath.end(), v.debugPath.cbegin(), v.debugPath.cend()); errorPath.emplace_back(tok, ""); - errorLogger.reportErr({errorPath, &tokenlist, Severity::debug, "valueFlow", msg, CWE{0}, Certainty::normal}); + errorLogger.reportErr({std::move(errorPath), &tokenlist, Severity::debug, "valueFlow", msg, CWE{0}, Certainty::normal}); } } }