Removed redundant nullpointer check (cppcheck catch)
This commit is contained in:
PKEuS 2012-04-18 16:35:04 +02:00
parent cb7537418a
commit 6a37c36ee8
3 changed files with 8 additions and 3 deletions

View File

@ -576,13 +576,13 @@ void CheckOther::checkSizeofForPointerSize()
// Also ensure the variables are pointers
// Only keep variables which are pointers
const Variable *var = symbolDatabase->getVariableFromVarId(variable->varId());
if (!var || !var->isPointer()) {
if (!var || !var->isPointer() || var->isArray()) {
variable = 0;
}
if (variable2) {
var = symbolDatabase->getVariableFromVarId(variable2->varId());
if (!var || !var->isPointer()) {
if (!var || !var->isPointer() || var->isArray()) {
variable2 = 0;
}
}

View File

@ -9278,7 +9278,7 @@ void Tokenizer::simplifyBorland()
while (tok2->next() && !Token::Match(tok2->next(), "{|;"))
tok2->deleteNext();
tok2->deleteThis();
if (tok2 && tok2->str() == "{") {
if (tok2->str() == "{") {
Token::eraseTokens(tok2, tok2->link());
tok2->deleteNext();
tok2->deleteThis();

View File

@ -4314,6 +4314,11 @@ private:
"memset(x, 0, sizeof(x));");
ASSERT_EQUALS("", errout.str());
check(
"char* x[10];\n"
"memset(x, 0, sizeof(x));");
ASSERT_EQUALS("", errout.str());
check(
"char x[10];\n"
"memset(x, 0, sizeof x);");