From: Costa Tsaousis Date: Sat, 18 Mar 2017 19:48:54 +0000 (+0200) Subject: Merge pull request #1969 from ktsaou/master X-Git-Tag: v1.6.0~9 X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=06322eaeaf2c4de13aabbd8ae47266b83a953c4f;hp=32e8eda4c4d6370e96233a69cab861b2ebb5cc9a;p=netdata.git Merge pull request #1969 from ktsaou/master minor improvements identified by coverity --- diff --git a/installer/functions.sh b/installer/functions.sh index f27b4535..36d10ec7 100644 --- a/installer/functions.sh +++ b/installer/functions.sh @@ -17,6 +17,32 @@ check_cmd() { # ----------------------------------------------------------------------------- setup_terminal() { + TPUT_RESET="" + TPUT_BLACK="" + TPUT_RED="" + TPUT_GREEN="" + TPUT_YELLOW="" + TPUT_BLUE="" + TPUT_PURPLE="" + TPUT_CYAN="" + TPUT_WHITE="" + TPUT_BGBLACK="" + TPUT_BGRED="" + TPUT_BGGREEN="" + TPUT_BGYELLOW="" + TPUT_BGBLUE="" + TPUT_BGPURPLE="" + TPUT_BGCYAN="" + TPUT_BGWHITE="" + TPUT_BOLD="" + TPUT_DIM="" + TPUT_UNDERLINED="" + TPUT_BLINK="" + TPUT_INVERTED="" + TPUT_STANDOUT="" + TPUT_BELL="" + TPUT_CLEAR="" + # Is stderr on the terminal? If not, then fail test -t 2 || return 1 diff --git a/src/plugin_nfacct.c b/src/plugin_nfacct.c index 2213ebb2..4c691be0 100644 --- a/src/plugin_nfacct.c +++ b/src/plugin_nfacct.c @@ -5,6 +5,11 @@ #ifdef HAVE_LIBMNL #include +static inline size_t mnl_buffer_size() { + long s = MNL_SOCKET_BUFFER_SIZE; + if(s <= 0) return 8192; + return (size_t)s; +} // ---------------------------------------------------------------------------- // DO_NFSTAT - collect netfilter connection tracker statistics via netlink @@ -74,7 +79,7 @@ static struct { static int nfstat_init(int update_every) { nfstat_root.update_every = update_every; - nfstat_root.buf_size = (size_t)MNL_SOCKET_BUFFER_SIZE; + nfstat_root.buf_size = mnl_buffer_size(); nfstat_root.buf = mallocz(nfstat_root.buf_size); 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 static int nfacct_init(int update_every) { nfacct_root.update_every = update_every; - nfacct_root.buf_size = (size_t)MNL_SOCKET_BUFFER_SIZE; + nfacct_root.buf_size = mnl_buffer_size(); nfacct_root.buf = mallocz(nfacct_root.buf_size); nfacct_root.nfacct_buffer = nfacct_alloc(); diff --git a/src/rrdhost.c b/src/rrdhost.c index 81ff96f8..a2310330 100644 --- a/src/rrdhost.c +++ b/src/rrdhost.c @@ -97,7 +97,7 @@ RRDHOST *rrdhost_create(const char *hostname, RRDHOST *host = callocz(1, sizeof(RRDHOST)); - host->rrd_update_every = update_every; + host->rrd_update_every = (update_every > 0)?update_every:1; host->rrd_history_entries = align_entries_to_pagesize(memory_mode, entries); host->rrd_memory_mode = memory_mode; host->health_enabled = (memory_mode == RRD_MEMORY_MODE_NONE)? 0 : health_enabled;