On 08/30/10 17:50, Cui, Dexuan wrote:
Kok, Auke-jan H wrote:
On 08/27/2010 05:49 AM, Cui, Dexuan wrote:
Kok, Auke-jan H wrote:
On 08/26/2010 01:14 AM, Cui, Dexuan wrote:
Is it intended to pass NULL to ncurses functions here? Is it safe
to do so? Can anybody please clarify it? Thanks!

we should be able to stub out the ncurses calls in dump mode, this
just needs some time to work out.

thanks,

Auke

How about the following patch? It at least works for me. :-)

Thanks,
-- Dexuan

--- a/display.c
+++ b/display.c
@@ -44,6 +44,12 @@
   static WINDOW *status_bar_window;

   #define print(win, y, x, fmt, args...) do { if (dump) printf(fmt,
## args); else mvwprintw(win, y, x, fmt, ## args); } while (0)
+#define wattrset(win, c) do { if (!dump ) wattrset(win, c); } while
(0) +#define wbkgd(win, c) do { if (!dump ) wbkgd(win, c); } while
(0) +#define werase(win) do { if (!dump ) werase(win); } while (0)
+#define wrefresh(win) do { if (!dump ) wrefresh(win); } while (0)
+#define wattron(win, a) do { if (!dump ) wattron(win, a); } while
(0) +#define wattroff(win, a) do { if (!dump ) wattroff(win, a); }
while (0)

   char status_bar_slots[10][40];


yup, something as terrible as that will do fine :)

thrown on the growing pile of oustanding patches!

Auke

Hi, the patch is posted below (also attached), with a description of the issue.
I'm new to PowerTop. Please let me know if any further action is needed to make 
the patch accepted.

Thanks,
-- Dexuan

--------------------------------------------------------------------------------------------

Fix segmentation fault in dump mode

Running PowerTop in dump mode (with --dump) always ends with a segmentation
fault.

The cause is: in dump mode, setup_windows() is not invoked so the
*_window variables, like cstate_window, are still NULL; later in
main() ->  show_cstates(), the functions, like wrefresh(), will trigger
segfault.

We should stub out the ncurses calls in dump mode.

BTW: I'm using libncurses 5.4.
In libncurses 5.7, there is an extra check in wrefresh():

     if (win == 0) {
         code = ERR;
     }

That explains why some peopoe don't meet with the segfault.

Signed-off-by Dexuan Cui<[email protected]>

--- a/display.c
+++ b/display.c
@@ -44,6 +44,12 @@
  static WINDOW *status_bar_window;

  #define print(win, y, x, fmt, args...) do { if (dump) printf(fmt, ## args); 
else mvwprintw(win, y, x, fmt, ## args); } while (0)
+#define wattrset(win, c) do { if (!dump ) wattrset(win, c); } while (0)
+#define wbkgd(win, c) do { if (!dump ) wbkgd(win, c); } while (0)
+#define werase(win) do { if (!dump ) werase(win); } while (0)
+#define wrefresh(win) do { if (!dump ) wrefresh(win); } while (0)
+#define wattron(win, a) do { if (!dump ) wattron(win, a); } while (0)
+#define wattroff(win, a) do { if (!dump ) wattroff(win, a); } while (0)

  char status_bar_slots[10][40];


I've merged this but with small modifications. The patch above actually results in "redefine" warnings and so I've renamed the "werase" to "p_werase" macro's doing the actual do { if () }; while (0) stubbing, which compiles cleanly.

thanks,

Auke
_______________________________________________
Discuss mailing list
[email protected]
http://lists.lesswatts.org/listinfo/discuss

Reply via email to