From d7ad0d6a5533eacd589a1293f19905d8eeabbf39 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Mon, 31 Oct 2016 16:57:40 +0100 Subject: [PATCH] src/daemon/utils_match.c: Improve readability of reset logic. --- src/daemon/utils_match.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/daemon/utils_match.c b/src/daemon/utils_match.c index 31ee6df2..39f70433 100644 --- a/src/daemon/utils_match.c +++ b/src/daemon/utils_match.c @@ -295,13 +295,16 @@ cu_match_t *match_create_simple (const char *regex, void match_value_reset (cu_match_value_t *mv) { - if ((mv == NULL) - || ((mv->ds_type & UTILS_MATCH_DS_TYPE_GAUGE) == 0) - || ((mv->ds_type & UTILS_MATCH_CF_GAUGE_PERSIST) != 0)) + if (mv == NULL) return; - mv->value.gauge = NAN; - mv->values_num = 0; + /* Reset GAUGE metrics only and except GAUGE_PERSIST. */ + if ((mv->ds_type & UTILS_MATCH_DS_TYPE_GAUGE) + && !(mv->ds_type & UTILS_MATCH_CF_GAUGE_PERSIST)) + { + mv->value.gauge = NAN; + mv->values_num = 0; + } } /* }}} void match_value_reset */ void match_destroy (cu_match_t *obj) -- 2.11.0