From 923af4d2ea2555abaa2626a4f7e16c3f83c9ea46 Mon Sep 17 00:00:00 2001 From: firewave Date: Sun, 16 Jun 2024 02:26:34 +0200 Subject: [PATCH] fixed some `COPY_INSTEAD_OF_MOVE` Coverity warnings --- lib/checkother.cpp | 2 +- lib/cppcheck.cpp | 2 +- lib/preprocessor.cpp | 2 +- lib/valueflow.cpp | 4 ++-- lib/vf_settokenvalue.cpp | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 00e62c7301a..e35e5ccd428 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -2589,7 +2589,7 @@ void CheckOther::checkDuplicateExpression() followVar, &errorPath) && isWithoutSideEffects(tok->astOperand2())) - duplicateExpressionError(tok->astOperand2(), tok->astOperand1()->astOperand2(), tok, errorPath); + duplicateExpressionError(tok->astOperand2(), tok->astOperand1()->astOperand2(), tok, std::move(errorPath)); else if (tok->astOperand2() && isConstExpression(tok->astOperand1(), mSettings->library)) { auto checkDuplicate = [&](const Token* exp1, const Token* exp2, const Token* ast1) { if (isSameExpression(true, exp1, exp2, *mSettings, true, true, &errorPath) && diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index 9cbe1245fd3..ee8fa685325 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -1629,7 +1629,7 @@ void CppCheck::reportErr(const ErrorMessage &msg) if (!remark.empty()) { ErrorMessage msg2(msg); - msg2.remark = remark; + msg2.remark = std::move(remark); mErrorLogger.reportErr(msg2); } else { mErrorLogger.reportErr(msg); diff --git a/lib/preprocessor.cpp b/lib/preprocessor.cpp index 06d01cd1406..c665f7ed726 100644 --- a/lib/preprocessor.cpp +++ b/lib/preprocessor.cpp @@ -163,7 +163,7 @@ static std::string getRelativeFilename(const simplecpp::Token* tok, const Settin } } } - return Path::simplifyPath(relativeFilename); + return Path::simplifyPath(std::move(relativeFilename)); } static void addInlineSuppressions(const simplecpp::TokenList &tokens, const Settings &settings, SuppressionList &suppressions, std::list &bad) diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index cdb57afb56c..fe6b4d045d4 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -8020,7 +8020,7 @@ static void valueFlowContainerSize(const TokenList& tokenlist, ValueFlow::Value value(Token::getStrLength(containerTok->tokAt(2))); value.valueType = ValueFlow::Value::ValueType::CONTAINER_SIZE; value.setKnown(); - valueFlowForward(containerTok->next(), containerTok, value, tokenlist, errorLogger, settings); + valueFlowForward(containerTok->next(), containerTok, std::move(value), tokenlist, errorLogger, settings); } } else if (Token::Match(tok->previous(), ">|return (|{") && astIsContainer(tok) && getLibraryContainer(tok)->size_templateArgNo < 0) { std::vector values; @@ -8084,7 +8084,7 @@ static void valueFlowContainerSize(const TokenList& tokenlist, Token* next = nextAfterAstRightmostLeaf(tok); if (!next) next = tok->next(); - valueFlowForward(next, containerTok, value, tokenlist, errorLogger, settings); + valueFlowForward(next, containerTok, std::move(value), tokenlist, errorLogger, settings); } } } diff --git a/lib/vf_settokenvalue.cpp b/lib/vf_settokenvalue.cpp index 5d1137bd2dd..b869c5427fa 100644 --- a/lib/vf_settokenvalue.cpp +++ b/lib/vf_settokenvalue.cpp @@ -445,7 +445,7 @@ namespace ValueFlow else if (astIsPointer(tok) && Token::Match(parent, "+|-") && (parent->astOperand2() == nullptr || !astIsPointer(parent->astOperand2())) && value.isIntValue() && value.isImpossible() && value.intvalue == 0) { - setTokenValue(parent, value, settings); + setTokenValue(parent, std::move(value), settings); } // Calculations..