All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [Powertop] [PATCH v3 05/15] fix clang++ compilation errors
@ 2014-09-30  2:42 Alexandra Yates
  0 siblings, 0 replies; 7+ messages in thread
From: Alexandra Yates @ 2014-09-30  2:42 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 3700 bytes --]


> Hi,
>
> On Sun, Sep 07, 2014 at 02:28:11PM -0700, powertop-request(a)lists.01.org
> wrote:
>> Date: Sun,  7 Sep 2014 22:27:08 +0100
>> From: Sami Kerola <kerolasa(a)iki.fi>
>>
>> The same error was fixed in multiple files to made clang++ work.
>>
>> error: variable length array of non-POD element type 'string' (aka
>> 'basic_string<char>')
>>
>> Signed-off-by: Sami Kerola <kerolasa(a)iki.fi>
>
>> diff --git a/src/cpu/cpu.cpp b/src/cpu/cpu.cpp
>> index dbca20c..4e040c1 100644
>> --- a/src/cpu/cpu.cpp
>> +++ b/src/cpu/cpu.cpp
>> @@ -479,12 +479,12 @@ void report_display_cpu_cstates(void)
>>  		/* Tables for PKG, CORE, CPU */
>>  		pkg_tbl_size.cols=2;
>>  		pkg_tbl_size.rows= ((cstates_num+1)-LEVEL_HEADER)+1;
>> -		string pkg_data[pkg_tbl_size.cols * pkg_tbl_size.rows];
>> +		string *pkg_data = new string[pkg_tbl_size.cols * pkg_tbl_size.rows];
>>
>>  		core_tbl_size.cols=2;
>>  		core_tbl_size.rows=(cstates_num *_package->children.size())
>>  				+ _package->children.size();
>> -		string core_data[core_tbl_size.cols * core_tbl_size.rows];
>> +		string *core_data = new string[core_tbl_size.cols *
>> core_tbl_size.rows];
>>  		int num_cpus=0, num_cores=0;
>>
>>  		for (core = 0; core < _package->children.size(); core++) {
>> @@ -506,7 +506,7 @@ void report_display_cpu_cstates(void)
>>  		cpu_tbl_size.cols=(2 * (num_cpus / num_cores)) + 1;
>>  		cpu_tbl_size.rows = ((cstates_num+1-LEVEL_HEADER) *
>> _package->children.size())
>>  				+ _package->children.size();
>> -		string cpu_data[cpu_tbl_size.cols * cpu_tbl_size.rows];
>> +		string *cpu_data = new string[cpu_tbl_size.cols * cpu_tbl_size.rows];
>>
>>  		for (core = 0; core < _package->children.size(); core++) {
>>  			cpu_data[idx3]="&nbsp;";
>> @@ -633,6 +633,9 @@ void report_display_cpu_cstates(void)
>>  		init_cpu_table_attr(&std_table_css, title+1, cpu_tbl_size.rows,
>>  				cpu_tbl_size.cols);
>>  		report.add_table(cpu_data, &std_table_css);
>> +		delete [] pkg_data;
>> +		delete [] core_data;
>> +		delete [] cpu_data;
>>  	}
>>  	report.end_div();
>>  }
>
> As a C++ developer with certain experience of sometimes (very) painful
> quality(the last VERY PAINFUL one less than 6 weeks ago...),
> I really wouldn't want to see open-coded, error-prone new/delete (or,
> heaven forbid, malloc/free used in C++ code) in new (pun not intended)
> code anywhere -
> nor non-scoped (omission-prone, return-hampered, exception-unsafe)
> handling
> of any other, possibly more critical resources (think locks, files, ...).
> Therefore I'd strongly recommend changing this patch
> into using properly scoped resource handling such as std::vector
> (std::array should also work, but since that is C++11 only
> I'd prefer std::vector).
> And possibly plus handling of std::bad_alloc cases, in this or outer
> scope...
>
>
> Put differently, one could even say
> that given an automated commit review system
> any appearance of new/delete should automatically make the review fail,
> with subsequent manual white-listing needed for the few rare cases
> that do really want to have it (think class-internal handling of
> resources,
> or some such).
>
>
> That said, thank you very much for enabling clang++ compatibility,
> and for all the other fixes!
> I had wanted to venture into such areas myself, too
> (e.g. for C++ diagnosis reasons), but simply haven't found the time yet.
>
> Andreas Mohr
> _______________________________________________
> PowerTop mailing list
> PowerTop(a)lists.01.org
> https://lists.01.org/mailman/listinfo/powertop
>

Andreas, feel free to submit a patch with this fix.

Thank you,
Alexandra.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Powertop] [PATCH v3 05/15] fix clang++ compilation errors
@ 2014-10-04 20:10 Andreas Mohr
  0 siblings, 0 replies; 7+ messages in thread
From: Andreas Mohr @ 2014-10-04 20:10 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 1859 bytes --]

Hi,

On Sat, Oct 04, 2014 at 03:15:34PM +0100, Sami Kerola wrote:
> On Sat, 4 Oct 2014, Andreas Mohr wrote:
> >So, now that this is documented for other people to be helped,
> >on to documenting README omissions and working on the scoped array handling commit.
> 
> Hi Andreas,
> 
> IMHO it would be better to require new enough automake as part of autotools
> configuration, than add notes to README.  Something like this could do:

Not quite, people actually need to get to know that they need automake at all
(to achieve availability of ./configure) ;)

(was mentioned shortly further below, but that's not enough)

> Apparently some Debian has rather old automake, version 1.7, which is
> causing build from git to fail.

That's just my "historic" Debian installation (18 years and counting).
(bo, woody, slink, hamm or some such?)

Oh crap, my 'puter just managed to get its driver's license ;)
Another 3 years and it will be allowed to drink beer...

> Set the requird automake version to be minimum of 1.11.1, that used to be
> the version GNU coreutils requied before they introduced
> AM_TESTS_ENVIRONMENT that works in 1.11.2 or later.  As powertop does not
> have tests, the earlier GNU coreutils requirement an initial pick for
> this project.

Yup, since we *do* seem to use version-specific functionality,
we likely *should* fend off version issues,
by demanding specific version requirements
in this AM_INIT_AUTOMAKE autoconf macro,
otherwise our behaviour is "improper", "weak".

> p.s. The automake 1.11.1 has been a round since December 2009, so there
> really shouldn't be need for support anything older, like 1.7.9 that was
> released November 2003.

Ouch, that old?


In closing: patch seems fine to me (possibly except for the specific
version number, that is).

Thanks,

Andreas Mohr

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Powertop] [PATCH v3 05/15] fix clang++ compilation errors
@ 2014-10-04 14:19 Sami Kerola
  0 siblings, 0 replies; 7+ messages in thread
From: Sami Kerola @ 2014-10-04 14:19 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 344 bytes --]

On Sat, 4 Oct 2014, Sami Kerola wrote:

> -AM_INIT_AUTOMAKE([-Wall foreign])
> +AM_INIT_AUTOMAKE([
> +	-Wall
> +	1.11.2
> +	foreign
> +])

Uh oh... I meant

s/1.11.2/1.11.1/

But then again even the 1.11.2 is not crazy bleeding edge, so it would 
probably be a fine pick as well.

-- 
Sami Kerola
http://www.iki.fi/kerolasa/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Powertop] [PATCH v3 05/15] fix clang++ compilation errors
@ 2014-10-04 14:15 Sami Kerola
  0 siblings, 0 replies; 7+ messages in thread
From: Sami Kerola @ 2014-10-04 14:15 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 4512 bytes --]

On Sat, 4 Oct 2014, Andreas Mohr wrote:

> On Mon, Sep 29, 2014 at 07:42:28PM -0700, Alexandra Yates wrote:
>>> any appearance of new/delete should automatically make the review fail,
>>> with subsequent manual white-listing needed for the few rare cases
>>> that do really want to have it (think class-internal handling of
>>> resources,
>>> or some such).
>>>
>>>
>>> That said, thank you very much for enabling clang++ compatibility,
>>> and for all the other fixes!
>>> I had wanted to venture into such areas myself, too
>>> (e.g. for C++ diagnosis reasons), but simply haven't found the time yet.
>>>
>>> Andreas Mohr
>>> _______________________________________________
>>> PowerTop mailing list
>>> PowerTop(a)lists.01.org
>>> https://lists.01.org/mailman/listinfo/powertop
>>>
>>
>> Andreas, feel free to submit a patch with this fix.
>
> Right, that seems like a good idea
> (although it's quite a bit of effort,
> and all these areas have been committed now unfortunately).
>
> I started to dive into it (did git pull of my existing
> https://github.com/fenrus75/powertop ), but immediately hit a snag:
>
> README said that I should apply the usual UNIX prayer of
>
>    ./configure
>    make
>    make install
>
> which obviously wasn't possible since in this repo-only content
> the automake step was not done (likely rightfully, I think,
> since these things should nicely fit the local environment,
> but then it should still have been explained in the README).
>
> Running automake then failed (again!! Somehow I knew it, since these things
> magically have a tendency to fail almost always...):
>
> # ./autogen.sh
> autoreconf: Entering directory `.'
> autoreconf: running: autopoint
> autoreconf: running: aclocal  --output=aclocal.m4t
> aclocal: configure.ac: 20: macro `AM_SILENT_RULES' not found in library
> aclocal: macro `AM_PROG_MKDIR_P' required but not defined
> aclocal: macro `AM_PROG_MKDIR_P' required but not defined
> aclocal: macro `_LT_DECL_SED' required but not defined
> aclocal: macro `_LT_FUNC_STRIPNAME_CNF' required but not defined
> autoreconf: aclocal failed with exit status: 1
>
> to which https://forum.videolan.org/viewtopic.php?f=13&t=84261
> had the following wise words to say: "Use automake 1.11".
>
> Fortunately there's an automake1.11 package on Debian, however there's also of course
> the "standard", "canonical version" "automake" package (oh darnit - which I currently
> don't even have installed, oops... can you tell that I'm a CMake guy already? ;)).
> So, since I only had older specific-version automake packages installed
> (a  sufficiently medieval automake1.7),,
> I installed the generic, version-progressing one.
> But it still used the old version prior to an
>    update-alternatives --config automake
> , at which point it worked.
>
> So, now that this is documented for other people to be helped,
> on to documenting README omissions and working on the scoped array handling commit.

Hi Andreas,

IMHO it would be better to require new enough automake as part of 
autotools configuration, than add notes to README.  Something like this 
could do:

--->8----
From: Sami Kerola <kerolasa(a)iki.fi>
Date: Sat, 4 Oct 2014 14:54:23 +0100
Subject: [PATCH] configure: require the least automake version 1.11.1

Apparently some Debian has rather old automake, version 1.7, which is
causing build from git to fail.

Set the requird automake version to be minimum of 1.11.1, that used to be
the version GNU coreutils requied before they introduced
AM_TESTS_ENVIRONMENT that works in 1.11.2 or later.  As powertop does not
have tests, the earlier GNU coreutils requirement an initial pick for
this project.

p.s. The automake 1.11.1 has been a round since December 2009, so there
really shouldn't be need for support anything older, like 1.7.9 that was
released November 2003.

Reported-by: Andreas Mohr <andi(a)lisas.de>
Signed-off-by: Sami Kerola <kerolasa(a)iki.fi>
---
  configure.ac | 6 +++++-
  1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 4991d97..a1dbfb8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3,7 +3,11 @@

  AC_PREREQ([2.68])
  AC_INIT([powertop], [2.6.1], [powertop(a)lists.01.org], [], [https://01.org/powertop])
-AM_INIT_AUTOMAKE([-Wall foreign])
+AM_INIT_AUTOMAKE([
+	-Wall
+	1.11.2
+	foreign
+])
  AC_LANG([C++])
  AC_CONFIG_FILES([
  	Makefile
-- 
2.1.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [Powertop] [PATCH v3 05/15] fix clang++ compilation errors
@ 2014-10-04 11:35 Andreas Mohr
  0 siblings, 0 replies; 7+ messages in thread
From: Andreas Mohr @ 2014-10-04 11:35 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 2919 bytes --]

Hi,

On Mon, Sep 29, 2014 at 07:42:28PM -0700, Alexandra Yates wrote:
> > any appearance of new/delete should automatically make the review fail,
> > with subsequent manual white-listing needed for the few rare cases
> > that do really want to have it (think class-internal handling of
> > resources,
> > or some such).
> >
> >
> > That said, thank you very much for enabling clang++ compatibility,
> > and for all the other fixes!
> > I had wanted to venture into such areas myself, too
> > (e.g. for C++ diagnosis reasons), but simply haven't found the time yet.
> >
> > Andreas Mohr
> > _______________________________________________
> > PowerTop mailing list
> > PowerTop(a)lists.01.org
> > https://lists.01.org/mailman/listinfo/powertop
> >
> 
> Andreas, feel free to submit a patch with this fix.

Right, that seems like a good idea
(although it's quite a bit of effort,
and all these areas have been committed now unfortunately).

I started to dive into it (did git pull of my existing
https://github.com/fenrus75/powertop ), but immediately hit a snag:

README said that I should apply the usual UNIX prayer of

    ./configure
    make
    make install

which obviously wasn't possible since in this repo-only content
the automake step was not done (likely rightfully, I think,
since these things should nicely fit the local environment,
but then it should still have been explained in the README).

Running automake then failed (again!! Somehow I knew it, since these things
magically have a tendency to fail almost always...):

# ./autogen.sh
autoreconf: Entering directory `.'
autoreconf: running: autopoint
autoreconf: running: aclocal  --output=aclocal.m4t
aclocal: configure.ac: 20: macro `AM_SILENT_RULES' not found in library
aclocal: macro `AM_PROG_MKDIR_P' required but not defined
aclocal: macro `AM_PROG_MKDIR_P' required but not defined
aclocal: macro `_LT_DECL_SED' required but not defined
aclocal: macro `_LT_FUNC_STRIPNAME_CNF' required but not defined
autoreconf: aclocal failed with exit status: 1

to which https://forum.videolan.org/viewtopic.php?f=13&t=84261
had the following wise words to say: "Use automake 1.11".

Fortunately there's an automake1.11 package on Debian, however there's also of course
the "standard", "canonical version" "automake" package (oh darnit - which I currently
don't even have installed, oops... can you tell that I'm a CMake guy already? ;)).
So, since I only had older specific-version automake packages installed
(a  sufficiently medieval automake1.7),,
I installed the generic, version-progressing one.
But it still used the old version prior to an
    update-alternatives --config automake
, at which point it worked.

So, now that this is documented for other people to be helped,
on to documenting README omissions and working on the scoped array handling commit.

Andreas Mohr

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Powertop] [PATCH v3 05/15] fix clang++ compilation errors
@ 2014-09-08 19:49 Andreas Mohr
  0 siblings, 0 replies; 7+ messages in thread
From: Andreas Mohr @ 2014-09-08 19:49 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 3342 bytes --]

Hi,

On Sun, Sep 07, 2014 at 02:28:11PM -0700, powertop-request(a)lists.01.org wrote:
> Date: Sun,  7 Sep 2014 22:27:08 +0100
> From: Sami Kerola <kerolasa(a)iki.fi>
> 
> The same error was fixed in multiple files to made clang++ work.
> 
> error: variable length array of non-POD element type 'string' (aka
> 'basic_string<char>')
> 
> Signed-off-by: Sami Kerola <kerolasa(a)iki.fi>

> diff --git a/src/cpu/cpu.cpp b/src/cpu/cpu.cpp
> index dbca20c..4e040c1 100644
> --- a/src/cpu/cpu.cpp
> +++ b/src/cpu/cpu.cpp
> @@ -479,12 +479,12 @@ void report_display_cpu_cstates(void)
>  		/* Tables for PKG, CORE, CPU */
>  		pkg_tbl_size.cols=2;
>  		pkg_tbl_size.rows= ((cstates_num+1)-LEVEL_HEADER)+1;
> -		string pkg_data[pkg_tbl_size.cols * pkg_tbl_size.rows];
> +		string *pkg_data = new string[pkg_tbl_size.cols * pkg_tbl_size.rows];
>  
>  		core_tbl_size.cols=2;
>  		core_tbl_size.rows=(cstates_num *_package->children.size())
>  				+ _package->children.size();
> -		string core_data[core_tbl_size.cols * core_tbl_size.rows];
> +		string *core_data = new string[core_tbl_size.cols * core_tbl_size.rows];
>  		int num_cpus=0, num_cores=0;
>  
>  		for (core = 0; core < _package->children.size(); core++) {
> @@ -506,7 +506,7 @@ void report_display_cpu_cstates(void)
>  		cpu_tbl_size.cols=(2 * (num_cpus / num_cores)) + 1;
>  		cpu_tbl_size.rows = ((cstates_num+1-LEVEL_HEADER) * _package->children.size())
>  				+ _package->children.size();
> -		string cpu_data[cpu_tbl_size.cols * cpu_tbl_size.rows];
> +		string *cpu_data = new string[cpu_tbl_size.cols * cpu_tbl_size.rows];
>  
>  		for (core = 0; core < _package->children.size(); core++) {
>  			cpu_data[idx3]="&nbsp;";
> @@ -633,6 +633,9 @@ void report_display_cpu_cstates(void)
>  		init_cpu_table_attr(&std_table_css, title+1, cpu_tbl_size.rows,
>  				cpu_tbl_size.cols);
>  		report.add_table(cpu_data, &std_table_css);
> +		delete [] pkg_data;
> +		delete [] core_data;
> +		delete [] cpu_data;
>  	}
>  	report.end_div();
>  }

As a C++ developer with certain experience of sometimes (very) painful quality(the last VERY PAINFUL one less than 6 weeks ago...),
I really wouldn't want to see open-coded, error-prone new/delete (or, heaven forbid, malloc/free used in C++ code) in new (pun not intended) code anywhere -
nor non-scoped (omission-prone, return-hampered, exception-unsafe) handling
of any other, possibly more critical resources (think locks, files, ...).
Therefore I'd strongly recommend changing this patch
into using properly scoped resource handling such as std::vector
(std::array should also work, but since that is C++11 only
I'd prefer std::vector).
And possibly plus handling of std::bad_alloc cases, in this or outer scope...


Put differently, one could even say
that given an automated commit review system
any appearance of new/delete should automatically make the review fail,
with subsequent manual white-listing needed for the few rare cases
that do really want to have it (think class-internal handling of resources,
or some such).


That said, thank you very much for enabling clang++ compatibility,
and for all the other fixes!
I had wanted to venture into such areas myself, too
(e.g. for C++ diagnosis reasons), but simply haven't found the time yet.

Andreas Mohr

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Powertop] [PATCH v3 05/15] fix clang++ compilation errors
@ 2014-09-07 21:27 Sami Kerola
  0 siblings, 0 replies; 7+ messages in thread
From: Sami Kerola @ 2014-09-07 21:27 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 10268 bytes --]

The same error was fixed in multiple files to made clang++ work.

error: variable length array of non-POD element type 'string' (aka
'basic_string<char>')

Signed-off-by: Sami Kerola <kerolasa(a)iki.fi>
---
 src/cpu/cpu.cpp            | 18 ++++++++++++------
 src/devices/ahci.cpp       |  3 ++-
 src/devices/device.cpp     |  6 ++++--
 src/devlist.cpp            |  3 ++-
 src/process/do_process.cpp |  9 ++++++---
 src/report/report.cpp      |  3 ++-
 src/tuning/tuning.cpp      | 10 ++++++----
 7 files changed, 34 insertions(+), 18 deletions(-)

diff --git a/src/cpu/cpu.cpp b/src/cpu/cpu.cpp
index dbca20c..4e040c1 100644
--- a/src/cpu/cpu.cpp
+++ b/src/cpu/cpu.cpp
@@ -479,12 +479,12 @@ void report_display_cpu_cstates(void)
 		/* Tables for PKG, CORE, CPU */
 		pkg_tbl_size.cols=2;
 		pkg_tbl_size.rows= ((cstates_num+1)-LEVEL_HEADER)+1;
-		string pkg_data[pkg_tbl_size.cols * pkg_tbl_size.rows];
+		string *pkg_data = new string[pkg_tbl_size.cols * pkg_tbl_size.rows];
 
 		core_tbl_size.cols=2;
 		core_tbl_size.rows=(cstates_num *_package->children.size())
 				+ _package->children.size();
-		string core_data[core_tbl_size.cols * core_tbl_size.rows];
+		string *core_data = new string[core_tbl_size.cols * core_tbl_size.rows];
 		int num_cpus=0, num_cores=0;
 
 		for (core = 0; core < _package->children.size(); core++) {
@@ -506,7 +506,7 @@ void report_display_cpu_cstates(void)
 		cpu_tbl_size.cols=(2 * (num_cpus / num_cores)) + 1;
 		cpu_tbl_size.rows = ((cstates_num+1-LEVEL_HEADER) * _package->children.size())
 				+ _package->children.size();
-		string cpu_data[cpu_tbl_size.cols * cpu_tbl_size.rows];
+		string *cpu_data = new string[cpu_tbl_size.cols * cpu_tbl_size.rows];
 
 		for (core = 0; core < _package->children.size(); core++) {
 			cpu_data[idx3]="&nbsp;";
@@ -633,6 +633,9 @@ void report_display_cpu_cstates(void)
 		init_cpu_table_attr(&std_table_css, title+1, cpu_tbl_size.rows,
 				cpu_tbl_size.cols);
 		report.add_table(cpu_data, &std_table_css);
+		delete [] pkg_data;
+		delete [] core_data;
+		delete [] cpu_data;
 	}
 	report.end_div();
 }
@@ -688,11 +691,11 @@ void report_display_cpu_pstates(void)
 		/*  Tables for PKG, CORE, CPU */
 		pkg_tbl_size.cols=2;
 		pkg_tbl_size.rows=((pstates_num+1)-LEVEL_HEADER)+2;
-		string pkg_data[pkg_tbl_size.cols * pkg_tbl_size.rows];
+		string *pkg_data = new string[pkg_tbl_size.cols * pkg_tbl_size.rows];
 
 		core_tbl_size.cols=2;
 		core_tbl_size.rows=((pstates_num+2) *_package->children.size());
-		string core_data[core_tbl_size.cols * core_tbl_size.rows];
+		string *core_data = new string[core_tbl_size.cols * core_tbl_size.rows];
 
 		/* PKG */
 		num_cpus=0;
@@ -717,7 +720,7 @@ void report_display_cpu_pstates(void)
 		cpu_tbl_size.cols= (num_cpus/ num_cores) + 1;
 		cpu_tbl_size.rows= (pstates_num+2) * _package->children.size()
 				+ _package->children.size();
-		string cpu_data[cpu_tbl_size.cols * cpu_tbl_size.rows];
+		string *cpu_data = new string[cpu_tbl_size.cols * cpu_tbl_size.rows];
 
 		/* Core */
 		for (core = 0; core < _package->children.size(); core++) {
@@ -818,6 +821,9 @@ void report_display_cpu_pstates(void)
 		init_cpu_table_attr(&std_table_css, title,
 				cpu_tbl_size.rows, cpu_tbl_size.cols);
 		report.add_table(cpu_data, &std_table_css);
+		delete [] pkg_data;
+		delete [] core_data;
+		delete [] cpu_data;
 	}
 	report.end_div();
 }
diff --git a/src/devices/ahci.cpp b/src/devices/ahci.cpp
index a4d1345..72e889f 100644
--- a/src/devices/ahci.cpp
+++ b/src/devices/ahci.cpp
@@ -384,7 +384,7 @@ void ahci_create_device_stats_table(void)
 
 
 	/* Set array of data in row Major order */
-	string ahci_data[cols * rows];
+	string *ahci_data = new string[cols * rows];
 	ahci_data[0]=__("Link");
 	ahci_data[1]=__("Active");
 	ahci_data[2]=__("Partial");
@@ -398,6 +398,7 @@ void ahci_create_device_stats_table(void)
 	report.add_title(&title_attr, __("AHCI ALPM Residency Statistics"));
 	report.add_table(ahci_data, &std_table_css);
 	report.end_div();
+	delete [] ahci_data;
 }
 
 void ahci::report_device_stats(string *ahci_data, int idx)
diff --git a/src/devices/device.cpp b/src/devices/device.cpp
index da595a8..b4765ef 100644
--- a/src/devices/device.cpp
+++ b/src/devices/device.cpp
@@ -247,7 +247,7 @@ void show_report_devices(void)
 
 	/* Device Summary */
 	int summary_size=2;
-        string summary[summary_size];
+	string *summary = new string[summary_size];
 	pw = global_joules_consumed();
 	char buf[32];
 	if (pw > 0.0001) {
@@ -263,9 +263,10 @@ void show_report_devices(void)
 		summary[1].append(" W");
 		report.add_summary_list(summary, summary_size);
 	}
+	delete [] summary;
 
         /* Set array of data in row Major order */
-	string device_data[cols * rows];
+	string *device_data = new string[cols * rows];
 	device_data[0]= __("Usage");
 	device_data[1]= __("Device Name");
 	if (show_power)
@@ -308,6 +309,7 @@ void show_report_devices(void)
 	/* Report Output */
 	report.add_title(&title_attr, __("Device Power Report"));
 	report.add_table(device_data, &std_table_css);
+	delete [] device_data;
 }
 
 
diff --git a/src/devlist.cpp b/src/devlist.cpp
index 21b4c1c..20fe5da 100644
--- a/src/devlist.cpp
+++ b/src/devlist.cpp
@@ -326,7 +326,7 @@ void report_show_open_devices(void)
 	init_title_attr(&title_attr);
 
 	/* Set array of data in row Major order */
-	string process_data[cols * rows];
+	string *process_data = new string[cols * rows];
 
 	sort(target->begin(), target->end(), devlist_sort);
 	process_data[0]=__("Process");
@@ -348,5 +348,6 @@ void report_show_open_devices(void)
 	/* No div attribute here inherits from device power report */
 	report.add_title(&title_attr, __("Process Device Activity"));
 	report.add_table(process_data, &std_table_css);
+	delete [] process_data;
 	report.end_div();
 }
diff --git a/src/process/do_process.cpp b/src/process/do_process.cpp
index f7f9765..8d55507 100644
--- a/src/process/do_process.cpp
+++ b/src/process/do_process.cpp
@@ -918,7 +918,7 @@ void report_process_update_display(void)
 	init_title_attr(&title_attr);
 
 	/* Set array of data in row Major order */
-	string  software_data[cols * rows];
+	string *software_data = new string[cols * rows];
 	software_data[0]=__("Usage");
 	software_data[1]=__("Wakeups/s");
 	software_data[2]=__("GPU ops/s");
@@ -1013,6 +1013,7 @@ void report_process_update_display(void)
 	report.add_title(&title_attr, __("Overview of Software Power Consumers"));
 	report.add_table(software_data, &std_table_css);
         report.end_div();
+	delete [] software_data;
 }
 
 void report_summary(void)
@@ -1048,7 +1049,7 @@ void report_summary(void)
 
 	/* Set array for summary */
 	int summary_size =12;
-	string summary[summary_size];
+	string *summary = new string [summary_size];
 	summary[0]=__("Target:");
 	summary[1]=__("1 units/s");
 	summary[2]=__("System: ");
@@ -1068,7 +1069,7 @@ void report_summary(void)
 	summary[11].append(__(" ops/s"));
 
 	/* Set array of data in row Major order */
-	string summary_data[cols * (rows+1)];
+	string *summary_data = new string[cols * (rows + 1)];
 	summary_data[0]=__("Usage");
 	summary_data[1]=__("Events/s");
 	summary_data[2]=__("Category");
@@ -1134,6 +1135,8 @@ void report_summary(void)
 	report.add_title(&title_attr, __("Top 10 Power Consumers"));
 	report.add_table(summary_data, &std_table_css);
 	report.end_div();
+	delete [] summary;
+	delete [] summary_data;
 }
 
 
diff --git a/src/report/report.cpp b/src/report/report.cpp
index d55531e..981e984 100644
--- a/src/report/report.cpp
+++ b/src/report/report.cpp
@@ -115,7 +115,7 @@ static void system_info(void)
         init_title_attr(&title_attr);
 
 	/* Set array of data in row Major order */
-	string system_data[sys_table.rows * sys_table.cols];
+	string *system_data = new string[sys_table.rows * sys_table.cols];
 	system_data[0]=__("PowerTOP Version");
 	system_data[1]=POWERTOP_VERSION;
 
@@ -159,6 +159,7 @@ static void system_info(void)
 	report.end_div();
 	report.end_header();
 	report.add_navigation();
+	delete [] system_data;
 }
 
 void init_report_output(char *filename_str, int iterations)
diff --git a/src/tuning/tuning.cpp b/src/tuning/tuning.cpp
index 6367a20..85b80ac 100644
--- a/src/tuning/tuning.cpp
+++ b/src/tuning/tuning.cpp
@@ -230,7 +230,7 @@ void report_show_tunables(void)
 		init_tune_table_attr(&tune_table_css, rows, cols);
 
 		/* Set array of data in row Major order */
-		string tunable_data[cols * rows];
+		string *tunable_data = new string[cols * rows];
 
 		tunable_data[0]=__("Description");
 		tunable_data[1]=__("Script");
@@ -249,6 +249,7 @@ void report_show_tunables(void)
 		/* Report Output */
 		report.add_title(&title_attr,__("Software Settings in Need of Tuning"));
 		report.add_table(tunable_data, &tune_table_css);
+		delete [] tunable_data;
 	}
 
 	/* Second Table */
@@ -258,7 +259,7 @@ void report_show_tunables(void)
 	init_tune_table_attr(&tune_table_css, rows, cols);
 
 	/* Set array of data in row Major order */
-	string untunable_data[rows];
+	string *untunable_data = new string[rows];
 	untunable_data[0]=__("Description");
 
 	for (i = 0; i < all_untunables.size(); i++)
@@ -267,6 +268,7 @@ void report_show_tunables(void)
 	/* Report Output */
 	report.add_title(&title_attr,__("Untunable Software Issues"));
 	report.add_table(untunable_data, &tune_table_css);
+	delete [] untunable_data;
 
 	/* Third Table */
 	/* Set Table attributes, rows, and cols */
@@ -275,7 +277,7 @@ void report_show_tunables(void)
 	init_std_table_attr(&tune_table_css, rows, cols);
 
 	/* Set array of data in row Major order */
-	string tuned_data[rows];
+	string *tuned_data = new string[rows];
 	tuned_data[0]=__("Description");
 	idx=cols;
 	for (i = 0; i < all_tunables.size(); i++) {
@@ -291,7 +293,7 @@ void report_show_tunables(void)
 	report.add_title(&title_attr,__("Optimal Tuned Software Settings"));
         report.add_table(tuned_data, &tune_table_css);
         report.end_div();
-
+	delete [] tuned_data;
 }
 
 void clear_tuning()
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-10-04 20:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-30  2:42 [Powertop] [PATCH v3 05/15] fix clang++ compilation errors Alexandra Yates
  -- strict thread matches above, loose matches on Subject: below --
2014-10-04 20:10 Andreas Mohr
2014-10-04 14:19 Sami Kerola
2014-10-04 14:15 Sami Kerola
2014-10-04 11:35 Andreas Mohr
2014-09-08 19:49 Andreas Mohr
2014-09-07 21:27 Sami Kerola

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.