Move SIGWINCH setup in the display file
The SIGWINCH signal handler calls a display function. For this
we exported the handler in powerdebug.c.
That does not make sense, let's move the signal setup in display.c
directly.
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
diff --git a/display.c b/display.c
index eada839..f7f90f4 100644
--- a/display.c
+++ b/display.c
@@ -20,6 +20,7 @@
*/
#include <stdio.h>
+#include <signal.h>
#include <string.h>
#define _GNU_SOURCE
#include <strings.h>
@@ -558,6 +559,8 @@
current_win = 1 << (ffs(options->flags & DEFAULT_OPTION) - 1);
+ signal(SIGWINCH, sigwinch_handler);
+
if (mainloop_add(0, display_keystroke, NULL))
return -1;
diff --git a/powerdebug.c b/powerdebug.c
index 356a8db..164126d 100644
--- a/powerdebug.c
+++ b/powerdebug.c
@@ -26,13 +26,10 @@
#include <stdio.h>
#include <errno.h>
#include <ncurses.h>
-#include <signal.h>
#include "display.h"
#include "mainloop.h"
#include "powerdebug.h"
-extern void sigwinch_handler(int);
-
void usage(void)
{
printf("Usage: powerdebug [OPTIONS]\n");
@@ -184,8 +181,6 @@
{
struct powerdebug_options *options;
- signal(SIGWINCH, sigwinch_handler);
-
options = malloc(sizeof(*options));
if (!options)
return NULL;