Merge pull request #438 from Dmitry-Me/moveDeclarationReorderCheck
Move declaration, run check earlier
This commit is contained in:
commit
776e720d8f
|
@ -890,9 +890,9 @@ void CheckBufferOverrun::checkScope(const Token *tok, const ArrayInfo &arrayInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
// Writing data into array..
|
// Writing data into array..
|
||||||
if (Token::Match(tok, "strcpy|strcat ( %varid% , %str% )", declarationId)) {
|
if (total_size > 0 && Token::Match(tok, "strcpy|strcat ( %varid% , %str% )", declarationId)) {
|
||||||
const std::size_t len = Token::getStrLength(tok->tokAt(4));
|
const std::size_t len = Token::getStrLength(tok->tokAt(4));
|
||||||
if (total_size > 0 && len >= (unsigned int)total_size) {
|
if (len >= (unsigned int)total_size) {
|
||||||
bufferOverrunError(tok, arrayInfo.varname());
|
bufferOverrunError(tok, arrayInfo.varname());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1092,8 +1092,6 @@ void CheckUnusedVar::checkFunctionVariableUsage()
|
||||||
it != variables.varUsage().end();
|
it != variables.varUsage().end();
|
||||||
++it) {
|
++it) {
|
||||||
const Variables::VariableUsage &usage = it->second;
|
const Variables::VariableUsage &usage = it->second;
|
||||||
const std::string &varname = usage._var->name();
|
|
||||||
const Variable* var = symbolDatabase->getVariableFromVarId(it->first);
|
|
||||||
|
|
||||||
// variable has been marked as unused so ignore it
|
// variable has been marked as unused so ignore it
|
||||||
if (usage._var->nameToken()->isAttributeUnused() || usage._var->nameToken()->isAttributeUsed())
|
if (usage._var->nameToken()->isAttributeUnused() || usage._var->nameToken()->isAttributeUsed())
|
||||||
|
@ -1105,6 +1103,9 @@ void CheckUnusedVar::checkFunctionVariableUsage()
|
||||||
usage._type == Variables::referenceArray)
|
usage._type == Variables::referenceArray)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
const std::string &varname = usage._var->name();
|
||||||
|
const Variable* var = symbolDatabase->getVariableFromVarId(it->first);
|
||||||
|
|
||||||
// variable has had memory allocated for it, but hasn't done
|
// variable has had memory allocated for it, but hasn't done
|
||||||
// anything with that memory other than, perhaps, freeing it
|
// anything with that memory other than, perhaps, freeing it
|
||||||
if (usage.unused() && !usage._modified && usage._allocateMemory)
|
if (usage.unused() && !usage._modified && usage._allocateMemory)
|
||||||
|
|
Loading…
Reference in New Issue