@cryptotaxi247 / netdata-1 / commits / 247105541

Fix misc compiler warnings on FreeBSD

Vladimir Kobal committed Mar 20, 2017 at 17:54 UTC 2471055410a7386a8e503b9a72a13c4117c8690b
4 files changed +18 -2
src/apps_plugin.c
+10 -2
@@ -1080,6 +1080,7 @@ static inline int read_proc_pid_statm(struct pid_stat *p, void *ptr) {
1080
1081 return 1;
1082
1083 +#ifndef __FreeBSD__
1084 cleanup:
1085 p->statm_size = 0;
1086 p->statm_resident = 0;
@@ -1089,6 +1090,7 @@ cleanup:
1090 // p->statm_data = 0;
1091 // p->statm_dirty = 0;
1092 return 0;
1093 +#endif
1094 }
1095
1096 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) {
1144
1145 return 1;
1146
1147 +#ifndef __FreeBSD__
1148 cleanup:
1149 p->io_logical_bytes_read = 0;
1150 p->io_logical_bytes_written = 0;
@@ -1151,12 +1154,13 @@ cleanup:
1154 p->io_storage_bytes_written = 0;
1155 // p->io_cancelled_write_bytes = 0;
1156 return 0;
1157 +#endif
1158 }
1159
1160 static inline int read_proc_stat() {
1161 #ifdef __FreeBSD__
1162 long cp_time[CPUSTATES];
1159 - int i;
1163 + static kernel_uint_t utime_raw = 0, stime_raw = 0, ntime_raw = 0;
1164
1165 if (unlikely(CPUSTATES != 5)) {
1166 error("FREEBSD: There are %d CPU states (5 was expected)", CPUSTATES);
@@ -1166,8 +1170,8 @@ static inline int read_proc_stat() {
1170 #else
1171 static char filename[FILENAME_MAX + 1] = "";
1172 static procfile *ff = NULL;
1169 -#endif
1173 static kernel_uint_t utime_raw = 0, stime_raw = 0, gtime_raw = 0, gntime_raw = 0, ntime_raw = 0;
1174 +#endif
1175 static usec_t collected_usec = 0, last_collected_usec = 0;
1176
1177 #ifndef __FreeBSD__
@@ -2000,6 +2004,7 @@ static inline void link_all_processes_to_their_parents(void) {
2004 // to avoid filling up all disk space
2005 // if debug is enabled, all errors are printed
2006
2007 +#ifndef __FreeBSD__
2008 static int compar_pid(const void *pid1, const void *pid2) {
2009
2010 struct pid_stat *p1 = all_pids[*((pid_t *)pid1)];
@@ -2010,6 +2015,7 @@ static int compar_pid(const void *pid1, const void *pid2) {
2015 else
2016 return 1;
2017 }
2018 +#endif
2019
2020 static inline int collect_data_for_pid(pid_t pid, void *ptr) {
2021 if(unlikely(pid < INIT_PID || pid > pid_max)) {
@@ -2096,7 +2102,9 @@ static int collect_data_for_all_processes(void) {
2102 #endif
2103
2104 if(all_pids_count) {
2105 +#ifndef __FreeBSD__
2106 size_t slc = 0;
2107 +#endif
2108 for(p = root_of_pids; p ; p = p->next) {
2109 p->read = 0; // mark it as not read, so that collect_data_for_pid() will read it
2110 p->updated = 0;
src/common.c
+3
@@ -914,6 +914,9 @@ char *trim(char *s) {
914 }
915
916 void *mymmap(const char *filename, size_t size, int flags, int ksm) {
917 +#ifndef MADV_MERGEABLE
918 + (void)ksm;
919 +#endif
920 static int log_madvise_1 = 1;
921 #ifdef MADV_MERGEABLE
922 static int log_madvise_2 = 1, log_madvise_3 = 1;
src/common.h
+1
@@ -189,6 +189,7 @@
189 #include "plugin_nfacct.h"
190
191 #if defined(__FreeBSD__)
192 +#include <pthread_np.h>
193 #include "plugin_freebsd.h"
194 #define NETDATA_OS_TYPE "freebsd"
195 #elif defined(__APPLE__)
src/web_client.c
+4
@@ -25,6 +25,8 @@ static inline int web_client_crock_socket(struct web_client *w) {
25 return -1;
26 }
27 }
28 +#else
29 + (void)w;
30 #endif /* TCP_CORK */
31
32 return 0;
@@ -40,6 +42,8 @@ static inline int web_client_uncrock_socket(struct web_client *w) {
42 return -1;
43 }
44 }
45 +#else
46 + (void)w;
47 #endif /* TCP_CORK */
48
49 return 0;