From af3f2faa41013885f10e5c20fb26eef1e94ead27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 18 Apr 2010 20:18:25 +0200 Subject: [PATCH] Refactoring: Renamed ArrayInfo::type_size to ArrayInfo::element_size --- lib/checkbufferoverrun.cpp | 20 ++++++++++---------- lib/checkbufferoverrun.h | 7 +++---- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/lib/checkbufferoverrun.cpp b/lib/checkbufferoverrun.cpp index cec1eab8f..e19494036 100644 --- a/lib/checkbufferoverrun.cpp +++ b/lib/checkbufferoverrun.cpp @@ -1021,7 +1021,7 @@ void CheckBufferOverrun::checkStructVariable() if (Token::simpleMatch(tok4, ") {")) { std::vector 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(); diff --git a/lib/checkbufferoverrun.h b/lib/checkbufferoverrun.h index ec4d226ea..41e6a72ef 100644 --- a/lib/checkbufferoverrun.h +++ b/lib/checkbufferoverrun.h @@ -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 &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 _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 # - /** type size in bytes */ - const unsigned int &type_size; + /** size of each element */ + const unsigned int &element_size; /** Variable name */ const unsigned int &varid;