(I'm not subscribed to the list.)
Hi,
Here's a patch that fixes a segfault of PowerTOP on Ubuntu Karmic. The
problem was that the kernel config grew past 5000 lines. The rest of the
patch is clean-ups for gcc and valgrind warnings that I encountered
while investigating the crash.
Thanks,
Tuukka
Index: display.c
===================================================================
--- display.c (revision 332)
+++ display.c (working copy)
@@ -35,17 +35,18 @@
#include "powertop.h"
-static WINDOW *title_bar_window;
-static WINDOW *cstate_window;
-static WINDOW *wakeup_window;
-static WINDOW *battery_power_window;
-static WINDOW *timerstat_window;
-static WINDOW *suggestion_window;
-static WINDOW *status_bar_window;
+static WINDOW *title_bar_window = NULL;
+static WINDOW *cstate_window = NULL;
+static WINDOW *wakeup_window = NULL;
+static WINDOW *battery_power_window = NULL;
+static WINDOW *timerstat_window = NULL;
+static WINDOW *suggestion_window = NULL;
+static WINDOW *status_bar_window = NULL;
#define print(win, y, x, fmt, args...) do { if (dump) printf(fmt, ##
args); else mvwprintw(win, y, x, fmt, ## args); } while (0)
-char status_bar_slots[10][40];
+#define STATUS_BAR_SLOTS 10
+char status_bar_slots[STATUS_BAR_SLOTS][40];
static void cleanup_curses(void) {
endwin();
@@ -91,6 +92,8 @@
void setup_windows(void)
{
+ int i;
+
getmaxyx(stdscr, maxy, maxx);
zap_windows();
@@ -105,6 +108,10 @@
suggestion_window = subwin(stdscr, 3, maxx, maxy-4, 0);
status_bar_window = subwin(stdscr, 1, maxx, maxy-1, 0);
+ for (i = 0; i<STATUS_BAR_SLOTS; i++) {
+ status_bar_slots[i][0] = '\0';
+ }
+
strcpy(status_bar_slots[0], _(" Q - Quit "));
strcpy(status_bar_slots[1], _(" R - Refresh "));
@@ -154,7 +161,7 @@
if (strlen(status_bar_slots[i])==0)
continue;
wattron(status_bar_window, A_REVERSE);
- print(status_bar_window, 0, x, status_bar_slots[i]);
+ print(status_bar_window, 0, x, "%s", status_bar_slots[i]);
wattroff(status_bar_window, A_REVERSE);
x+= strlen(status_bar_slots[i])+1;
}
Index: config.c
===================================================================
--- config.c (revision 332)
+++ config.c (working copy)
@@ -33,8 +33,8 @@
#include "powertop.h"
/* static arrays are not nice programming.. but they're easy */
-static char configlines[5000][100];
-static int configcount;
+static char configlines[10000][100];
+static int configcount = 0;
static void read_kernel_config(void)
{
Index: urbnum.c
===================================================================
--- urbnum.c (revision 332)
+++ urbnum.c (working copy)
@@ -137,7 +137,7 @@
char buffer[4096];
struct device_data *dev;
int len;
- char linkto[PATH_MAX];
+ char linkto[PATH_MAX] = "";
dir = opendir("/sys/bus/usb/devices");
if (!dir)
Index: usb.c
===================================================================
--- usb.c (revision 332)
+++ usb.c (working copy)
@@ -74,7 +74,7 @@
char filename[PATH_MAX];
char line[1024];
int len;
- char linkto[PATH_MAX];
+ char linkto[PATH_MAX] = "";
int need_hint = 0;
dir = opendir("/sys/bus/usb/devices");
_______________________________________________
Power mailing list
[email protected]
http://www.bughost.org/mailman/listinfo/power