From: Florian Forster Date: Fri, 17 Jul 2020 10:42:42 +0000 (+0200) Subject: common: More cleanups. X-Git-Tag: 6.0.0-rc0~144^2~86 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a970c9f79c5c7605f153454edd53ee545791ff8b;p=thirdparty%2Fcollectd.git common: More cleanups. * Struct "metric_t": unnecessary fields "type", "plugin", "ds" have been removed. The field "value_ds_type" has been renamed to "value_type". * The reference counted, multiple instance "meta_data_list_head_t" type has been removed. Manually doing the reference counting all over the place is error prone and it seems like premature optimization. * The "_destroy" functions must handle NULL gracefully. Removed NULL-checks around their invocation to improve readability. # Conflicts: # src/daemon/metrics_list_test.c --- diff --git a/src/utils/common/common.c b/src/utils/common/common.c index 000c09078..f47715835 100644 --- a/src/utils/common/common.c +++ b/src/utils/common/common.c @@ -911,7 +911,7 @@ int format_values(char *ret, size_t ret_len, /* {{{ */ strbuf_printf(&buf, "%.3f", CDTIME_T_TO_DOUBLE(metric_p->time)); - if (metric_p->value_ds_type == DS_TYPE_GAUGE) + if (metric_p->value_type == DS_TYPE_GAUGE) strbuf_printf(&buf, ":" GAUGE_FORMAT, metric_p->value.gauge); else if (store_rates) { gauge_t rates = NAN; @@ -921,13 +921,13 @@ int format_values(char *ret, size_t ret_len, /* {{{ */ return status; } strbuf_printf(&buf, ":" GAUGE_FORMAT, rates); - } else if (metric_p->value_ds_type == DS_TYPE_COUNTER) + } else if (metric_p->value_type == DS_TYPE_COUNTER) strbuf_printf(&buf, ":%" PRIu64, (uint64_t)metric_p->value.counter); - else if (metric_p->value_ds_type == DS_TYPE_DERIVE) + else if (metric_p->value_type == DS_TYPE_DERIVE) strbuf_printf(&buf, ":%" PRIi64, metric_p->value.derive); else { ERROR("format_values: Unknown data source type: %i", - metric_p->value_ds_type); + metric_p->value_type); return -1; }