From 48af0110f88d63bc351579974ceafde352ebe8e2 Mon Sep 17 00:00:00 2001 From: Peter Millerchip Date: Thu, 20 Aug 2015 14:38:44 +0100 Subject: Compile with -W -Wall -Werror --- src/firemon/Makefile.in | 2 +- src/firemon/firemon.c | 3 +++ src/firemon/netstats.c | 2 +- src/firemon/top.c | 11 +++++++---- 4 files changed, 12 insertions(+), 6 deletions(-) (limited to 'src/firemon') diff --git a/src/firemon/Makefile.in b/src/firemon/Makefile.in index 425289695..56c25ee18 100644 --- a/src/firemon/Makefile.in +++ b/src/firemon/Makefile.in @@ -8,7 +8,7 @@ H_FILE_LIST = $(wildcard *.[h]) C_FILE_LIST = $(wildcard *.c) OBJS = $(C_FILE_LIST:.c=.o) BINOBJS = $(foreach file, $(OBJS), $file) -CFLAGS += -ggdb -O2 -DVERSION='"$(VERSION)"' -fstack-protector-all -D_FORTIFY_SOURCE=2 -fPIE -pie -Wformat -Wformat-security +CFLAGS += -ggdb -W -Wall -Werror -O2 -DVERSION='"$(VERSION)"' -fstack-protector-all -D_FORTIFY_SOURCE=2 -fPIE -pie -Wformat -Wformat-security LDFLAGS += -pie -Wl,-z,relro -Wl,-z,now %.o : %.c $(H_FILE_LIST) diff --git a/src/firemon/firemon.c b/src/firemon/firemon.c index d77d11a7a..d3c89651e 100644 --- a/src/firemon/firemon.c +++ b/src/firemon/firemon.c @@ -40,6 +40,9 @@ static struct termios twait; // no wait on key press static int terminal_set = 0; static void my_handler(int s){ + // Remove unused parameter warning + (void)s; + if (terminal_set) tcsetattr(0, TCSANOW, &tlocal); exit(0); diff --git a/src/firemon/netstats.c b/src/firemon/netstats.c index 6c4a767f1..3f1e00ee9 100644 --- a/src/firemon/netstats.c +++ b/src/firemon/netstats.c @@ -195,7 +195,7 @@ void netstats(void) { // start printing firemon_clrscr(); char *header = get_header(); - if (strlen(header) > col) + if (strlen(header) > (size_t)col) header[col] = '\0'; printf("%s\n", header); if (row > 0) diff --git a/src/firemon/top.c b/src/firemon/top.c index 1eb753694..8de3ee6b5 100644 --- a/src/firemon/top.c +++ b/src/firemon/top.c @@ -42,7 +42,10 @@ static char *get_header(void) { // recursivity!!! static char *print_top(unsigned index, unsigned parent, unsigned *utime, unsigned *stime, unsigned itv, float *cpu, int *cnt) { char *rv = NULL; - + + // Remove unused parameter warning + (void)parent; + char procdir[20]; snprintf(procdir, 20, "/proc/%u", index); struct stat s; @@ -68,7 +71,7 @@ static char *print_top(unsigned index, unsigned parent, unsigned *utime, unsigne int i; for (i = index + 1; i < max_pids; i++) { - if (pids[i].parent == index) + if (pids[i].parent == (pid_t)index) print_top(i, index, utime, stime, itv, cpu, cnt); } @@ -213,7 +216,7 @@ void head_print(int col, int row) { if (current >= row) break; - if (strlen(ptr->line) > col) + if (strlen(ptr->line) > (size_t)col) ptr->line[col] = '\0'; if (ptr->next == NULL || current == (row - 1)) { @@ -264,7 +267,7 @@ void top(void) { // start printing firemon_clrscr(); char *header = get_header(); - if (strlen(header) > col) + if (strlen(header) > (size_t)col) header[col] = '\0'; printf("%s\n", header); if (row > 0) -- cgit v1.2.3-54-g00ecf