[rtems-tools commit] Remove projectName global variable
Joel Sherrill
joel at rtems.org
Tue Aug 3 21:00:44 UTC 2021
Module: rtems-tools
Branch: master
Commit: 987d912435832aec118a02e6e2f2160f4319ca71
Changeset: http://git.rtems.org/rtems-tools/commit/?id=987d912435832aec118a02e6e2f2160f4319ca71
Author: Ryan Long <ryan.long at oarcorp.com>
Date: Tue Jul 27 17:41:23 2021 -0400
Remove projectName global variable
- Replaced projectName in app_common with a local variable in covoar()
- Changed datatype to string
- Changed conditionals to reflect this
- Created projectName_m member variable for ReportsBase
- Added parameter to Reports* constructors to initialize projectName_m
---
tester/covoar/ReportsBase.cc | 23 ++++++++++++++++++-----
tester/covoar/ReportsBase.h | 12 ++++++++++--
tester/covoar/ReportsHtml.cc | 33 +++++++++++++++++----------------
tester/covoar/ReportsHtml.h | 3 ++-
tester/covoar/ReportsText.cc | 5 +++--
tester/covoar/ReportsText.h | 3 ++-
tester/covoar/app_common.cc | 1 -
tester/covoar/app_common.h | 1 -
tester/covoar/covoar.cc | 10 ++++++++--
9 files changed, 60 insertions(+), 31 deletions(-)
diff --git a/tester/covoar/ReportsBase.cc b/tester/covoar/ReportsBase.cc
index 8947f58..b2da71a 100644
--- a/tester/covoar/ReportsBase.cc
+++ b/tester/covoar/ReportsBase.cc
@@ -26,11 +26,13 @@ namespace Coverage {
ReportsBase::ReportsBase(
time_t timestamp,
const std::string& symbolSetName,
- Coverage::Explanations& allExplanations
+ Coverage::Explanations& allExplanations,
+ const std::string& projectName
): reportExtension_m( "" ),
symbolSetName_m( symbolSetName ),
timestamp_m( timestamp ),
- allExplanations_m( allExplanations )
+ allExplanations_m( allExplanations ),
+ projectName_m( projectName )
{
}
@@ -565,7 +567,8 @@ void ReportsBase::WriteSummaryReport(
void GenerateReports(
const std::string& symbolSetName,
Coverage::Explanations& allExplanations,
- bool verbose
+ bool verbose,
+ const std::string& projectName
)
{
typedef std::list<ReportsBase *> reportList_t;
@@ -578,9 +581,19 @@ void GenerateReports(
timestamp = time( NULL ); /* get current cal time */
- reports = new ReportsText( timestamp, symbolSetName, allExplanations );
+ reports = new ReportsText(
+ timestamp,
+ symbolSetName,
+ allExplanations,
+ projectName
+ );
reportList.push_back( reports );
- reports = new ReportsHtml( timestamp, symbolSetName, allExplanations );
+ reports = new ReportsHtml(
+ timestamp,
+ symbolSetName,
+ allExplanations,
+ projectName
+ );
reportList.push_back( reports );
for ( ritr = reportList.begin(); ritr != reportList.end(); ritr++ ) {
diff --git a/tester/covoar/ReportsBase.h b/tester/covoar/ReportsBase.h
index 41ac7ef..38b7c29 100644
--- a/tester/covoar/ReportsBase.h
+++ b/tester/covoar/ReportsBase.h
@@ -30,7 +30,8 @@ class ReportsBase {
ReportsBase(
time_t timestamp,
const std::string& symbolSetName,
- Coverage::Explanations& allExplanations
+ Coverage::Explanations& allExplanations,
+ const std::string& projectName
);
virtual ~ReportsBase();
@@ -130,6 +131,11 @@ class ReportsBase {
Coverage::Explanations& allExplanations_m;
/*!
+ * This variable stores the name of the project.
+ */
+ std::string projectName_m;
+
+ /*!
* This method Opens a report file and verifies that it opened
* correctly. Upon failure NULL is returned.
*
@@ -401,11 +407,13 @@ class ReportsBase {
* @param[in] symbolSetName is the name of the symbol set to report on.
* @param[in] allExplanations is the explanations to report on.
* @param[in] verbose specifies whether to be verbose with output
+ * @param[in] projectName specifies the name of the project
*/
void GenerateReports(
const std::string& symbolSetName,
Coverage::Explanations& allExplanations,
- bool verbose
+ bool verbose,
+ const std::string& projectName
);
}
diff --git a/tester/covoar/ReportsHtml.cc b/tester/covoar/ReportsHtml.cc
index 83fc52f..2c210b5 100644
--- a/tester/covoar/ReportsHtml.cc
+++ b/tester/covoar/ReportsHtml.cc
@@ -40,8 +40,9 @@ namespace Coverage {
ReportsHtml::ReportsHtml(
time_t timestamp,
const std::string& symbolSetName,
- Coverage::Explanations& allExplanations
- ): ReportsBase( timestamp, symbolSetName, allExplanations ),
+ Coverage::Explanations& allExplanations,
+ const std::string& projectName
+ ): ReportsBase( timestamp, symbolSetName, allExplanations, projectName ),
lastState_m( A_SOURCE )
{
reportExtension_m = ".html";
@@ -71,8 +72,8 @@ namespace Coverage {
aFile << "<title>Index</title>" << std::endl
<< "<div class=\"heading-title\">";
- if ( projectName ) {
- aFile << projectName << "<br>";
+ if ( !projectName_m.empty() ) {
+ aFile << projectName_m << "<br>";
}
aFile << "Coverage Analysis Reports</div>" << std::endl
@@ -129,8 +130,8 @@ namespace Coverage {
aFile << "<title>Annotated Report</title>" << std::endl
<< "<div class=\"heading-title\">";
- if ( projectName ) {
- aFile << projectName << "<br>";
+ if ( !projectName_m.empty() ) {
+ aFile << projectName_m << "<br>";
}
aFile << "Annotated Report</div>" << std::endl
@@ -153,8 +154,8 @@ namespace Coverage {
aFile << "<title>Branch Report</title>" << std::endl
<< "<div class=\"heading-title\">";
- if ( projectName ) {
- aFile << projectName << "<br>";
+ if ( !projectName_m.empty() ) {
+ aFile << projectName_m << "<br>";
}
aFile << "Branch Report</div>" << std::endl
@@ -199,8 +200,8 @@ namespace Coverage {
aFile << "<title>Coverage Report</title>" << std::endl
<< "<div class=\"heading-title\">";
- if ( projectName ) {
- aFile << projectName << "<br>";
+ if ( !projectName_m.empty() ) {
+ aFile << projectName_m << "<br>";
}
aFile << "Coverage Report</div>" << std::endl
@@ -242,8 +243,8 @@ namespace Coverage {
aFile << "<title> Report</title>" << std::endl
<< "<div class=\"heading-title\">";
- if ( projectName ) {
- aFile << projectName << "<br>";
+ if ( !projectName_m.empty() ) {
+ aFile << projectName_m << "<br>";
}
aFile << "No Range Report</div>" << std::endl
@@ -275,8 +276,8 @@ namespace Coverage {
aFile << "<title>Uncovered Range Size Report</title>" << std::endl
<< "<div class=\"heading-title\">";
- if ( projectName ) {
- aFile << projectName << "<br>";
+ if ( !projectName_m.empty() ) {
+ aFile << projectName_m << "<br>";
}
aFile << "Uncovered Range Size Report</div>" << std::endl
@@ -312,8 +313,8 @@ namespace Coverage {
aFile << "<title>Symbol Summary Report</title>" << std::endl
<< "<div class=\"heading-title\">";
- if ( projectName ) {
- aFile << projectName << "<br>";
+ if ( !projectName_m.empty() ) {
+ aFile << projectName_m << "<br>";
}
aFile << "Symbol Summary Report</div>" << std::endl
diff --git a/tester/covoar/ReportsHtml.h b/tester/covoar/ReportsHtml.h
index 711c48b..46698f0 100644
--- a/tester/covoar/ReportsHtml.h
+++ b/tester/covoar/ReportsHtml.h
@@ -28,7 +28,8 @@ class ReportsHtml: public ReportsBase {
ReportsHtml(
time_t timestamp,
const std::string& symbolSetName,
- Coverage::Explanations& allExplanations
+ Coverage::Explanations& allExplanations,
+ const std::string& projectName
);
~ReportsHtml();
diff --git a/tester/covoar/ReportsText.cc b/tester/covoar/ReportsText.cc
index 0b0d9df..7318de3 100644
--- a/tester/covoar/ReportsText.cc
+++ b/tester/covoar/ReportsText.cc
@@ -19,8 +19,9 @@ namespace Coverage {
ReportsText::ReportsText(
time_t timestamp,
const std::string& symbolSetName,
- Coverage::Explanations& allExplanations
-): ReportsBase( timestamp, symbolSetName, allExplanations )
+ Coverage::Explanations& allExplanations,
+ const std::string& projectName
+): ReportsBase( timestamp, symbolSetName, allExplanations, projectName )
{
reportExtension_m = ".txt";
}
diff --git a/tester/covoar/ReportsText.h b/tester/covoar/ReportsText.h
index 48528b0..c44591d 100644
--- a/tester/covoar/ReportsText.h
+++ b/tester/covoar/ReportsText.h
@@ -24,7 +24,8 @@ class ReportsText: public ReportsBase {
ReportsText(
time_t timestamp,
const std::string& symbolSetName,
- Coverage::Explanations& allExplanations
+ Coverage::Explanations& allExplanations,
+ const std::string& projectName
);
virtual ~ReportsText();
diff --git a/tester/covoar/app_common.cc b/tester/covoar/app_common.cc
index 587af1a..cedffdd 100644
--- a/tester/covoar/app_common.cc
+++ b/tester/covoar/app_common.cc
@@ -60,7 +60,6 @@ Coverage::DesiredSymbols* SymbolsToAnalyze = NULL;
const char* outputDirectory = ".";
bool BranchInfoAvailable = false;
Target::TargetBase* TargetInfo = NULL;
-const char* projectName = NULL;
char inputBuffer[MAX_LINE_LENGTH];
char inputBuffer2[MAX_LINE_LENGTH];
diff --git a/tester/covoar/app_common.h b/tester/covoar/app_common.h
index 6cb8577..533a926 100644
--- a/tester/covoar/app_common.h
+++ b/tester/covoar/app_common.h
@@ -16,7 +16,6 @@ extern Coverage::DesiredSymbols* SymbolsToAnalyze;
extern const char* outputDirectory;
extern bool BranchInfoAvailable;
extern Target::TargetBase* TargetInfo;
-extern const char* projectName;
#define MAX_LINE_LENGTH 512
extern char inputBuffer[MAX_LINE_LENGTH];
diff --git a/tester/covoar/covoar.cc b/tester/covoar/covoar.cc
index 3894867..5f8de5b 100644
--- a/tester/covoar/covoar.cc
+++ b/tester/covoar/covoar.cc
@@ -178,6 +178,7 @@ int covoar(
Coverage::ObjdumpProcessor objdumpProcessor;
bool verbose = false;
std::string dynamicLibrary;
+ std::string projectName;
//
// Process command line options.
@@ -223,7 +224,7 @@ int covoar(
/*
* Check for project name.
*/
- if ( !projectName )
+ if ( projectName.empty() )
throw option_error( "project name -p" );
//
@@ -474,7 +475,12 @@ int covoar(
std::cerr << "Generate Reports" << std::endl;
for (const auto& setName : SymbolsToAnalyze->getSetNames()) {
- Coverage::GenerateReports( setName, allExplanations, verbose );
+ Coverage::GenerateReports(
+ setName,
+ allExplanations,
+ verbose,
+ projectName
+ );
}
// Write explanations that were not found.
More information about the vc
mailing list