Symbol database: removed unnecessary null pointer checks

This commit is contained in:
Robert Reif 2010-12-07 07:07:07 +01:00 committed by Daniel Marjamäki
parent 26864dd011
commit 6c719c5806
4 changed files with 12 additions and 15 deletions

View File

@ -114,7 +114,7 @@ void CheckBufferOverrun::bufferOverrun(const Token *tok, const std::string &varn
void CheckBufferOverrun::strncatUsage(const Token *tok)
{
if (_settings && !_settings->_checkCodingStyle)
if (!_settings->_checkCodingStyle)
return;
reportError(tok, Severity::warning, "strncatUsage", "Dangerous usage of strncat. Tip: the 3rd parameter means maximum number of characters to append");
@ -127,7 +127,7 @@ void CheckBufferOverrun::outOfBounds(const Token *tok, const std::string &what)
void CheckBufferOverrun::sizeArgumentAsChar(const Token *tok)
{
if (_settings && !_settings->_checkCodingStyle)
if (!_settings->_checkCodingStyle)
return;
reportError(tok, Severity::warning, "sizeArgumentAsChar", "The size argument is given as a char constant");
}
@ -990,7 +990,7 @@ void CheckBufferOverrun::checkScope(const Token *tok, const ArrayInfo &arrayInfo
if (!Token::Match(tok2, "%varid% [ %any% ] = 0 ;", tok->tokAt(2)->varId()))
{
// this is currently inconclusive. See TestBufferOverrun::terminateStrncpy3
if (_settings && _settings->inconclusive)
if (_settings->inconclusive)
terminateStrncpyError(tok);
}

View File

@ -761,7 +761,7 @@ const char * CheckMemoryLeakInFunction::call_func(const Token *tok, std::list<co
--parlevel;
if (parlevel < 1)
{
return (_settings && _settings->inconclusive) ? 0 : "callfunc";
return (_settings->inconclusive) ? 0 : "callfunc";
}
}

View File

@ -1205,7 +1205,7 @@ void SymbolDatabase::SpaceInfo::getVarList()
// If the vartok was set in the if-blocks above, create a entry for this variable..
if (vartok && vartok->str() != "operator")
{
if (vartok->varId() == 0 && check->_settings && check->_settings->debugwarnings)
if (vartok->varId() == 0 && check->_settings->debugwarnings)
{
std::list<ErrorLogger::ErrorMessage::FileLocation> locationList;
ErrorLogger::ErrorMessage::FileLocation loc;

View File

@ -414,7 +414,7 @@ void Tokenizer::createTokens(std::istream &code)
void Tokenizer::duplicateTypedefError(const Token *tok1, const Token *tok2, const std::string &type)
{
if (!(_settings && _settings->_checkCodingStyle))
if (!(_settings->_checkCodingStyle))
return;
std::list<ErrorLogger::ErrorMessage::FileLocation> locationList;
@ -440,7 +440,7 @@ void Tokenizer::duplicateTypedefError(const Token *tok1, const Token *tok2, cons
void Tokenizer::duplicateDeclarationError(const Token *tok1, const Token *tok2, const std::string &type)
{
if (!(_settings && _settings->_checkCodingStyle))
if (!(_settings->_checkCodingStyle))
return;
std::list<ErrorLogger::ErrorMessage::FileLocation> locationList;
@ -647,9 +647,6 @@ bool Tokenizer::duplicateTypedef(Token **tokPtr, const Token *name)
void Tokenizer::unsupportedTypedef(const Token *tok) const
{
if (!_settings)
return;
if (!_settings->debugwarnings)
return;
@ -2655,7 +2652,7 @@ void Tokenizer::simplifyTemplates()
else
{
// debug message that we bail out..
if (_settings && _settings->debugwarnings)
if (_settings->debugwarnings)
{
std::list<ErrorLogger::ErrorMessage::FileLocation> locationList;
ErrorLogger::ErrorMessage::FileLocation loc;
@ -2750,7 +2747,7 @@ void Tokenizer::simplifyTemplates()
if (type2.empty() || type.size() != types2.size())
{
if (_settings && _settings->debugwarnings)
if (_settings->debugwarnings)
{
std::list<ErrorLogger::ErrorMessage::FileLocation> locationList;
ErrorLogger::ErrorMessage::FileLocation loc;
@ -4073,7 +4070,7 @@ bool Tokenizer::simplifyTokenList()
removeRedundantAssignment();
simplifyComma();
if (_settings && _settings->debug)
if (_settings->debug)
{
_tokens->printOut(0, _files);
}
@ -6155,7 +6152,7 @@ bool Tokenizer::simplifyKnownVariables()
{
// This is a really generic bailout so let's try to avoid this.
// There might be lots of false negatives.
if (_settings && _settings->debugwarnings)
if (_settings->debugwarnings)
{
// FIXME: Fix all the debug warnings for values and then
// remove this bailout
@ -6943,7 +6940,7 @@ void Tokenizer::simplifyNestedStrcat()
void Tokenizer::duplicateEnumError(const Token * tok1, const Token * tok2, const std::string & type)
{
if (!(_settings && _settings->_checkCodingStyle))
if (!(_settings->_checkCodingStyle))
return;
std::list<ErrorLogger::ErrorMessage::FileLocation> locationList;