From 48ccbdb018f773e9c9074fe6d6514eeffa740d70 Mon Sep 17 00:00:00 2001 From: Sean Tranchetti Date: Tue, 3 Apr 2018 15:18:51 -0600 Subject: [PATCH] datatop: Fix compilation errors due to -Werror Compiler warnings marked as errors made it impossible to build this project successfully. This patch fixes said warnings, allowing the project to be compiled. This patch also fixes the observed segfault behavior and fixes the behavior of command line options. Change-Id: Iede2b0d9ffac33737694ea3313c6e1a68de3ed44 --- datatop/src/datatop.c | 2 +- datatop/src/datatop_dev_poll.c | 2 +- datatop/src/datatop_ip_table_poll.c | 6 ++---- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/datatop/src/datatop.c b/datatop/src/datatop.c index fba26e1..60253d7 100644 --- a/datatop/src/datatop.c +++ b/datatop/src/datatop.c @@ -200,7 +200,7 @@ int main(int argc, char **argv) } if (usr_cl_opts.iptables_rules_routes == OPT_CHOSE) { - if (!usr_cl_opts.out_dir) { + if (usr_cl_opts.out_dir[0] == '\0') { printf("Please provide an out directory.\n"); exit(EXIT_FAILURE); } diff --git a/datatop/src/datatop_dev_poll.c b/datatop/src/datatop_dev_poll.c index 0dcab1e..2a47567 100644 --- a/datatop/src/datatop_dev_poll.c +++ b/datatop/src/datatop_dev_poll.c @@ -89,7 +89,7 @@ static void dt_dev_parse(char *line1, int len1, if (line1[j] != ' ' && line1[j] != ' ') { dict->val[k] = &line1[j]; n = j; - while (line1[n] != ' ' && line1[n] != ' ') + while (line1[n] != 0 && line1[n] != ' ' && line1[n] != ' ') n++; if (n < len1) line1[n] = 0; diff --git a/datatop/src/datatop_ip_table_poll.c b/datatop/src/datatop_ip_table_poll.c index 980eb4c..09e504d 100644 --- a/datatop/src/datatop_ip_table_poll.c +++ b/datatop/src/datatop_ip_table_poll.c @@ -125,7 +125,6 @@ int dtop_ip_table_poll(struct dtop_data_point_gatherer *dpg) static void dtop_ip_table_dpg_deconstructor (struct dtop_data_point_gatherer *dpset) { - int i; free(dpset->prefix); if(dpset->file) { @@ -179,9 +178,6 @@ int dtop_ip_table_init_files() */ void dtop_ip_table_poll_cleanup() { - struct dtop_data_point_gatherer *dpset; - struct dtop_linked_list *curr_ptr = ip_dpg_list; - pthread_mutex_lock(&dtop_ip_table_lock); deconstruct_dpgs(ip_dpg_list); dtop_rem_linked_list(ip_dpg_list); @@ -200,6 +196,8 @@ void *dtop_ip_table_start_poll(void *arg) double diff_t = 9999999.00; /* some high # > DTOP_IPTRR_POLL_PERIOD */ int ret = DTOP_POLL_OK; + (void) arg; + if (pthread_mutex_init(&dtop_ip_table_lock, NULL) != 0) { printf("\n mutex init failed\n");