Refactoring: Renamed ArrayInfo::type_size to ArrayInfo::element_size
This commit is contained in:
parent
1ae5a89982
commit
af3f2faa41
|
@ -1021,7 +1021,7 @@ void CheckBufferOverrun::checkStructVariable()
|
||||||
if (Token::simpleMatch(tok4, ") {"))
|
if (Token::simpleMatch(tok4, ") {"))
|
||||||
{
|
{
|
||||||
std::vector<std::string> v;
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1078,7 +1078,7 @@ void CheckBufferOverrun::checkStructVariable()
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Check variable usage..
|
// 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()
|
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;
|
_varid = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckBufferOverrun::ArrayInfo::ArrayInfo(const CheckBufferOverrun::ArrayInfo &ai)
|
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;
|
*this = ai;
|
||||||
}
|
}
|
||||||
|
@ -1291,7 +1291,7 @@ const CheckBufferOverrun::ArrayInfo & CheckBufferOverrun::ArrayInfo::operator=(c
|
||||||
{
|
{
|
||||||
if (&ai != this)
|
if (&ai != this)
|
||||||
{
|
{
|
||||||
_typesize = ai.type_size;
|
_element_size = ai.element_size;
|
||||||
_num = ai.num;
|
_num = ai.num;
|
||||||
_varid = ai.varid;
|
_varid = ai.varid;
|
||||||
_varname = ai.varname;
|
_varname = ai.varname;
|
||||||
|
@ -1302,7 +1302,7 @@ const CheckBufferOverrun::ArrayInfo & CheckBufferOverrun::ArrayInfo::operator=(c
|
||||||
bool CheckBufferOverrun::ArrayInfo::declare(const Token *tok, const Tokenizer &tokenizer)
|
bool CheckBufferOverrun::ArrayInfo::declare(const Token *tok, const Tokenizer &tokenizer)
|
||||||
{
|
{
|
||||||
_num.clear();
|
_num.clear();
|
||||||
_typesize = 0;
|
_element_size = 0;
|
||||||
_varname.clear();
|
_varname.clear();
|
||||||
|
|
||||||
if (!tok->isName())
|
if (!tok->isName())
|
||||||
|
@ -1320,14 +1320,14 @@ bool CheckBufferOverrun::ArrayInfo::declare(const Token *tok, const Tokenizer &t
|
||||||
const Token *vartok = tok->tokAt(ivar);
|
const Token *vartok = tok->tokAt(ivar);
|
||||||
if (vartok->str() == "*")
|
if (vartok->str() == "*")
|
||||||
{
|
{
|
||||||
_typesize = tokenizer.sizeOfType(vartok);
|
_element_size = tokenizer.sizeOfType(vartok);
|
||||||
vartok = vartok->next();
|
vartok = vartok->next();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_typesize = tokenizer.sizeOfType(tok);
|
_element_size = tokenizer.sizeOfType(tok);
|
||||||
}
|
}
|
||||||
if (_typesize == 0)
|
if (_element_size == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
_varname = vartok->str();
|
_varname = vartok->str();
|
||||||
|
|
|
@ -97,7 +97,6 @@ public:
|
||||||
/** Check for buffer overruns - this is the function that performs the actual checking */
|
/** 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);
|
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 */
|
/** Information about N-dimensional array */
|
||||||
class ArrayInfo
|
class ArrayInfo
|
||||||
{
|
{
|
||||||
|
@ -106,7 +105,7 @@ public:
|
||||||
std::vector<unsigned int> _num;
|
std::vector<unsigned int> _num;
|
||||||
|
|
||||||
/** size of each element in array */
|
/** size of each element in array */
|
||||||
unsigned int _typesize;
|
unsigned int _element_size;
|
||||||
|
|
||||||
/** variable id */
|
/** variable id */
|
||||||
unsigned int _varid;
|
unsigned int _varid;
|
||||||
|
@ -130,8 +129,8 @@ public:
|
||||||
/** array size */
|
/** array size */
|
||||||
const std::vector<unsigned int> #
|
const std::vector<unsigned int> #
|
||||||
|
|
||||||
/** type size in bytes */
|
/** size of each element */
|
||||||
const unsigned int &type_size;
|
const unsigned int &element_size;
|
||||||
|
|
||||||
/** Variable name */
|
/** Variable name */
|
||||||
const unsigned int &varid;
|
const unsigned int &varid;
|
||||||
|
|
Loading…
Reference in New Issue