Refactoring: Renamed ArrayInfo::type_size to ArrayInfo::element_size

This commit is contained in:
Daniel Marjamäki 2010-04-18 20:18:25 +02:00
parent 1ae5a89982
commit af3f2faa41
2 changed files with 13 additions and 14 deletions

View File

@ -1021,7 +1021,7 @@ void CheckBufferOverrun::checkStructVariable()
if (Token::simpleMatch(tok4, ") {"))
{
std::vector<std::string> v;
checkScope(tok4->tokAt(2), v, arrayInfo.num[0], arrayInfo.num[0] * arrayInfo.type_size, arrayInfo.varid);
checkScope(tok4->tokAt(2), v, arrayInfo.num[0], arrayInfo.num[0] * arrayInfo.element_size, arrayInfo.varid);
break;
}
}
@ -1078,7 +1078,7 @@ void CheckBufferOverrun::checkStructVariable()
continue;
// Check variable usage..
checkScope(CheckTok, varname, arrayInfo.num[0], arrayInfo.num[0] * arrayInfo.type_size, 0);
checkScope(CheckTok, varname, arrayInfo.num[0], arrayInfo.num[0] * arrayInfo.element_size, 0);
}
}
}
@ -1275,14 +1275,14 @@ void CheckBufferOverrun::checkSprintfCall(const Token *tok, int size)
CheckBufferOverrun::ArrayInfo::ArrayInfo()
: num(_num), type_size(_typesize), varid(_varid), varname(_varname)
: num(_num), element_size(_element_size), varid(_varid), varname(_varname)
{
_typesize = 0;
_element_size = 0;
_varid = 0;
}
CheckBufferOverrun::ArrayInfo::ArrayInfo(const CheckBufferOverrun::ArrayInfo &ai)
: num(_num), type_size(_typesize), varid(_varid), varname(_varname)
: num(_num), element_size(_element_size), varid(_varid), varname(_varname)
{
*this = ai;
}
@ -1291,7 +1291,7 @@ const CheckBufferOverrun::ArrayInfo & CheckBufferOverrun::ArrayInfo::operator=(c
{
if (&ai != this)
{
_typesize = ai.type_size;
_element_size = ai.element_size;
_num = ai.num;
_varid = ai.varid;
_varname = ai.varname;
@ -1302,7 +1302,7 @@ const CheckBufferOverrun::ArrayInfo & CheckBufferOverrun::ArrayInfo::operator=(c
bool CheckBufferOverrun::ArrayInfo::declare(const Token *tok, const Tokenizer &tokenizer)
{
_num.clear();
_typesize = 0;
_element_size = 0;
_varname.clear();
if (!tok->isName())
@ -1320,14 +1320,14 @@ bool CheckBufferOverrun::ArrayInfo::declare(const Token *tok, const Tokenizer &t
const Token *vartok = tok->tokAt(ivar);
if (vartok->str() == "*")
{
_typesize = tokenizer.sizeOfType(vartok);
_element_size = tokenizer.sizeOfType(vartok);
vartok = vartok->next();
}
else
{
_typesize = tokenizer.sizeOfType(tok);
_element_size = tokenizer.sizeOfType(tok);
}
if (_typesize == 0)
if (_element_size == 0)
return false;
_varname = vartok->str();

View File

@ -97,7 +97,6 @@ public:
/** Check for buffer overruns - this is the function that performs the actual checking */
void checkScope(const Token *tok, const std::vector<std::string> &varname, const int size, const int total_size, unsigned int varid);
/** Information about N-dimensional array */
class ArrayInfo
{
@ -106,7 +105,7 @@ public:
std::vector<unsigned int> _num;
/** size of each element in array */
unsigned int _typesize;
unsigned int _element_size;
/** variable id */
unsigned int _varid;
@ -130,8 +129,8 @@ public:
/** array size */
const std::vector<unsigned int> &num;
/** type size in bytes */
const unsigned int &type_size;
/** size of each element */
const unsigned int &element_size;
/** Variable name */
const unsigned int &varid;