From: Florian Forster Date: Fri, 17 Jul 2020 10:43:01 +0000 (+0200) Subject: format_graphite: More cleanups. X-Git-Tag: 6.0.0-rc0~144^2~85 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e8922f7307d72c315f0fc93215888afbcdcc566b;p=thirdparty%2Fcollectd.git format_graphite: 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/format_graphite/format_graphite.c b/src/utils/format_graphite/format_graphite.c index 8a4d66c37..6e671c49e 100644 --- a/src/utils/format_graphite/format_graphite.c +++ b/src/utils/format_graphite/format_graphite.c @@ -54,17 +54,17 @@ static int gr_format_values(char *ret, size_t ret_len, const metric_t *metric_p, offset += ((size_t)status); \ } while (0) - if (metric_p->value_ds_type == DS_TYPE_GAUGE) + if (metric_p->value_type == DS_TYPE_GAUGE) BUFFER_ADD(GAUGE_FORMAT, metric_p->value.gauge); else if (rate != -1) BUFFER_ADD("%f", rate); - else if (metric_p->value_ds_type == DS_TYPE_COUNTER) + else if (metric_p->value_type == DS_TYPE_COUNTER) BUFFER_ADD("%" 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) BUFFER_ADD("%" PRIi64, metric_p->value.derive); else { P_ERROR("gr_format_values: Unknown data source type: %i", - metric_p->value_ds_type); + metric_p->value_type); return -1; }