X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fthreshold.c;h=f12b405773609c89cbe37ea4e8061d93d714a706;hb=5afde1077e3c8fc119b79caa2572cbf84dbfe5ca;hp=b753d37445166c4facfdd9facf2cabbf8e4fa1be;hpb=f0b5610723ae8962ae264f84210f8bac483bcd20;p=collectd.git diff --git a/src/threshold.c b/src/threshold.c index b753d374..f12b4057 100644 --- a/src/threshold.c +++ b/src/threshold.c @@ -30,9 +30,6 @@ #include "utils_cache.h" #include "utils_threshold.h" -#include -#include - /* * Threshold management * ==================== @@ -70,7 +67,7 @@ static int ut_threshold_add (const threshold_t *th) return (-1); } - th_copy = (threshold_t *) malloc (sizeof (threshold_t)); + th_copy = malloc (sizeof (*th_copy)); if (th_copy == NULL) { sfree (name_copy); @@ -78,7 +75,6 @@ static int ut_threshold_add (const threshold_t *th) return (-1); } memcpy (th_copy, th, sizeof (threshold_t)); - th_ptr = NULL; DEBUG ("ut_threshold_add: Adding entry `%s'", name); @@ -868,17 +864,15 @@ static int ut_missing (const value_list_t *vl, return (0); } /* }}} int ut_missing */ -int ut_config (oconfig_item_t *ci) +static int ut_config (oconfig_item_t *ci) { /* {{{ */ int i; int status = 0; int old_size = c_avl_size (threshold_tree); - threshold_t th; - if (threshold_tree == NULL) { - threshold_tree = c_avl_create ((void *) strcmp); + threshold_tree = c_avl_create ((int (*) (const void *, const void *)) strcmp); if (threshold_tree == NULL) { ERROR ("ut_config: c_avl_create failed."); @@ -886,15 +880,13 @@ int ut_config (oconfig_item_t *ci) } } - memset (&th, '\0', sizeof (th)); - th.warning_min = NAN; - th.warning_max = NAN; - th.failure_min = NAN; - th.failure_max = NAN; - - th.hits = 0; - th.hysteresis = 0; - th.flags = UT_FLAG_INTERESTING; /* interesting by default */ + threshold_t th = { + .warning_min = NAN, + .warning_max = NAN, + .failure_min = NAN, + .failure_max = NAN, + .flags = UT_FLAG_INTERESTING /* interesting by default */ + }; for (i = 0; i < ci->children_num; i++) {