diff --git a/cfg/std.cfg b/cfg/std.cfg index f1635f5be..dbec3a269 100644 --- a/cfg/std.cfg +++ b/cfg/std.cfg @@ -85,7 +85,6 @@ - true @@ -2733,14 +2732,12 @@ - true - true diff --git a/lib/checkother.cpp b/lib/checkother.cpp index d2adeb0d3..054f1cdb5 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -2156,6 +2156,9 @@ void CheckOther::checkSignOfUnsignedVariable() const Scope * scope = symbolDatabase->functionScopes[i]; // check all the code in the function for (const Token *tok = scope->classStart->next(); tok != scope->classEnd; tok = tok->next()) { + // Quick check to see if any of the matches below have any chances + if (!tok->varId() && tok->str() != "0") + continue; if (Token::Match(tok, "%name% <|<= 0") && tok->varId() && !Token::Match(tok->tokAt(3), "+|-")) { // TODO: handle a[10].b , a::b , (unsigned int)x , etc const Token *prev = tok->previous(); diff --git a/lib/errorlogger.cpp b/lib/errorlogger.cpp index 3b102ba17..f0f441f1e 100644 --- a/lib/errorlogger.cpp +++ b/lib/errorlogger.cpp @@ -302,14 +302,7 @@ void ErrorLogger::ErrorMessage::findAndReplace(std::string &source, const std::s std::string::size_type index = 0; while ((index = source.find(searchFor, index)) != std::string::npos) { source.replace(index, searchFor.length(), replaceWith); - - std::string::size_type advanceBy; - if (searchFor.length() >= replaceWith.length()) - advanceBy = replaceWith.length(); - else - advanceBy = (replaceWith.length() - searchFor.length()) + 1; - - index += advanceBy; + index += replaceWith.length(); } }