From: Eero Tamminen Date: Tue, 16 Jan 2024 12:57:05 +0000 (+0200) Subject: daemon/utils_cache: remove unused functions and function args X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ebe63863a3d0080c99a71d634e56871e201b525f;p=thirdparty%2Fcollectd.git daemon/utils_cache: remove unused functions and function args Arg update required touching also threshold.c & write_riemann plugin. Signed-off-by: Eero Tamminen --- diff --git a/src/daemon/utils_cache.c b/src/daemon/utils_cache.c index cf2095eec..03d25605e 100644 --- a/src/daemon/utils_cache.c +++ b/src/daemon/utils_cache.c @@ -670,7 +670,7 @@ int uc_get_names(char ***ret_names, cdtime_t **ret_times, size_t *ret_number) { return 0; } /* int uc_get_names */ -int uc_get_state(const data_set_t *ds, const value_list_t *vl) { +int uc_get_state(const value_list_t *vl) { char name[6 * DATA_MAX_NAME_LEN]; cache_entry_t *ce = NULL; int ret = STATE_ERROR; @@ -692,7 +692,7 @@ int uc_get_state(const data_set_t *ds, const value_list_t *vl) { return ret; } /* int uc_get_state */ -int uc_set_state(const data_set_t *ds, const value_list_t *vl, int state) { +int uc_set_state(const value_list_t *vl, int state) { char name[6 * DATA_MAX_NAME_LEN]; cache_entry_t *ce = NULL; int ret = -1; @@ -775,19 +775,7 @@ int uc_get_history_by_name(const char *name, gauge_t *ret_history, return 0; } /* int uc_get_history_by_name */ -int uc_get_history(const data_set_t *ds, const value_list_t *vl, - gauge_t *ret_history, size_t num_steps, size_t num_ds) { - char name[6 * DATA_MAX_NAME_LEN]; - - if (FORMAT_VL(name, sizeof(name), vl) != 0) { - ERROR("utils_cache: uc_get_history: FORMAT_VL failed."); - return -1; - } - - return uc_get_history_by_name(name, ret_history, num_steps, num_ds); -} /* int uc_get_history */ - -int uc_get_hits(const data_set_t *ds, const value_list_t *vl) { +int uc_get_hits(const value_list_t *vl) { char name[6 * DATA_MAX_NAME_LEN]; cache_entry_t *ce = NULL; int ret = STATE_ERROR; @@ -809,7 +797,7 @@ int uc_get_hits(const data_set_t *ds, const value_list_t *vl) { return ret; } /* int uc_get_hits */ -int uc_set_hits(const data_set_t *ds, const value_list_t *vl, int hits) { +int uc_set_hits(const value_list_t *vl, int hits) { char name[6 * DATA_MAX_NAME_LEN]; cache_entry_t *ce = NULL; int ret = -1; @@ -832,7 +820,7 @@ int uc_set_hits(const data_set_t *ds, const value_list_t *vl, int hits) { return ret; } /* int uc_set_hits */ -int uc_inc_hits(const data_set_t *ds, const value_list_t *vl, int step) { +int uc_inc_hits(const value_list_t *vl, int step) { char name[6 * DATA_MAX_NAME_LEN]; cache_entry_t *ce = NULL; int ret = -1; diff --git a/src/daemon/utils_cache.h b/src/daemon/utils_cache.h index 9050477fc..880f3b18b 100644 --- a/src/daemon/utils_cache.h +++ b/src/daemon/utils_cache.h @@ -50,16 +50,14 @@ value_t *uc_get_value(const data_set_t *ds, const value_list_t *vl); size_t uc_get_size(void); int uc_get_names(char ***ret_names, cdtime_t **ret_times, size_t *ret_number); -int uc_get_state(const data_set_t *ds, const value_list_t *vl); -int uc_set_state(const data_set_t *ds, const value_list_t *vl, int state); -int uc_get_hits(const data_set_t *ds, const value_list_t *vl); -int uc_set_hits(const data_set_t *ds, const value_list_t *vl, int hits); -int uc_inc_hits(const data_set_t *ds, const value_list_t *vl, int step); +int uc_get_state(const value_list_t *vl); +int uc_set_state(const value_list_t *vl, int state); +int uc_get_hits(const value_list_t *vl); +int uc_set_hits(const value_list_t *vl, int hits); +int uc_inc_hits(const value_list_t *vl, int step); int uc_set_callbacks_mask(const char *name, unsigned long callbacks_mask); -int uc_get_history(const data_set_t *ds, const value_list_t *vl, - gauge_t *ret_history, size_t num_steps, size_t num_ds); int uc_get_history_by_name(const char *name, gauge_t *ret_history, size_t num_steps, size_t num_ds); diff --git a/src/threshold.c b/src/threshold.c index e74dfc2ca..c0d3ac041 100644 --- a/src/threshold.c +++ b/src/threshold.c @@ -289,22 +289,22 @@ static int ut_report_state(const data_set_t *ds, const value_list_t *vl, /* Check if hits matched */ if ((th->hits != 0)) { - int hits = uc_get_hits(ds, vl); + int hits = uc_get_hits(vl); /* STATE_OKAY resets hits unless PERSIST_OK flag is set. Hits resets if * threshold is hit. */ if (((state == STATE_OKAY) && ((th->flags & UT_FLAG_PERSIST_OK) == 0)) || (hits > th->hits)) { DEBUG("ut_report_state: reset uc_get_hits = 0"); - uc_set_hits(ds, vl, 0); /* reset hit counter and notify */ + uc_set_hits(vl, 0); /* reset hit counter and notify */ } else { DEBUG("ut_report_state: th->hits = %d, uc_get_hits = %d", th->hits, - uc_get_hits(ds, vl)); - (void)uc_inc_hits(ds, vl, 1); /* increase hit counter */ + uc_get_hits(vl)); + (void)uc_inc_hits(vl, 1); /* increase hit counter */ return 0; } } /* end check hits */ - state_old = uc_get_state(ds, vl); + state_old = uc_get_state(vl); /* If the state didn't change, report if `persistent' is specified. If the * state is `okay', then only report if `persist_ok` flag is set. */ @@ -319,7 +319,7 @@ static int ut_report_state(const data_set_t *ds, const value_list_t *vl, } if (state != state_old) - uc_set_state(ds, vl, state); + uc_set_state(vl, state); NOTIFICATION_INIT_VL(&n, vl); @@ -476,7 +476,7 @@ static int ut_check_one_data_source( /* XXX: This is an experimental code, not optimized, not fast, not reliable, * and probably, do not work as you expect. Enjoy! :D */ if (th->hysteresis > 0) { - prev_state = uc_get_state(ds, vl); + prev_state = uc_get_state(vl); /* The purpose of hysteresis is elliminating flapping state when the value * oscilates around the thresholds. In other words, what is important is * the previous state; if the new value would trigger a transition, make diff --git a/src/write_riemann_threshold.c b/src/write_riemann_threshold.c index 041ed7d5a..9968c4451 100644 --- a/src/write_riemann_threshold.c +++ b/src/write_riemann_threshold.c @@ -73,7 +73,7 @@ static int ut_check_one_data_source( /* XXX: This is an experimental code, not optimized, not fast, not reliable, * and probably, do not work as you expect. Enjoy! :D */ - prev_state = uc_get_state(ds, vl); + prev_state = uc_get_state(vl); if ((th->hysteresis > 0) && (prev_state != STATE_OKAY) && (prev_state != STATE_UNKNOWN)) { switch (prev_state) {