eliminated warnings identified by coverity
Costa Tsaousis (ktsaou) committed
Mar 18, 2017 at 19:56 UTC
3f6f47b5c8015a00ddb1e9857c31d456853aee5b
2 files changed
+8
-3
src/plugin_nfacct.c
+7
-2
@@ -5,6 +5,11 @@
5
#ifdef HAVE_LIBMNL
6
#include <libmnl/libmnl.h>
7
8
+static inline size_t mnl_buffer_size() {
9
+ long s = MNL_SOCKET_BUFFER_SIZE;
10
+ if(s <= 0) return 8192;
11
+ return (size_t)s;
12
+}
13
14
// ----------------------------------------------------------------------------
15
// DO_NFSTAT - collect netfilter connection tracker statistics via netlink
@@ -74,7 +79,7 @@ static struct {
79
static int nfstat_init(int update_every) {
80
nfstat_root.update_every = update_every;
81
77
- nfstat_root.buf_size = (size_t)MNL_SOCKET_BUFFER_SIZE;
82
+ nfstat_root.buf_size = mnl_buffer_size();
83
nfstat_root.buf = mallocz(nfstat_root.buf_size);
84
85
nfstat_root.mnl = mnl_socket_open(NETLINK_NETFILTER);
@@ -534,7 +539,7 @@ static inline struct nfacct_data *nfacct_data_get(const char *name, uint32_t has
539
static int nfacct_init(int update_every) {
540
nfacct_root.update_every = update_every;
541
537
- nfacct_root.buf_size = (size_t)MNL_SOCKET_BUFFER_SIZE;
542
+ nfacct_root.buf_size = mnl_buffer_size();
543
nfacct_root.buf = mallocz(nfacct_root.buf_size);
544
545
nfacct_root.nfacct_buffer = nfacct_alloc();
src/rrdhost.c
+1
-1
@@ -97,7 +97,7 @@ RRDHOST *rrdhost_create(const char *hostname,
97
98
RRDHOST *host = callocz(1, sizeof(RRDHOST));
99
100
- host->rrd_update_every = update_every;
100
+ host->rrd_update_every = (update_every > 0)?update_every:1;
101
host->rrd_history_entries = align_entries_to_pagesize(memory_mode, entries);
102
host->rrd_memory_mode = memory_mode;
103
host->health_enabled = (memory_mode == RRD_MEMORY_MODE_NONE)? 0 : health_enabled;