All of lore.kernel.org
 help / color / mirror / Atom feed
* [Powertop] [PATCH] do not implement get_user_input() in DISABLE_NCURSES builds
@ 2012-08-19 21:57 Sergey Senozhatsky
  0 siblings, 0 replies; 10+ messages in thread
From: Sergey Senozhatsky @ 2012-08-19 21:57 UTC (permalink / raw)
  To: powertop

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

do not implement get_user_input() in DISABLE_NCURSES builds

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky(a)gmail.com>

---

 src/lib.cpp | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/lib.cpp b/src/lib.cpp
index 77e49a2..ddb0b5c 100644
--- a/src/lib.cpp
+++ b/src/lib.cpp
@@ -436,12 +436,16 @@ void process_directory(const char *d_name, callback fn)
 
 int get_user_input(char *buf, unsigned sz)
 {
+	int ret = 0;
+#ifndef DISABLE_NCURSES
 	fflush(stdout);
 	echo();
 	/* Upon successful completion, these functions return OK. Otherwise, they return ERR. */
-	int ret = getnstr(buf, sz);
+	ret = getnstr(buf, sz);
 	noecho();
 	fflush(stdout);
 	/* to distinguish between getnstr error and empty line */
-	return ret || strlen(buf);
+	ret |= strlen(buf);
+#endif
+	return ret;
 }

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

* Re: [Powertop] [PATCH] do not implement get_user_input() in DISABLE_NCURSES builds
@ 2012-08-20  0:40 Arjan van de Ven
  0 siblings, 0 replies; 10+ messages in thread
From: Arjan van de Ven @ 2012-08-20  0:40 UTC (permalink / raw)
  To: powertop

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

On 8/19/2012 2:57 PM, Sergey Senozhatsky wrote:
> do not implement get_user_input() in DISABLE_NCURSES builds

no offence.. but this ifdef madness needs to stop.

right now, powertop uses ncurses.

either we want to make it optional, but then this stuff needs to get a lot more modular,
or we just declare that you need ncurses.
I'm very much leaning towards the later fwiw...


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

* Re: [Powertop] [PATCH] do not implement get_user_input() in DISABLE_NCURSES builds
@ 2012-08-20  9:49 Sergey Senozhatsky
  0 siblings, 0 replies; 10+ messages in thread
From: Sergey Senozhatsky @ 2012-08-20  9:49 UTC (permalink / raw)
  To: powertop

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

On (08/19/12 17:40), Arjan van de Ven wrote:
> On 8/19/2012 2:57 PM, Sergey Senozhatsky wrote:
> > do not implement get_user_input() in DISABLE_NCURSES builds
> 
> no offence.. but this ifdef madness needs to stop.
> 
> right now, powertop uses ncurses.
> 
> either we want to make it optional, but then this stuff needs to get a lot more modular,
> or we just declare that you need ncurses.
> I'm very much leaning towards the later fwiw...
> 

I agree, and actually I don't like this patch (ifdef stuff also affects patches I'm currently
working on). it's rather hard to tell how many people will be affected by #2 decision, but we
can tell the number for #1 case. 

DISABLE_NCURSES is not that nasty in overall, since it just disables some application features,
comparing to, for example, DISABLE_TRYCATCH, which disables standard language features for very
much non-obvious reason for someone with no embedded background.

that said, it'll be nice if we forbid DISABLE_NCURSES, but we'll still have ifdefs in
code because of decisions different people made (like no ncurses in some distros or incomplete/buggy
programming language support).


	-ss

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

* Re: [Powertop] [PATCH] do not implement get_user_input() in DISABLE_NCURSES builds
@ 2012-08-20 15:18 Chris Ferron
  0 siblings, 0 replies; 10+ messages in thread
From: Chris Ferron @ 2012-08-20 15:18 UTC (permalink / raw)
  To: powertop

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

On 08/20/2012 02:49 AM, Sergey Senozhatsky wrote:
> On (08/19/12 17:40), Arjan van de Ven wrote:
>> On 8/19/2012 2:57 PM, Sergey Senozhatsky wrote:
>>> do not implement get_user_input() in DISABLE_NCURSES builds
>> no offence.. but this ifdef madness needs to stop.
>>
>> right now, powertop uses ncurses.
>>
>> either we want to make it optional, but then this stuff needs to get a lot more modular,
>> or we just declare that you need ncurses.
>> I'm very much leaning towards the later fwiw...
>>
> I agree, and actually I don't like this patch (ifdef stuff also affects patches I'm currently
> working on). it's rather hard to tell how many people will be affected by #2 decision, but we
> can tell the number for #1 case.
>
> DISABLE_NCURSES is not that nasty in overall, since it just disables some application features,
> comparing to, for example, DISABLE_TRYCATCH, which disables standard language features for very
> much non-obvious reason for someone with no embedded background.
>
> that said, it'll be nice if we forbid DISABLE_NCURSES, but we'll still have ifdefs in
> code because of decisions different people made (like no ncurses in some distros or incomplete/buggy
> programming language support).
>
>
> 	-ss
The only reason we allowed DISABLE_NCURSES in the first place, was to 
support android. If we don't want to support android out of the box, we 
can start removing the crude and android can patch PowerTOP within their 
distro if they wanted.

All other ifdef's need to be scrutinized.
-C

> _______________________________________________
> PowerTop mailing list
> PowerTop(a)lists.01.org
> https://lists.01.org/mailman/listinfo/powertop


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

* Re: [Powertop] [PATCH] do not implement get_user_input() in DISABLE_NCURSES builds
@ 2012-08-20 15:21 Arjan van de Ven
  0 siblings, 0 replies; 10+ messages in thread
From: Arjan van de Ven @ 2012-08-20 15:21 UTC (permalink / raw)
  To: powertop

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

On 8/20/2012 8:18 AM, Chris Ferron wrote:

>>     -ss
> The only reason we allowed DISABLE_NCURSES in the first place, was to support android. If we don't want to support android out of the box, we can start removing the crude
> and android can patch PowerTOP within their distro if they wanted.


..or for an android build one adds ncurses to the local android.. like libpci and libnl are anyway


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

* Re: [Powertop] [PATCH] do not implement get_user_input() in DISABLE_NCURSES builds
@ 2012-08-20 15:31 Sergey Senozhatsky
  0 siblings, 0 replies; 10+ messages in thread
From: Sergey Senozhatsky @ 2012-08-20 15:31 UTC (permalink / raw)
  To: powertop

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

On (08/20/12 08:18), Chris Ferron wrote:
> >>right now, powertop uses ncurses.
> >>
> >>either we want to make it optional, but then this stuff needs to get a lot more modular,
> >>or we just declare that you need ncurses.
> >>I'm very much leaning towards the later fwiw...
> >>
> >I agree, and actually I don't like this patch (ifdef stuff also affects patches I'm currently
> >working on). it's rather hard to tell how many people will be affected by #2 decision, but we
> >can tell the number for #1 case.
> >
> >DISABLE_NCURSES is not that nasty in overall, since it just disables some application features,
> >comparing to, for example, DISABLE_TRYCATCH, which disables standard language features for very
> >much non-obvious reason for someone with no embedded background.
> >
> >that said, it'll be nice if we forbid DISABLE_NCURSES, but we'll still have ifdefs in
> >code because of decisions different people made (like no ncurses in some distros or incomplete/buggy
> >programming language support).
> >
> >
> >	-ss
> The only reason we allowed DISABLE_NCURSES in the first place, was to
> support android. If we don't want to support android out of the box,
> we can start removing the crude and android can patch PowerTOP within
> their distro if they wanted.
> 
> All other ifdef's need to be scrutinized.
> -C
> 

as far as I concerned, android build require several defines:
 -- DISABLE_NCURSES
 -- DISABLE_TRYCATCH
 -- DISABLE_I18N
 -- perhaps, some more

/* patch series by John Mathew */


	-ss

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

* Re: [Powertop] [PATCH] do not implement get_user_input() in DISABLE_NCURSES builds
@ 2012-08-20 15:31 Chris Ferron
  0 siblings, 0 replies; 10+ messages in thread
From: Chris Ferron @ 2012-08-20 15:31 UTC (permalink / raw)
  To: powertop

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

On 08/20/2012 08:21 AM, Arjan van de Ven wrote:
> On 8/20/2012 8:18 AM, Chris Ferron wrote:
>
>>>      -ss
>> The only reason we allowed DISABLE_NCURSES in the first place, was to support android. If we don't want to support android out of the box, we can start removing the crude
>> and android can patch PowerTOP within their distro if they wanted.
>
> ..or for an android build one adds ncurses to the local android.. like libpci and libnl are anyway
>
Yep, another perfectly reasonable option. So lets make ncurses a hard 
requirement and remove the ifdef's.


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

* Re: [Powertop] [PATCH] do not implement get_user_input() in DISABLE_NCURSES builds
@ 2012-08-20 15:34 Arjan van de Ven
  0 siblings, 0 replies; 10+ messages in thread
From: Arjan van de Ven @ 2012-08-20 15:34 UTC (permalink / raw)
  To: powertop

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

On 8/20/2012 8:31 AM, Chris Ferron wrote:
> On 08/20/2012 08:21 AM, Arjan van de Ven wrote:
>> On 8/20/2012 8:18 AM, Chris Ferron wrote:
>>
>>>>      -ss
>>> The only reason we allowed DISABLE_NCURSES in the first place, was to support android. If we don't want to support android out of the box, we can start removing the crude
>>> and android can patch PowerTOP within their distro if they wanted.
>>
>> ..or for an android build one adds ncurses to the local android.. like libpci and libnl are anyway
>>
> Yep, another perfectly reasonable option. So lets make ncurses a hard requirement and remove the ifdef's.

it's already a runtime option anyway (with --html and co)

worst case, if someone really cannot stand this, they can contribute a mini "stub" ncurses that we then
compile in for those people who can't cope. But that really should be a separate stub (similar to how we
do the pevent lib), not a ton of ifdefs in code.


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

* Re: [Powertop] [PATCH] do not implement get_user_input() in DISABLE_NCURSES builds
@ 2012-08-20 18:17 Chris Ferron
  0 siblings, 0 replies; 10+ messages in thread
From: Chris Ferron @ 2012-08-20 18:17 UTC (permalink / raw)
  To: powertop

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

On 08/20/2012 08:34 AM, Arjan van de Ven wrote:
> On 8/20/2012 8:31 AM, Chris Ferron wrote:
>> On 08/20/2012 08:21 AM, Arjan van de Ven wrote:
>>> On 8/20/2012 8:18 AM, Chris Ferron wrote:
>>>
>>>>>       -ss
>>>> The only reason we allowed DISABLE_NCURSES in the first place, was to support android. If we don't want to support android out of the box, we can start removing the crude
>>>> and android can patch PowerTOP within their distro if they wanted.
>>> ..or for an android build one adds ncurses to the local android.. like libpci and libnl are anyway
>>>
>> Yep, another perfectly reasonable option. So lets make ncurses a hard requirement and remove the ifdef's.
> it's already a runtime option anyway (with --html and co)
>
> worst case, if someone really cannot stand this, they can contribute a mini "stub" ncurses that we then
> compile in for those people who can't cope. But that really should be a separate stub (similar to how we
> do the pevent lib), not a ton of ifdefs in code.
>
Sergey good patch but it sounds like the ifdefs for ncurses and others 
should go. I have fixed this, hopefully this also helps you out.
-C


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

* Re: [Powertop] [PATCH] do not implement get_user_input() in DISABLE_NCURSES builds
@ 2012-08-20 19:39 Sergey Senozhatsky
  0 siblings, 0 replies; 10+ messages in thread
From: Sergey Senozhatsky @ 2012-08-20 19:39 UTC (permalink / raw)
  To: powertop

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

On (08/20/12 11:17), Chris Ferron wrote:
> On 08/20/2012 08:34 AM, Arjan van de Ven wrote:
> >On 8/20/2012 8:31 AM, Chris Ferron wrote:
> >>On 08/20/2012 08:21 AM, Arjan van de Ven wrote:
> >>>On 8/20/2012 8:18 AM, Chris Ferron wrote:
> >>>>The only reason we allowed DISABLE_NCURSES in the first place, was to support android. If we don't want to support android out of the box, we can start removing the crude
> >>>>and android can patch PowerTOP within their distro if they wanted.
> >>>..or for an android build one adds ncurses to the local android.. like libpci and libnl are anyway
> >>>
> >>Yep, another perfectly reasonable option. So lets make ncurses a hard requirement and remove the ifdef's.
> >it's already a runtime option anyway (with --html and co)
> >
> >worst case, if someone really cannot stand this, they can contribute a mini "stub" ncurses that we then
> >compile in for those people who can't cope. But that really should be a separate stub (similar to how we
> >do the pevent lib), not a ton of ifdefs in code.
> >
> Sergey good patch but it sounds like the ifdefs for ncurses and
> others should go. I have fixed this, hopefully this also helps you
> out.
> 

Good job! I'm happy that you washed away these ifdefs.

	-ss

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

end of thread, other threads:[~2012-08-20 19:39 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-20  0:40 [Powertop] [PATCH] do not implement get_user_input() in DISABLE_NCURSES builds Arjan van de Ven
  -- strict thread matches above, loose matches on Subject: below --
2012-08-20 19:39 Sergey Senozhatsky
2012-08-20 18:17 Chris Ferron
2012-08-20 15:34 Arjan van de Ven
2012-08-20 15:31 Chris Ferron
2012-08-20 15:31 Sergey Senozhatsky
2012-08-20 15:21 Arjan van de Ven
2012-08-20 15:18 Chris Ferron
2012-08-20  9:49 Sergey Senozhatsky
2012-08-19 21:57 Sergey Senozhatsky

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.