Refactoring: Removed 'possible error' message about cin
This commit is contained in:
parent
26fab24de4
commit
01034cd48d
|
@ -93,14 +93,6 @@ void CheckBufferOverrun::bufferOverrun(const Token *tok, const std::string &varn
|
|||
reportError(tok, Severity::error, "bufferAccessOutOfBounds", errmsg);
|
||||
}
|
||||
|
||||
void CheckBufferOverrun::dangerousStdCin(const Token *tok)
|
||||
{
|
||||
if (_settings && _settings->inconclusive == false)
|
||||
return;
|
||||
|
||||
reportError(tok, Severity::possibleError, "dangerousStdCin", "Dangerous usage of std::cin, possible buffer overrun");
|
||||
}
|
||||
|
||||
void CheckBufferOverrun::strncatUsage(const Token *tok)
|
||||
{
|
||||
if (_settings && !_settings->_checkCodingStyle)
|
||||
|
@ -788,13 +780,6 @@ void CheckBufferOverrun::checkScope(const Token *tok, const ArrayInfo &arrayInfo
|
|||
|
||||
}
|
||||
|
||||
// cin..
|
||||
else if (Token::Match(tok, "cin >> %varid% ;", arrayInfo.varid))
|
||||
{
|
||||
dangerousStdCin(tok);
|
||||
}
|
||||
|
||||
|
||||
// Loop..
|
||||
else if (Token::simpleMatch(tok, "for ("))
|
||||
{
|
||||
|
|
|
@ -172,7 +172,6 @@ public:
|
|||
void arrayIndexOutOfBounds(const Token *tok, int size, int index);
|
||||
void arrayIndexOutOfBounds(const Token *tok, const ArrayInfo &arrayInfo, const std::vector<int> &index);
|
||||
void bufferOverrun(const Token *tok, const std::string &varnames = "");
|
||||
void dangerousStdCin(const Token *tok);
|
||||
void strncatUsage(const Token *tok);
|
||||
void outOfBounds(const Token *tok, const std::string &what);
|
||||
void sizeArgumentAsChar(const Token *tok);
|
||||
|
@ -183,7 +182,6 @@ public:
|
|||
{
|
||||
arrayIndexOutOfBounds(0, 2, 2);
|
||||
bufferOverrun(0, std::string("buffer"));
|
||||
dangerousStdCin(0);
|
||||
strncatUsage(0);
|
||||
outOfBounds(0, "index");
|
||||
sizeArgumentAsChar(0);
|
||||
|
|
|
@ -139,8 +139,6 @@ private:
|
|||
|
||||
TEST_CASE(memfunc); // memchr/memset/memcpy
|
||||
|
||||
TEST_CASE(cin1);
|
||||
|
||||
TEST_CASE(varid1);
|
||||
TEST_CASE(varid2);
|
||||
|
||||
|
@ -1691,21 +1689,6 @@ private:
|
|||
}
|
||||
|
||||
|
||||
|
||||
void cin1()
|
||||
{
|
||||
check("#include <iostream>\n"
|
||||
"using namespace std;\n"
|
||||
"void f()\n"
|
||||
"{\n"
|
||||
" char str[10];\n"
|
||||
" cin >> str;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:6]: (possible error) Dangerous usage of std::cin, possible buffer overrun\n", errout.str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
void varid1()
|
||||
{
|
||||
check("void foo()\n"
|
||||
|
|
Loading…
Reference in New Issue