Re: [PATCH rtems-tools v1] ReportsBase: Change raw pointer to unique_ptr

2021-12-20 Thread Chris Johns
On 21/12/21 10:08 am, Ryan Long wrote:
> On 12/20/2021 5:03 PM, Chris Johns wrote:
>> On 21/12/21 7:24 am, Ryan Long wrote:
>>
>>>     reportList_t   reportList;
>> Then make this `reports`.
>>
>>>     reportList_t::iterator ritr;
>>>     std::string    reportName;
>>> -  ReportsBase*   reports;
>>>     time_t timestamp;
>>>         timestamp = time( NULL ); /* get current cal time */
>>> -  reports = new ReportsText(
>>> +  reportList.emplace_back(new ReportsText(
>> Should `std::make_unique(...)` be used?
> I was going to use this, but it was added in c++14.

Ak OK and thanks. I am using c++14 these days and had not noticed. I will leave
this with you.

Chris
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH rtems-tools v1] ReportsBase: Change raw pointer to unique_ptr

2021-12-20 Thread Ryan Long



On 12/20/2021 5:03 PM, Chris Johns wrote:


On 21/12/21 7:24 am, Ryan Long wrote:

Replaced raw pointer used with ReportsBase-derived classes to make code
cleaner and make it to where pointers do not have to be manually
deleted.

Closes #4376
---
  tester/covoar/ReportsBase.cc | 21 ++---
  1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/tester/covoar/ReportsBase.cc b/tester/covoar/ReportsBase.cc
index 219e5af..8ec65c0 100644
--- a/tester/covoar/ReportsBase.cc
+++ b/tester/covoar/ReportsBase.cc
@@ -591,17 +591,16 @@ void GenerateReports(
boolbranchInfoAvailable
  )
  {
-  typedef std::list reportList_t;
+  typedef std::vector> reportList_t;

Are we OK to use `*_t` in types?

Plus I have moved to ...

using reportList = std::vector>

so I would use the following to avoid '>>':

using reportList_ptr = std::unique_ptr;
using reportLists = std::vector;

I'll put this in V2.


The vector is a container of report lists and not a container of report list
singular.

A minor point, I do not embed the container type into the type alias because
someone may decide to change this to `std::deque` or `std::forward_list` and the
name becomes misleading.


reportList_t   reportList;

Then make this `reports`.


reportList_t::iterator ritr;
std::stringreportName;
-  ReportsBase*   reports;
time_t timestamp;
  
  
timestamp = time( NULL ); /* get current cal time */

-  reports = new ReportsText(
+  reportList.emplace_back(new ReportsText(

Should `std::make_unique(...)` be used?

I was going to use this, but it was added in c++14.


Thanks
Chris


  timestamp,
  symbolSetName,
  allExplanations,
@@ -609,9 +608,8 @@ void GenerateReports(
  outputDirectory,
  symbolsToAnalyze,
  branchInfoAvailable
-  );
-  reportList.push_back( reports );
-  reports = new ReportsHtml(
+  ));
+  reportList.emplace_back(new ReportsHtml(
  timestamp,
  symbolSetName,
  allExplanations,
@@ -619,11 +617,9 @@ void GenerateReports(
  outputDirectory,
  symbolsToAnalyze,
  branchInfoAvailable
-  );
-  reportList.push_back( reports );
+  ));
  
-  for ( ritr = reportList.begin(); ritr != reportList.end(); ritr++ ) {

-reports = *ritr;
+  for ( auto& reports: reportList ) {
  
  reportName = "index" + reports->ReportExtension();

  if ( verbose ) {
@@ -662,11 +658,6 @@ void GenerateReports(
  reports->WriteSymbolSummaryReport( reportName, symbolsToAnalyze );
}
  
-  for ( ritr = reportList.begin(); ritr != reportList.end(); ritr++ ) {

-reports = *ritr;
-delete reports;
-  }
-
ReportsBase::WriteSummaryReport(
  "summary.txt",
  symbolSetName,

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: [PATCH rtems-tools v1] ReportsBase: Change raw pointer to unique_ptr

2021-12-20 Thread Chris Johns



On 21/12/21 7:24 am, Ryan Long wrote:
> Replaced raw pointer used with ReportsBase-derived classes to make code
> cleaner and make it to where pointers do not have to be manually
> deleted.
> 
> Closes #4376
> ---
>  tester/covoar/ReportsBase.cc | 21 ++---
>  1 file changed, 6 insertions(+), 15 deletions(-)
> 
> diff --git a/tester/covoar/ReportsBase.cc b/tester/covoar/ReportsBase.cc
> index 219e5af..8ec65c0 100644
> --- a/tester/covoar/ReportsBase.cc
> +++ b/tester/covoar/ReportsBase.cc
> @@ -591,17 +591,16 @@ void GenerateReports(
>boolbranchInfoAvailable
>  )
>  {
> -  typedef std::list reportList_t;
> +  typedef std::vector> reportList_t;

Are we OK to use `*_t` in types?

Plus I have moved to ...

using reportList = std::vector>

so I would use the following to avoid '>>':

using reportList_ptr = std::unique_ptr;
using reportLists = std::vector;

The vector is a container of report lists and not a container of report list
singular.

A minor point, I do not embed the container type into the type alias because
someone may decide to change this to `std::deque` or `std::forward_list` and the
name becomes misleading.

>reportList_t   reportList;

Then make this `reports`.

>reportList_t::iterator ritr;
>std::stringreportName;
> -  ReportsBase*   reports;
>time_t timestamp;
>  
>  
>timestamp = time( NULL ); /* get current cal time */
> -  reports = new ReportsText(
> +  reportList.emplace_back(new ReportsText(

Should `std::make_unique(...)` be used?

Thanks
Chris

>  timestamp,
>  symbolSetName,
>  allExplanations,
> @@ -609,9 +608,8 @@ void GenerateReports(
>  outputDirectory,
>  symbolsToAnalyze,
>  branchInfoAvailable
> -  );
> -  reportList.push_back( reports );
> -  reports = new ReportsHtml(
> +  ));
> +  reportList.emplace_back(new ReportsHtml(
>  timestamp,
>  symbolSetName,
>  allExplanations,
> @@ -619,11 +617,9 @@ void GenerateReports(
>  outputDirectory,
>  symbolsToAnalyze,
>  branchInfoAvailable
> -  );
> -  reportList.push_back( reports );
> +  ));
>  
> -  for ( ritr = reportList.begin(); ritr != reportList.end(); ritr++ ) {
> -reports = *ritr;
> +  for ( auto& reports: reportList ) {
>  
>  reportName = "index" + reports->ReportExtension();
>  if ( verbose ) {
> @@ -662,11 +658,6 @@ void GenerateReports(
>  reports->WriteSymbolSummaryReport( reportName, symbolsToAnalyze );
>}
>  
> -  for ( ritr = reportList.begin(); ritr != reportList.end(); ritr++ ) {
> -reports = *ritr;
> -delete reports;
> -  }
> -
>ReportsBase::WriteSummaryReport(
>  "summary.txt",
>  symbolSetName,
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH rtems-tools v1] ReportsBase: Change raw pointer to unique_ptr

2021-12-20 Thread Ryan Long
Replaced raw pointer used with ReportsBase-derived classes to make code
cleaner and make it to where pointers do not have to be manually
deleted.

Closes #4376
---
 tester/covoar/ReportsBase.cc | 21 ++---
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/tester/covoar/ReportsBase.cc b/tester/covoar/ReportsBase.cc
index 219e5af..8ec65c0 100644
--- a/tester/covoar/ReportsBase.cc
+++ b/tester/covoar/ReportsBase.cc
@@ -591,17 +591,16 @@ void GenerateReports(
   boolbranchInfoAvailable
 )
 {
-  typedef std::list reportList_t;
+  typedef std::vector> reportList_t;
 
   reportList_t   reportList;
   reportList_t::iterator ritr;
   std::stringreportName;
-  ReportsBase*   reports;
   time_t timestamp;
 
 
   timestamp = time( NULL ); /* get current cal time */
-  reports = new ReportsText(
+  reportList.emplace_back(new ReportsText(
 timestamp,
 symbolSetName,
 allExplanations,
@@ -609,9 +608,8 @@ void GenerateReports(
 outputDirectory,
 symbolsToAnalyze,
 branchInfoAvailable
-  );
-  reportList.push_back( reports );
-  reports = new ReportsHtml(
+  ));
+  reportList.emplace_back(new ReportsHtml(
 timestamp,
 symbolSetName,
 allExplanations,
@@ -619,11 +617,9 @@ void GenerateReports(
 outputDirectory,
 symbolsToAnalyze,
 branchInfoAvailable
-  );
-  reportList.push_back( reports );
+  ));
 
-  for ( ritr = reportList.begin(); ritr != reportList.end(); ritr++ ) {
-reports = *ritr;
+  for ( auto& reports: reportList ) {
 
 reportName = "index" + reports->ReportExtension();
 if ( verbose ) {
@@ -662,11 +658,6 @@ void GenerateReports(
 reports->WriteSymbolSummaryReport( reportName, symbolsToAnalyze );
   }
 
-  for ( ritr = reportList.begin(); ritr != reportList.end(); ritr++ ) {
-reports = *ritr;
-delete reports;
-  }
-
   ReportsBase::WriteSummaryReport(
 "summary.txt",
 symbolSetName,
-- 
1.8.3.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel