From 2471055410a7386a8e503b9a72a13c4117c8690b Mon Sep 17 00:00:00 2001 From: Vladimir Kobal Date: Mon, 20 Mar 2017 17:54:10 +0200 Subject: [PATCH] Fix misc compiler warnings on FreeBSD --- src/apps_plugin.c | 12 ++++++++++-- src/common.c | 3 +++ src/common.h | 1 + src/web_client.c | 4 ++++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/apps_plugin.c b/src/apps_plugin.c index 83694c9f..b1bf06be 100644 --- a/src/apps_plugin.c +++ b/src/apps_plugin.c @@ -1080,6 +1080,7 @@ static inline int read_proc_pid_statm(struct pid_stat *p, void *ptr) { return 1; +#ifndef __FreeBSD__ cleanup: p->statm_size = 0; p->statm_resident = 0; @@ -1089,6 +1090,7 @@ cleanup: // p->statm_data = 0; // p->statm_dirty = 0; return 0; +#endif } static inline int read_proc_pid_io(struct pid_stat *p, void *ptr) { @@ -1142,6 +1144,7 @@ static inline int read_proc_pid_io(struct pid_stat *p, void *ptr) { return 1; +#ifndef __FreeBSD__ cleanup: p->io_logical_bytes_read = 0; p->io_logical_bytes_written = 0; @@ -1151,12 +1154,13 @@ cleanup: p->io_storage_bytes_written = 0; // p->io_cancelled_write_bytes = 0; return 0; +#endif } static inline int read_proc_stat() { #ifdef __FreeBSD__ long cp_time[CPUSTATES]; - int i; + static kernel_uint_t utime_raw = 0, stime_raw = 0, ntime_raw = 0; if (unlikely(CPUSTATES != 5)) { error("FREEBSD: There are %d CPU states (5 was expected)", CPUSTATES); @@ -1166,8 +1170,8 @@ static inline int read_proc_stat() { #else static char filename[FILENAME_MAX + 1] = ""; static procfile *ff = NULL; -#endif static kernel_uint_t utime_raw = 0, stime_raw = 0, gtime_raw = 0, gntime_raw = 0, ntime_raw = 0; +#endif static usec_t collected_usec = 0, last_collected_usec = 0; #ifndef __FreeBSD__ @@ -2000,6 +2004,7 @@ static inline void link_all_processes_to_their_parents(void) { // to avoid filling up all disk space // if debug is enabled, all errors are printed +#ifndef __FreeBSD__ static int compar_pid(const void *pid1, const void *pid2) { struct pid_stat *p1 = all_pids[*((pid_t *)pid1)]; @@ -2010,6 +2015,7 @@ static int compar_pid(const void *pid1, const void *pid2) { else return 1; } +#endif static inline int collect_data_for_pid(pid_t pid, void *ptr) { if(unlikely(pid < INIT_PID || pid > pid_max)) { @@ -2096,7 +2102,9 @@ static int collect_data_for_all_processes(void) { #endif if(all_pids_count) { +#ifndef __FreeBSD__ size_t slc = 0; +#endif for(p = root_of_pids; p ; p = p->next) { p->read = 0; // mark it as not read, so that collect_data_for_pid() will read it p->updated = 0; diff --git a/src/common.c b/src/common.c index 72412baa..88fcf85b 100644 --- a/src/common.c +++ b/src/common.c @@ -914,6 +914,9 @@ char *trim(char *s) { } void *mymmap(const char *filename, size_t size, int flags, int ksm) { +#ifndef MADV_MERGEABLE + (void)ksm; +#endif static int log_madvise_1 = 1; #ifdef MADV_MERGEABLE static int log_madvise_2 = 1, log_madvise_3 = 1; diff --git a/src/common.h b/src/common.h index f2c764b5..b82c078f 100644 --- a/src/common.h +++ b/src/common.h @@ -189,6 +189,7 @@ #include "plugin_nfacct.h" #if defined(__FreeBSD__) +#include #include "plugin_freebsd.h" #define NETDATA_OS_TYPE "freebsd" #elif defined(__APPLE__) diff --git a/src/web_client.c b/src/web_client.c index ef39d3b5..b5b25899 100644 --- a/src/web_client.c +++ b/src/web_client.c @@ -25,6 +25,8 @@ static inline int web_client_crock_socket(struct web_client *w) { return -1; } } +#else + (void)w; #endif /* TCP_CORK */ return 0; @@ -40,6 +42,8 @@ static inline int web_client_uncrock_socket(struct web_client *w) { return -1; } } +#else + (void)w; #endif /* TCP_CORK */ return 0; -- 2.39.2