From: Florian Forster Date: Fri, 17 Jul 2020 10:43:49 +0000 (+0200) Subject: perl plugin: More cleanups. X-Git-Tag: 6.0.0-rc0~144^2~82 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a0393395b3c2edbc4412a851bc5f98eeb35c09e6;p=thirdparty%2Fcollectd.git perl plugin: 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/perl.c b/src/perl.c index d6f316bf0..bf9c87f15 100644 --- a/src/perl.c +++ b/src/perl.c @@ -353,13 +353,13 @@ static int hv2metric_list(pTHX_ HV *hash, metric_t *metric_p) { SV **tmp = av_fetch(array, 0, 0); if (NULL != tmp) { - if (DS_TYPE_COUNTER == metric_p->value_ds_type) + if (DS_TYPE_COUNTER == metric_p->value_type) metric_p->value.counter = SvIV(*tmp); - else if (DS_TYPE_GAUGE == metric_p->value_ds_type) + else if (DS_TYPE_GAUGE == metric_p->value_type) metric_p->value.gauge = SvNV(*tmp); - else if (DS_TYPE_DERIVE == metric_p->value_ds_type) + else if (DS_TYPE_DERIVE == metric_p->value_type) metric_p->value.derive = SvIV(*tmp); - else if (DS_TYPE_ABSOLUTE == metric_p->value_ds_type) + else if (DS_TYPE_ABSOLUTE == metric_p->value_type) metric_p->value.absolute = SvIV(*tmp); } else { return 0;