Minor refactoring

This commit is contained in:
Daniel Marjamäki 2008-03-22 17:09:08 +00:00
parent ab7cb379af
commit ede402a5ec
3 changed files with 8 additions and 10 deletions

View File

@ -7,9 +7,11 @@
#include <stdlib.h> // <- strtoul
//---------------------------------------------------------------------------
extern bool ShowAll;
//---------------------------------------------------------------------------
TOKEN *findfunction(TOKEN *tok)
static const TOKEN *findfunction(const TOKEN *tok)
{
int indentlevel = 0, parlevel = 0;
for (; tok; tok = tok->next)
@ -28,7 +30,7 @@ TOKEN *findfunction(TOKEN *tok)
if (indentlevel==0 && parlevel==0 && IsName(tok->str) && tok->next->str[0]=='(')
{
for (TOKEN *tok2 = tok->next; tok2; tok2 = tok2->next)
for (const TOKEN *tok2 = tok->next; tok2; tok2 = tok2->next)
{
if (tok2->str[0] == ')' && tok2->next)
{
@ -43,13 +45,10 @@ TOKEN *findfunction(TOKEN *tok)
return 0;
}
//---------------------------------------------------------------------------
// Writing dynamic data in buffer without bounds checking
//---------------------------------------------------------------------------
extern bool ShowAll;
static void _DynamicDataCheck(const TOKEN *ftok, const TOKEN *tok)
{
const char *var2 = tok->str;
@ -107,7 +106,7 @@ static void _DynamicDataCheck(const TOKEN *ftok, const TOKEN *tok)
}
static void _DynamicData()
static void CheckBufferOverrun_DynamicData()
{
for (const TOKEN *ftok = findfunction(tokens); ftok; ftok = findfunction(ftok->next))
{
@ -158,8 +157,6 @@ static void _DynamicData()
static void CheckBufferOverrun_LocalVariable()
{
_DynamicData();
int indentlevel = 0;
for (const TOKEN *tok = tokens; tok; tok = tok->next)
{
@ -400,6 +397,7 @@ static void CheckBufferOverrun_StructVariable()
void CheckBufferOverrun()
{
CheckBufferOverrun_DynamicData();
CheckBufferOverrun_LocalVariable();
CheckBufferOverrun_StructVariable();
}

View File

@ -21,7 +21,7 @@ std::string FileLine(const TOKEN *tok)
std::list<std::string> ErrorList;
void ReportErr(const std::string errmsg)
void ReportErr(const std::string &errmsg)
{
if ( OnlyReportUniqueErrors )
{

View File

@ -12,7 +12,7 @@ std::string FileLine(const TOKEN *tok);
extern bool OnlyReportUniqueErrors;
void ReportErr(const std::string errmsg);
void ReportErr(const std::string &errmsg);
extern std::ostringstream errout;