From 3d61334a8cf1caf5d497f88331bd973032d34625 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 26 Jan 2009 18:32:00 +0000 Subject: [PATCH] errmsg: Moved 'function parameter parname is passed by value' to the style checks --- src/cppcheck.cpp | 2 +- src/errormessage.h | 4 ++-- tools/errmsg.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cppcheck.cpp b/src/cppcheck.cpp index 58736be0c..d76760173 100644 --- a/src/cppcheck.cpp +++ b/src/cppcheck.cpp @@ -389,7 +389,7 @@ void CppCheck::checkFile(const std::string &code, const char FileName[]) checkOther.CheckStructMemberUsage(); // Check if a constant function parameter is passed by value - if (ErrorMessage::passedByValue()) + if (ErrorMessage::passedByValue(_settings)) checkOther.CheckConstantFunctionParameter(); // Variable scope (check if the scope could be limited) diff --git a/src/errormessage.h b/src/errormessage.h index 9ba44e9ce..c251e965a 100644 --- a/src/errormessage.h +++ b/src/errormessage.h @@ -251,9 +251,9 @@ public: { return msg1(tokenizer, Location) + "Function parameter '" + parname + "' is passed by value. It could be passed by reference instead."; } - static bool passedByValue() + static bool passedByValue(const Settings &s) { - return true; + return s._checkCodingStyle; } static std::string constStatement(const Tokenizer *tokenizer, const Token *Location, const std::string &type) diff --git a/tools/errmsg.cpp b/tools/errmsg.cpp index f6073e6ff..4adb0d60d 100644 --- a/tools/errmsg.cpp +++ b/tools/errmsg.cpp @@ -86,7 +86,7 @@ int main() err.push_back(Message("udivError", Message::always, "Unsigned division. The result will be wrong.")); err.push_back(Message("udivWarning", Message::style_all, "Warning: Division with signed and unsigned operators")); err.push_back(Message("unusedStructMember", Message::style, "struct or union member '%1::%2' is never used", "structname", "varname")); - err.push_back(Message("passedByValue", Message::always, "Function parameter '%1' is passed by value. It could be passed by reference instead.", "parname")); + err.push_back(Message("passedByValue", Message::style, "Function parameter '%1' is passed by value. It could be passed by reference instead.", "parname")); err.push_back(Message("constStatement", Message::style, "Redundant code: Found a statement that begins with %1 constant", "type")); err.push_back(Message("charArrayIndex", Message::style, "Warning - using char variable as array index")); err.push_back(Message("charBitOp", Message::style, "Warning - using char variable in bit operation"));