From ede402a5eceaf0a2c49de3709e6daadcf1ced707 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 22 Mar 2008 17:09:08 +0000 Subject: [PATCH] Minor refactoring --- CheckBufferOverrun.cpp | 14 ++++++-------- CommonCheck.cpp | 2 +- CommonCheck.h | 2 +- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/CheckBufferOverrun.cpp b/CheckBufferOverrun.cpp index 26d0dd004..79c4f1787 100644 --- a/CheckBufferOverrun.cpp +++ b/CheckBufferOverrun.cpp @@ -7,9 +7,11 @@ #include // <- 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(); } diff --git a/CommonCheck.cpp b/CommonCheck.cpp index d4feb9c47..f469f6804 100644 --- a/CommonCheck.cpp +++ b/CommonCheck.cpp @@ -21,7 +21,7 @@ std::string FileLine(const TOKEN *tok) std::list ErrorList; -void ReportErr(const std::string errmsg) +void ReportErr(const std::string &errmsg) { if ( OnlyReportUniqueErrors ) { diff --git a/CommonCheck.h b/CommonCheck.h index 89af51034..80fb2c2a5 100644 --- a/CommonCheck.h +++ b/CommonCheck.h @@ -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;