72 lines
2.1 KiB
Diff
72 lines
2.1 KiB
Diff
---
|
|
display.c | 8 ++++----
|
|
powertop.h | 5 ++++-
|
|
suggestions.c | 4 ++--
|
|
3 files changed, 10 insertions(+), 7 deletions(-)
|
|
|
|
--- powertop-1.8.orig/display.c
|
|
+++ powertop-1.8/display.c
|
|
@@ -45,7 +45,7 @@ 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)
|
|
|
|
-char status_bar_slots[10][40];
|
|
+char status_bar_slots[STATUS_BAR_NR_SLOTS][STATUS_BAR_SLOTSIZE + 1];
|
|
|
|
static void cleanup_curses(void) {
|
|
endwin();
|
|
@@ -105,8 +105,8 @@ void setup_windows(void)
|
|
suggestion_window = subwin(stdscr, 3, maxx, maxy-4, 0);
|
|
status_bar_window = subwin(stdscr, 1, maxx, maxy-1, 0);
|
|
|
|
- strcpy(status_bar_slots[0], _(" Q - Quit "));
|
|
- strcpy(status_bar_slots[1], _(" R - Refresh "));
|
|
+ strncpy(status_bar_slots[0], _(" Q - Quit "), STATUS_BAR_SLOTSIZE);
|
|
+ strncpy(status_bar_slots[1], _(" R - Refresh "), STATUS_BAR_SLOTSIZE);
|
|
|
|
werase(stdscr);
|
|
refresh();
|
|
@@ -150,7 +150,7 @@ void show_title_bar(void)
|
|
werase(status_bar_window);
|
|
|
|
x = 0;
|
|
- for (i=0; i<10; i++) {
|
|
+ for (i=0; i < STATUS_BAR_NR_SLOTS; i++) {
|
|
if (strlen(status_bar_slots[i])==0)
|
|
continue;
|
|
wattron(status_bar_window, A_REVERSE);
|
|
--- powertop-1.8.orig/powertop.h
|
|
+++ powertop-1.8/powertop.h
|
|
@@ -69,7 +69,10 @@ extern int topcstate;
|
|
extern int topfreq;
|
|
extern int dump;
|
|
|
|
-extern char status_bar_slots[10][40];
|
|
+#define STATUS_BAR_NR_SLOTS 10
|
|
+#define STATUS_BAR_SLOTSIZE 40
|
|
+char status_bar_slots[STATUS_BAR_NR_SLOTS][STATUS_BAR_SLOTSIZE + 1];
|
|
+
|
|
extern char suggestion_key;
|
|
extern suggestion_func *suggestion_activate;
|
|
|
|
--- powertop-1.8.orig/suggestions.c
|
|
+++ powertop-1.8/suggestions.c
|
|
@@ -71,7 +71,7 @@ void reset_suggestions(void)
|
|
ptr = next;
|
|
}
|
|
suggestions = NULL;
|
|
- strcpy(status_bar_slots[8],"");
|
|
+ strncpy(status_bar_slots[8],"", STATUS_BAR_SLOTSIZE);
|
|
suggestion_key = 255;
|
|
suggestion_activate = NULL;
|
|
total_weight = 0;
|
|
@@ -105,7 +105,7 @@ void pick_suggestion(void)
|
|
struct suggestion *ptr;
|
|
int weight;
|
|
|
|
- strcpy(status_bar_slots[8],"");
|
|
+ strncpy(status_bar_slots[8],"", STATUS_BAR_SLOTSIZE);
|
|
suggestion_key = 255;
|
|
suggestion_activate = NULL;
|
|
|