CheckOther: removed redundant conditions. No need to check if varid is > 0 and if there is variable info.

This commit is contained in:
Daniel Marjamäki 2013-07-29 12:01:52 +02:00
parent f59164302d
commit d9a2f542be
1 changed files with 6 additions and 10 deletions

View File

@ -63,19 +63,15 @@ void CheckOther::checkCastIntToCharAndBack()
} }
} else if (Token::Match(tok, "EOF %comp% ( %var% = fclose|fflush|fputc|fputs|fscanf|getchar|getc|fgetc|putchar|putc|puts|scanf|sscanf|ungetc (")) { } else if (Token::Match(tok, "EOF %comp% ( %var% = fclose|fflush|fputc|fputs|fscanf|getchar|getc|fgetc|putchar|putc|puts|scanf|sscanf|ungetc (")) {
tok = tok->tokAt(3); tok = tok->tokAt(3);
if (tok && tok->varId()) { const Variable *var = tok->variable();
const Variable *var = tok->variable(); if (var && var->typeEndToken()->str() == "char" && !var->typeEndToken()->isSigned()) {
if (var && var->typeEndToken()->str() == "char" && !var->typeEndToken()->isSigned()) { checkCastIntToCharAndBackError(tok, tok->strAt(2));
checkCastIntToCharAndBackError(tok, tok->strAt(2));
}
} }
} else if (Token::Match(tok, "EOF %comp% ( %var% = std :: cin . get (") || Token::Match(tok, "EOF %comp% ( %var% = cin . get (")) { } else if (Token::Match(tok, "EOF %comp% ( %var% = std :: cin . get (") || Token::Match(tok, "EOF %comp% ( %var% = cin . get (")) {
tok = tok->tokAt(3); tok = tok->tokAt(3);
if (tok && tok->varId()) { const Variable *var = tok->variable();
const Variable *var = tok->variable(); if (var && var->typeEndToken()->str() == "char" && !var->typeEndToken()->isSigned()) {
if (var && var->typeEndToken()->str() == "char" && !var->typeEndToken()->isSigned()) { checkCastIntToCharAndBackError(tok, "cin.get");
checkCastIntToCharAndBackError(tok, "cin.get");
}
} }
} else if (Token::Match(tok, "%var% = std :: cin . get (") || Token::Match(tok, "%var% = cin . get (")) { } else if (Token::Match(tok, "%var% = std :: cin . get (") || Token::Match(tok, "%var% = cin . get (")) {
const Variable *var = tok->variable(); const Variable *var = tok->variable();