All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [Powertop] [PATCH 1/2] Updates to support Android platform
@ 2012-09-17 16:28 Chris Ferron
  0 siblings, 0 replies; 13+ messages in thread
From: Chris Ferron @ 2012-09-17 16:28 UTC (permalink / raw)
  To: powertop

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

On 09/17/2012 07:34 AM, Rajagopal Venkat wrote:
>   
>   #include "devices/device.h"
> diff --git a/src/process/do_process.cpp b/src/process/do_process.cpp
> index eaef7f1..c9d6b0b 100644
> --- a/src/process/do_process.cpp
> +++ b/src/process/do_process.cpp
> @@ -869,7 +869,7 @@ void process_update_display(void)
>   		if (!show_power)
>   			strcpy(power, "          ");
>   		sprintf(name, "%s", all_power[i]->type());
> -		while (mbstowcs(NULL,name,0) < 14) strcat(name, " ");
> +		while (mbstowcs(NULL,name,20) < 14) strcat(name, " ");
>   
mbstowcs(NULL,name,0) is a test. return will be count. while catches the 
error.

>   
>   		if (all_power[i]->events() == 0 && all_power[i]->usage() == 0 && all_power[i]->Witts() == 0)
> @@ -882,7 +882,7 @@ void process_update_display(void)
>   			else
>   				sprintf(usage, "%5i%s", (int)all_power[i]->usage(), all_power[i]->usage_units());
>   		}
> -		while (mbstowcs(NULL,usage,0) < 14) strcat(usage, " ");
> +		while (mbstowcs(NULL,usage,20) < 14) strcat(usage, " ");
>   		sprintf(events, "%5.1f", all_power[i]->events());
>   		if (!all_power[i]->show_events())
>   			events[0] = 0;


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

* Re: [Powertop] [PATCH 1/2] Updates to support Android platform
@ 2012-09-24 12:22 Rajagopal Venkat
  0 siblings, 0 replies; 13+ messages in thread
From: Rajagopal Venkat @ 2012-09-24 12:22 UTC (permalink / raw)
  To: powertop

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

On 18 September 2012 18:56, Arjan van de Ven <arjan(a)linux.intel.com> wrote:
> On 9/17/2012 10:53 PM, Rajagopal Venkat wrote:
>> On 18 September 2012 10:53, Magnus Fromreide <magfr(a)lysator.liu.se> wrote:
>>> On Tue, 2012-09-18 at 09:54 +0530, Rajagopal Venkat wrote:
>>>> On 17 September 2012 21:58, Chris Ferron <chris.e.ferron(a)linux.intel.com> wrote:
>>>>> On 09/17/2012 07:34 AM, Rajagopal Venkat wrote:
>>>>>>
>>>>>>     #include "devices/device.h"
>>>>>> diff --git a/src/process/do_process.cpp b/src/process/do_process.cpp
>>>>>> index eaef7f1..c9d6b0b 100644
>>>>>> --- a/src/process/do_process.cpp
>>>>>> +++ b/src/process/do_process.cpp
>>>>>> @@ -869,7 +869,7 @@ void process_update_display(void)
>>>>>>                 if (!show_power)
>>>>>>                         strcpy(power, "          ");
>>>>>>                 sprintf(name, "%s", all_power[i]->type());
>>>>>> -               while (mbstowcs(NULL,name,0) < 14) strcat(name, " ");
>>>>>> +               while (mbstowcs(NULL,name,20) < 14) strcat(name, " ");
>>>>>>
>>>>>
>>>>> mbstowcs(NULL,name,0) is a test. return will be count. while catches the
>>>>> error.
>>>>
>>>> Agree. The Android bionic libc version of mbstowcs always returns zero if
>>>> max(third parameter) is zero, resulting in infinite loop.
>>>
>>> Have you reported the bug in the library to Google? If the first
>>> argument is NULL posix says the third argument should be ignored.
>>
>> I don't see bionic libc claiming to be posix compliant.
>
> can you make a small wrapper in your android compat header to cope with this case?
> (in the idea of keeping all the junk to work around a buggy platform in one place)
>

Next patch version will add this.

>
>



-- 
Regards,
Rajagopal

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

* Re: [Powertop] [PATCH 1/2] Updates to support Android platform
@ 2012-09-18 13:26 Arjan van de Ven
  0 siblings, 0 replies; 13+ messages in thread
From: Arjan van de Ven @ 2012-09-18 13:26 UTC (permalink / raw)
  To: powertop

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

On 9/17/2012 10:53 PM, Rajagopal Venkat wrote:
> On 18 September 2012 10:53, Magnus Fromreide <magfr(a)lysator.liu.se> wrote:
>> On Tue, 2012-09-18 at 09:54 +0530, Rajagopal Venkat wrote:
>>> On 17 September 2012 21:58, Chris Ferron <chris.e.ferron(a)linux.intel.com> wrote:
>>>> On 09/17/2012 07:34 AM, Rajagopal Venkat wrote:
>>>>>
>>>>>     #include "devices/device.h"
>>>>> diff --git a/src/process/do_process.cpp b/src/process/do_process.cpp
>>>>> index eaef7f1..c9d6b0b 100644
>>>>> --- a/src/process/do_process.cpp
>>>>> +++ b/src/process/do_process.cpp
>>>>> @@ -869,7 +869,7 @@ void process_update_display(void)
>>>>>                 if (!show_power)
>>>>>                         strcpy(power, "          ");
>>>>>                 sprintf(name, "%s", all_power[i]->type());
>>>>> -               while (mbstowcs(NULL,name,0) < 14) strcat(name, " ");
>>>>> +               while (mbstowcs(NULL,name,20) < 14) strcat(name, " ");
>>>>>
>>>>
>>>> mbstowcs(NULL,name,0) is a test. return will be count. while catches the
>>>> error.
>>>
>>> Agree. The Android bionic libc version of mbstowcs always returns zero if
>>> max(third parameter) is zero, resulting in infinite loop.
>>
>> Have you reported the bug in the library to Google? If the first
>> argument is NULL posix says the third argument should be ignored.
> 
> I don't see bionic libc claiming to be posix compliant.

can you make a small wrapper in your android compat header to cope with this case?
(in the idea of keeping all the junk to work around a buggy platform in one place)




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

* Re: [Powertop] [PATCH 1/2] Updates to support Android platform
@ 2012-09-18  8:11 Sergey Senozhatsky
  0 siblings, 0 replies; 13+ messages in thread
From: Sergey Senozhatsky @ 2012-09-18  8:11 UTC (permalink / raw)
  To: powertop

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

On (09/18/12 11:28), Rajagopal Venkat wrote:
> >> >
> >> Android doesn't support C++ exception handling. Here is the Android official
> >> answer [1]. This is the reason for having DISABLE_TRYCATCH macro in
> >> powertop code which were removed in recent commit.
> >>
> >> [1] https://groups.google.com/forum/?fromgroups=#!topic/android-ndk/idtn7R-_ZFA
> >
> > That reference is two years old and it ends with a note that they will
> > try to enable exception handling for user space programs. Have anything
> > happened on that part in these last two years?
> 
> I don't think it is yet there. Here is another reference[2],
> "Android does not yet support C++ exceptions".
> 
> [2] http://developer.android.com/guide/practices/jni.html
> 

so... we endup in need to support non-POSIX C runtime and non-ISO C++.


	-ss

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

* Re: [Powertop] [PATCH 1/2] Updates to support Android platform
@ 2012-09-18  5:58 Rajagopal Venkat
  0 siblings, 0 replies; 13+ messages in thread
From: Rajagopal Venkat @ 2012-09-18  5:58 UTC (permalink / raw)
  To: powertop

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

On 18 September 2012 11:13, Magnus Fromreide <magfr(a)lysator.liu.se> wrote:
> On Tue, 2012-09-18 at 09:20 +0530, Rajagopal Venkat wrote:
>> On 17 September 2012 21:29, Arjan van de Ven <arjan(a)linux.intel.com> wrote:
>> >
>> >
>> Android doesn't support C++ exception handling. Here is the Android official
>> answer [1]. This is the reason for having DISABLE_TRYCATCH macro in
>> powertop code which were removed in recent commit.
>>
>> [1] https://groups.google.com/forum/?fromgroups=#!topic/android-ndk/idtn7R-_ZFA
>
> That reference is two years old and it ends with a note that they will
> try to enable exception handling for user space programs. Have anything
> happened on that part in these last two years?

I don't think it is yet there. Here is another reference[2],
"Android does not yet support C++ exceptions".

[2] http://developer.android.com/guide/practices/jni.html

>
> /MF
>



-- 
Regards,
Rajagopal

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

* Re: [Powertop] [PATCH 1/2] Updates to support Android platform
@ 2012-09-18  5:53 Rajagopal Venkat
  0 siblings, 0 replies; 13+ messages in thread
From: Rajagopal Venkat @ 2012-09-18  5:53 UTC (permalink / raw)
  To: powertop

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

On 18 September 2012 10:53, Magnus Fromreide <magfr(a)lysator.liu.se> wrote:
> On Tue, 2012-09-18 at 09:54 +0530, Rajagopal Venkat wrote:
>> On 17 September 2012 21:58, Chris Ferron <chris.e.ferron(a)linux.intel.com> wrote:
>> > On 09/17/2012 07:34 AM, Rajagopal Venkat wrote:
>> >>
>> >>     #include "devices/device.h"
>> >> diff --git a/src/process/do_process.cpp b/src/process/do_process.cpp
>> >> index eaef7f1..c9d6b0b 100644
>> >> --- a/src/process/do_process.cpp
>> >> +++ b/src/process/do_process.cpp
>> >> @@ -869,7 +869,7 @@ void process_update_display(void)
>> >>                 if (!show_power)
>> >>                         strcpy(power, "          ");
>> >>                 sprintf(name, "%s", all_power[i]->type());
>> >> -               while (mbstowcs(NULL,name,0) < 14) strcat(name, " ");
>> >> +               while (mbstowcs(NULL,name,20) < 14) strcat(name, " ");
>> >>
>> >
>> > mbstowcs(NULL,name,0) is a test. return will be count. while catches the
>> > error.
>>
>> Agree. The Android bionic libc version of mbstowcs always returns zero if
>> max(third parameter) is zero, resulting in infinite loop.
>
> Have you reported the bug in the library to Google? If the first
> argument is NULL posix says the third argument should be ignored.

I don't see bionic libc claiming to be posix compliant.
>
> What happens if 'name' is more than 20 characters? It shouldn't affect
> this use of mbstowcs but there might be others.
>
>> I believe this change should not cause any adverse effect on current behavior.
>> The mbstowcs would stop parsing source string when it encounters null-character
>> or max len. Atleast I didn't observe any change in return value(count).
>
> It shouldn't change the behaviour since mbstowcs is required to ignore
> it's third argument if the first argument is NULL.
As there is no change in current behaviour. Can this be considered for
supporting
Android?

>
> /MF
>



-- 
Regards,
Rajagopal

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

* Re: [Powertop] [PATCH 1/2] Updates to support Android platform
@ 2012-09-18  5:43 Magnus Fromreide
  0 siblings, 0 replies; 13+ messages in thread
From: Magnus Fromreide @ 2012-09-18  5:43 UTC (permalink / raw)
  To: powertop

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

On Tue, 2012-09-18 at 09:20 +0530, Rajagopal Venkat wrote:
> On 17 September 2012 21:29, Arjan van de Ven <arjan(a)linux.intel.com> wrote:
> >
> >
> Android doesn't support C++ exception handling. Here is the Android official
> answer [1]. This is the reason for having DISABLE_TRYCATCH macro in
> powertop code which were removed in recent commit.
> 
> [1] https://groups.google.com/forum/?fromgroups=#!topic/android-ndk/idtn7R-_ZFA

That reference is two years old and it ends with a note that they will
try to enable exception handling for user space programs. Have anything
happened on that part in these last two years?

/MF


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

* Re: [Powertop] [PATCH 1/2] Updates to support Android platform
@ 2012-09-18  5:23 Magnus Fromreide
  0 siblings, 0 replies; 13+ messages in thread
From: Magnus Fromreide @ 2012-09-18  5:23 UTC (permalink / raw)
  To: powertop

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

On Tue, 2012-09-18 at 09:54 +0530, Rajagopal Venkat wrote:
> On 17 September 2012 21:58, Chris Ferron <chris.e.ferron(a)linux.intel.com> wrote:
> > On 09/17/2012 07:34 AM, Rajagopal Venkat wrote:
> >>
> >>     #include "devices/device.h"
> >> diff --git a/src/process/do_process.cpp b/src/process/do_process.cpp
> >> index eaef7f1..c9d6b0b 100644
> >> --- a/src/process/do_process.cpp
> >> +++ b/src/process/do_process.cpp
> >> @@ -869,7 +869,7 @@ void process_update_display(void)
> >>                 if (!show_power)
> >>                         strcpy(power, "          ");
> >>                 sprintf(name, "%s", all_power[i]->type());
> >> -               while (mbstowcs(NULL,name,0) < 14) strcat(name, " ");
> >> +               while (mbstowcs(NULL,name,20) < 14) strcat(name, " ");
> >>
> >
> > mbstowcs(NULL,name,0) is a test. return will be count. while catches the
> > error.
> 
> Agree. The Android bionic libc version of mbstowcs always returns zero if
> max(third parameter) is zero, resulting in infinite loop.

Have you reported the bug in the library to Google? If the first
argument is NULL posix says the third argument should be ignored.

What happens if 'name' is more than 20 characters? It shouldn't affect
this use of mbstowcs but there might be others.

> I believe this change should not cause any adverse effect on current behavior.
> The mbstowcs would stop parsing source string when it encounters null-character
> or max len. Atleast I didn't observe any change in return value(count).

It shouldn't change the behaviour since mbstowcs is required to ignore
it's third argument if the first argument is NULL.

/MF


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

* Re: [Powertop] [PATCH 1/2] Updates to support Android platform
@ 2012-09-18  4:24 Rajagopal Venkat
  0 siblings, 0 replies; 13+ messages in thread
From: Rajagopal Venkat @ 2012-09-18  4:24 UTC (permalink / raw)
  To: powertop

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

On 17 September 2012 21:58, Chris Ferron <chris.e.ferron(a)linux.intel.com> wrote:
> On 09/17/2012 07:34 AM, Rajagopal Venkat wrote:
>>
>>     #include "devices/device.h"
>> diff --git a/src/process/do_process.cpp b/src/process/do_process.cpp
>> index eaef7f1..c9d6b0b 100644
>> --- a/src/process/do_process.cpp
>> +++ b/src/process/do_process.cpp
>> @@ -869,7 +869,7 @@ void process_update_display(void)
>>                 if (!show_power)
>>                         strcpy(power, "          ");
>>                 sprintf(name, "%s", all_power[i]->type());
>> -               while (mbstowcs(NULL,name,0) < 14) strcat(name, " ");
>> +               while (mbstowcs(NULL,name,20) < 14) strcat(name, " ");
>>
>
> mbstowcs(NULL,name,0) is a test. return will be count. while catches the
> error.

Agree. The Android bionic libc version of mbstowcs always returns zero if
max(third parameter) is zero, resulting in infinite loop.

I believe this change should not cause any adverse effect on current behavior.
The mbstowcs would stop parsing source string when it encounters null-character
or max len. Atleast I didn't observe any change in return value(count).

>
>
>>                 if (all_power[i]->events() == 0 && all_power[i]->usage()
>> == 0 && all_power[i]->Witts() == 0)
>> @@ -882,7 +882,7 @@ void process_update_display(void)
>>                         else
>>                                 sprintf(usage, "%5i%s",
>> (int)all_power[i]->usage(), all_power[i]->usage_units());
>>                 }
>> -               while (mbstowcs(NULL,usage,0) < 14) strcat(usage, " ");
>> +               while (mbstowcs(NULL,usage,20) < 14) strcat(usage, " ");
>>                 sprintf(events, "%5.1f", all_power[i]->events());
>>                 if (!all_power[i]->show_events())
>>                         events[0] = 0;
>
>
> _______________________________________________
> PowerTop mailing list
> PowerTop(a)lists.01.org
> https://lists.01.org/mailman/listinfo/powertop



-- 
Regards,
Rajagopal

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

* Re: [Powertop] [PATCH 1/2] Updates to support Android platform
@ 2012-09-18  3:50 Rajagopal Venkat
  0 siblings, 0 replies; 13+ messages in thread
From: Rajagopal Venkat @ 2012-09-18  3:50 UTC (permalink / raw)
  To: powertop

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

On 17 September 2012 21:29, Arjan van de Ven <arjan(a)linux.intel.com> wrote:
>
>> Hi,
>> I don't have exp with android development.
>> this is not the first time we have exception related patches in order to support android.
>> I just wonder -- what's wrong with C++ in general (and exception handling in particular)
>> in android?
>
> yeah this looks extremely fragile
>
> +/* define stubs for C++ exception handling */
> +#define try            if (true)
> +#define catch(x)       if (false)
> +
>
> I mean.. this really is wrong.
> Is C++ on Android really so broken that try/catch do not work ???
>
> what else is terminal in the C++ implementation on android then?
>
Android doesn't support C++ exception handling. Here is the Android official
answer [1]. This is the reason for having DISABLE_TRYCATCH macro in
powertop code which were removed in recent commit.

[1] https://groups.google.com/forum/?fromgroups=#!topic/android-ndk/idtn7R-_ZFA

-- 
Regards,
Rajagopal

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

* Re: [Powertop] [PATCH 1/2] Updates to support Android platform
@ 2012-09-17 15:59 Arjan van de Ven
  0 siblings, 0 replies; 13+ messages in thread
From: Arjan van de Ven @ 2012-09-17 15:59 UTC (permalink / raw)
  To: powertop

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


> Hi,
> I don't have exp with android development.
> this is not the first time we have exception related patches in order to support android.
> I just wonder -- what's wrong with C++ in general (and exception handling in particular) 
> in android?

yeah this looks extremely fragile

+/* define stubs for C++ exception handling */
+#define try     	if (true)
+#define catch(x) 	if (false)
+

I mean.. this really is wrong.
Is C++ on Android really so broken that try/catch do not work ???

what else is terminal in the C++ implementation on android then?


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

* Re: [Powertop] [PATCH 1/2] Updates to support Android platform
@ 2012-09-17 14:54 Sergey Senozhatsky
  0 siblings, 0 replies; 13+ messages in thread
From: Sergey Senozhatsky @ 2012-09-17 14:54 UTC (permalink / raw)
  To: powertop

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

On (09/17/12 20:04), Rajagopal Venkat wrote:
> This patch adds following minor changes to prepare powertop
> to support Android platform.
> 
> - add missing HAVE_CONFIG_H conditional check.
> - remove un-used ethtool_cmd_speed_set and ethtool_cmd_speed
> functions.
> - minimize dependency on exception handling in catch blocks.
> 
> These changes will not affect powertop functionality.
> 
> Signed-off-by: Rajagopal Venkat <rajagopal.venkat(a)linaro.org>
> ---
>  src/devices/ahci.cpp       |    4 ++--
>  src/devices/alsa.cpp       |    4 ++--
>  src/devices/network.cpp    |   16 ----------------
>  src/lib.cpp                |    2 +-
>  src/main.cpp               |    2 ++
>  src/process/do_process.cpp |    4 ++--
>  6 files changed, 9 insertions(+), 23 deletions(-)
> 
> diff --git a/src/devices/ahci.cpp b/src/devices/ahci.cpp
> index 1fe39c7..67ce06e 100644
> --- a/src/devices/ahci.cpp
> +++ b/src/devices/ahci.cpp
> @@ -170,7 +170,7 @@ void ahci::start_measurement(void)
>  		file.close();
>  	}
>  	catch (std::ios_base::failure &c) {
> -		fprintf(stderr, "%s\n", c.what());
> +		fprintf(stderr, "Failed to start measurement for ahci device\n");
>  	}
>  

Hi,
I don't have exp with android development.
this is not the first time we have exception related patches in order to support android.
I just wonder -- what's wrong with C++ in general (and exception handling in particular) 
in android?


	-ss

>  }
> @@ -203,7 +203,7 @@ void ahci::end_measurement(void)
>  		file.close();
>  	}
>  	catch (std::ios_base::failure &c) {
> -		fprintf(stderr, "%s\n", c.what());
> +		fprintf(stderr, "Failed to end measurement for ahci device\n");
>  	}
>  	if (end_active < start_active)
>  		end_active = start_active;
> diff --git a/src/devices/alsa.cpp b/src/devices/alsa.cpp
> index 4f5d3f9..a67780c 100644
> --- a/src/devices/alsa.cpp
> +++ b/src/devices/alsa.cpp
> @@ -104,7 +104,7 @@ void alsa::start_measurement(void)
>  		file.close();
>  	}
>  	catch (std::ios_base::failure &c) {
> -		fprintf(stderr, "%s\n", c.what());
> +		fprintf(stderr, "Failed to start measurement for alsa device\n");
>  	}
>  }
>  
> @@ -130,7 +130,7 @@ void alsa::end_measurement(void)
>  		file.close();
>  	}
>  	catch (std::ios_base::failure &c) {
> -		fprintf(stderr, "%s\n", c.what());
> +		fprintf(stderr, "Failed to end measurement for alsa device\n");
>  	}
>  
>  	p = (end_active - start_active) / (0.001 + end_active + end_inactive - start_active - start_inactive) * 100.0;
> diff --git a/src/devices/network.cpp b/src/devices/network.cpp
> index b8a5c9c..ed9d7aa 100644
> --- a/src/devices/network.cpp
> +++ b/src/devices/network.cpp
> @@ -55,22 +55,6 @@ extern "C" {
>  
>  static map<string, class network *> nics;
>  
> -#ifdef DISABLE_TRYCATCH
> -
> -static inline void ethtool_cmd_speed_set(struct ethtool_cmd *ep,
> -						__u32 speed)
> -{
> -
> -	ep->speed = (__u16)speed;
> -	ep->speed_hi = (__u16)(speed >> 16);
> -}
> -
> -static inline __u32 ethtool_cmd_speed(struct ethtool_cmd *ep)
> -{
> -	return (ep->speed_hi << 16) | ep->speed;
> -}
> -
> -#endif
>  
>  static void do_proc_net_dev(void)
>  {
> diff --git a/src/lib.cpp b/src/lib.cpp
> index 9838c0b..776a67b 100644
> --- a/src/lib.cpp
> +++ b/src/lib.cpp
> @@ -259,7 +259,7 @@ void format_watts(double W, char *buffer, unsigned int len)
>  	if (W < 0.0001)
>  		sprintf(buffer, _("    0 mW"));
>  
> -	while (mbstowcs(NULL,buffer,0) < len)
> +	while (mbstowcs(NULL,buffer,len) < len)
>  		strcat(buffer, " ");
>  }
>  
> diff --git a/src/main.cpp b/src/main.cpp
> index 1815075..dc49dba 100644
> --- a/src/main.cpp
> +++ b/src/main.cpp
> @@ -42,7 +42,9 @@
>  #include "perf/perf.h"
>  #include "perf/perf_bundle.h"
>  #include "lib.h"
> +#ifdef HAVE_CONFIG_H
>  #include "../config.h"
> +#endif
>  
>  
>  #include "devices/device.h"
> diff --git a/src/process/do_process.cpp b/src/process/do_process.cpp
> index eaef7f1..c9d6b0b 100644
> --- a/src/process/do_process.cpp
> +++ b/src/process/do_process.cpp
> @@ -869,7 +869,7 @@ void process_update_display(void)
>  		if (!show_power)
>  			strcpy(power, "          ");
>  		sprintf(name, "%s", all_power[i]->type());
> -		while (mbstowcs(NULL,name,0) < 14) strcat(name, " ");
> +		while (mbstowcs(NULL,name,20) < 14) strcat(name, " ");
>  
>  
>  		if (all_power[i]->events() == 0 && all_power[i]->usage() == 0 && all_power[i]->Witts() == 0)
> @@ -882,7 +882,7 @@ void process_update_display(void)
>  			else
>  				sprintf(usage, "%5i%s", (int)all_power[i]->usage(), all_power[i]->usage_units());
>  		}
> -		while (mbstowcs(NULL,usage,0) < 14) strcat(usage, " ");
> +		while (mbstowcs(NULL,usage,20) < 14) strcat(usage, " ");
>  		sprintf(events, "%5.1f", all_power[i]->events());
>  		if (!all_power[i]->show_events())
>  			events[0] = 0;
> -- 
> 1.7.9.5
> 
> _______________________________________________
> PowerTop mailing list
> PowerTop(a)lists.01.org
> https://lists.01.org/mailman/listinfo/powertop
> 

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

* [Powertop] [PATCH 1/2] Updates to support Android platform
@ 2012-09-17 14:34 Rajagopal Venkat
  0 siblings, 0 replies; 13+ messages in thread
From: Rajagopal Venkat @ 2012-09-17 14:34 UTC (permalink / raw)
  To: powertop

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

This patch adds following minor changes to prepare powertop
to support Android platform.

- add missing HAVE_CONFIG_H conditional check.
- remove un-used ethtool_cmd_speed_set and ethtool_cmd_speed
functions.
- minimize dependency on exception handling in catch blocks.

These changes will not affect powertop functionality.

Signed-off-by: Rajagopal Venkat <rajagopal.venkat(a)linaro.org>
---
 src/devices/ahci.cpp       |    4 ++--
 src/devices/alsa.cpp       |    4 ++--
 src/devices/network.cpp    |   16 ----------------
 src/lib.cpp                |    2 +-
 src/main.cpp               |    2 ++
 src/process/do_process.cpp |    4 ++--
 6 files changed, 9 insertions(+), 23 deletions(-)

diff --git a/src/devices/ahci.cpp b/src/devices/ahci.cpp
index 1fe39c7..67ce06e 100644
--- a/src/devices/ahci.cpp
+++ b/src/devices/ahci.cpp
@@ -170,7 +170,7 @@ void ahci::start_measurement(void)
 		file.close();
 	}
 	catch (std::ios_base::failure &c) {
-		fprintf(stderr, "%s\n", c.what());
+		fprintf(stderr, "Failed to start measurement for ahci device\n");
 	}
 
 }
@@ -203,7 +203,7 @@ void ahci::end_measurement(void)
 		file.close();
 	}
 	catch (std::ios_base::failure &c) {
-		fprintf(stderr, "%s\n", c.what());
+		fprintf(stderr, "Failed to end measurement for ahci device\n");
 	}
 	if (end_active < start_active)
 		end_active = start_active;
diff --git a/src/devices/alsa.cpp b/src/devices/alsa.cpp
index 4f5d3f9..a67780c 100644
--- a/src/devices/alsa.cpp
+++ b/src/devices/alsa.cpp
@@ -104,7 +104,7 @@ void alsa::start_measurement(void)
 		file.close();
 	}
 	catch (std::ios_base::failure &c) {
-		fprintf(stderr, "%s\n", c.what());
+		fprintf(stderr, "Failed to start measurement for alsa device\n");
 	}
 }
 
@@ -130,7 +130,7 @@ void alsa::end_measurement(void)
 		file.close();
 	}
 	catch (std::ios_base::failure &c) {
-		fprintf(stderr, "%s\n", c.what());
+		fprintf(stderr, "Failed to end measurement for alsa device\n");
 	}
 
 	p = (end_active - start_active) / (0.001 + end_active + end_inactive - start_active - start_inactive) * 100.0;
diff --git a/src/devices/network.cpp b/src/devices/network.cpp
index b8a5c9c..ed9d7aa 100644
--- a/src/devices/network.cpp
+++ b/src/devices/network.cpp
@@ -55,22 +55,6 @@ extern "C" {
 
 static map<string, class network *> nics;
 
-#ifdef DISABLE_TRYCATCH
-
-static inline void ethtool_cmd_speed_set(struct ethtool_cmd *ep,
-						__u32 speed)
-{
-
-	ep->speed = (__u16)speed;
-	ep->speed_hi = (__u16)(speed >> 16);
-}
-
-static inline __u32 ethtool_cmd_speed(struct ethtool_cmd *ep)
-{
-	return (ep->speed_hi << 16) | ep->speed;
-}
-
-#endif
 
 static void do_proc_net_dev(void)
 {
diff --git a/src/lib.cpp b/src/lib.cpp
index 9838c0b..776a67b 100644
--- a/src/lib.cpp
+++ b/src/lib.cpp
@@ -259,7 +259,7 @@ void format_watts(double W, char *buffer, unsigned int len)
 	if (W < 0.0001)
 		sprintf(buffer, _("    0 mW"));
 
-	while (mbstowcs(NULL,buffer,0) < len)
+	while (mbstowcs(NULL,buffer,len) < len)
 		strcat(buffer, " ");
 }
 
diff --git a/src/main.cpp b/src/main.cpp
index 1815075..dc49dba 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -42,7 +42,9 @@
 #include "perf/perf.h"
 #include "perf/perf_bundle.h"
 #include "lib.h"
+#ifdef HAVE_CONFIG_H
 #include "../config.h"
+#endif
 
 
 #include "devices/device.h"
diff --git a/src/process/do_process.cpp b/src/process/do_process.cpp
index eaef7f1..c9d6b0b 100644
--- a/src/process/do_process.cpp
+++ b/src/process/do_process.cpp
@@ -869,7 +869,7 @@ void process_update_display(void)
 		if (!show_power)
 			strcpy(power, "          ");
 		sprintf(name, "%s", all_power[i]->type());
-		while (mbstowcs(NULL,name,0) < 14) strcat(name, " ");
+		while (mbstowcs(NULL,name,20) < 14) strcat(name, " ");
 
 
 		if (all_power[i]->events() == 0 && all_power[i]->usage() == 0 && all_power[i]->Witts() == 0)
@@ -882,7 +882,7 @@ void process_update_display(void)
 			else
 				sprintf(usage, "%5i%s", (int)all_power[i]->usage(), all_power[i]->usage_units());
 		}
-		while (mbstowcs(NULL,usage,0) < 14) strcat(usage, " ");
+		while (mbstowcs(NULL,usage,20) < 14) strcat(usage, " ");
 		sprintf(events, "%5.1f", all_power[i]->events());
 		if (!all_power[i]->show_events())
 			events[0] = 0;
-- 
1.7.9.5


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

end of thread, other threads:[~2012-09-24 12:22 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-17 16:28 [Powertop] [PATCH 1/2] Updates to support Android platform Chris Ferron
  -- strict thread matches above, loose matches on Subject: below --
2012-09-24 12:22 Rajagopal Venkat
2012-09-18 13:26 Arjan van de Ven
2012-09-18  8:11 Sergey Senozhatsky
2012-09-18  5:58 Rajagopal Venkat
2012-09-18  5:53 Rajagopal Venkat
2012-09-18  5:43 Magnus Fromreide
2012-09-18  5:23 Magnus Fromreide
2012-09-18  4:24 Rajagopal Venkat
2012-09-18  3:50 Rajagopal Venkat
2012-09-17 15:59 Arjan van de Ven
2012-09-17 14:54 Sergey Senozhatsky
2012-09-17 14:34 Rajagopal Venkat

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.