Refactoring: Removed 'possible error' message about cin

This commit is contained in:
Daniel Marjamäki 2010-05-16 19:09:36 +02:00
parent 26fab24de4
commit 01034cd48d
3 changed files with 0 additions and 34 deletions

View File

@ -93,14 +93,6 @@ void CheckBufferOverrun::bufferOverrun(const Token *tok, const std::string &varn
reportError(tok, Severity::error, "bufferAccessOutOfBounds", errmsg); 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) void CheckBufferOverrun::strncatUsage(const Token *tok)
{ {
if (_settings && !_settings->_checkCodingStyle) 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.. // Loop..
else if (Token::simpleMatch(tok, "for (")) else if (Token::simpleMatch(tok, "for ("))
{ {

View File

@ -172,7 +172,6 @@ public:
void arrayIndexOutOfBounds(const Token *tok, int size, int index); void arrayIndexOutOfBounds(const Token *tok, int size, int index);
void arrayIndexOutOfBounds(const Token *tok, const ArrayInfo &arrayInfo, const std::vector<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 bufferOverrun(const Token *tok, const std::string &varnames = "");
void dangerousStdCin(const Token *tok);
void strncatUsage(const Token *tok); void strncatUsage(const Token *tok);
void outOfBounds(const Token *tok, const std::string &what); void outOfBounds(const Token *tok, const std::string &what);
void sizeArgumentAsChar(const Token *tok); void sizeArgumentAsChar(const Token *tok);
@ -183,7 +182,6 @@ public:
{ {
arrayIndexOutOfBounds(0, 2, 2); arrayIndexOutOfBounds(0, 2, 2);
bufferOverrun(0, std::string("buffer")); bufferOverrun(0, std::string("buffer"));
dangerousStdCin(0);
strncatUsage(0); strncatUsage(0);
outOfBounds(0, "index"); outOfBounds(0, "index");
sizeArgumentAsChar(0); sizeArgumentAsChar(0);

View File

@ -139,8 +139,6 @@ private:
TEST_CASE(memfunc); // memchr/memset/memcpy TEST_CASE(memfunc); // memchr/memset/memcpy
TEST_CASE(cin1);
TEST_CASE(varid1); TEST_CASE(varid1);
TEST_CASE(varid2); 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() void varid1()
{ {
check("void foo()\n" check("void foo()\n"