From: Florian Forster Date: Fri, 17 Jul 2020 10:29:28 +0000 (+0200) Subject: barometer, python plugins: Reworked some code in src/daemon/plugin.[ch]. X-Git-Tag: 6.0.0-rc0~144^2~87 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9e90834b85144df25f984b9b6801cf1fa325814b;p=thirdparty%2Fcollectd.git barometer, python plugins: Reworked some code in src/daemon/plugin.[ch]. Unfortunately it's all a bit messy and entangled. Since this is such an early WIP, I didn't spend the (substantial) time needed to pick this into separate changes. The changes in this commit are: * Create a consistent naming schema for the identity functions: * Rename "create_identity" to "identity_create_legacy". * Rename "clone_identity" to "identity_clone". * Rename "destroy_identity" to "identity_destroy". * Add "identity_create" to allocate a new identity_t. * Copy key and value strings within "identity_add_label". * Make use of "identity_create" and "identity_add_label" in "identity_clone", "identity_create_legacy" and others that used to fiddle with the AVL tree directly. * Remove the "_p" suffix used for pointers. This is quite unusual for the collectd codebase. # Conflicts: # src/daemon/metrics_list_test.c --- diff --git a/src/barometer.c b/src/barometer.c index 121e8beac..10ea6de73 100644 --- a/src/barometer.c +++ b/src/barometer.c @@ -1405,7 +1405,7 @@ static int MPL115_collectd_barometer_read(void) { norm_pressure = abs_to_mean_sea_level_pressure(pressure); index_p->metric.identity = - create_identity("barometer", "pressure", "value", NULL); + identity_create_legacy("barometer", "pressure", "value", NULL); if (index_p->metric.identity == NULL) { destroy_metrics_list(ml); return -1; @@ -1434,7 +1434,7 @@ static int MPL115_collectd_barometer_read(void) { index_p->next_p = NULL; index_p->metric.identity = - create_identity("barometer", "pressure", "value", NULL); + identity_create_legacy("barometer", "pressure", "value", NULL); if (index_p->metric.identity == NULL) { destroy_metrics_list(ml); return -1; @@ -1465,7 +1465,7 @@ static int MPL115_collectd_barometer_read(void) { /* dispatch sensor temperature */ index_p->metric.identity = - create_identity("barometer", "temperature", "value", NULL); + identity_create_legacy("barometer", "temperature", "value", NULL); index_p->metric.value.gauge = temperature; diff --git a/src/pyvalues.c b/src/pyvalues.c index c733224b8..8d52b6a0a 100644 --- a/src/pyvalues.c +++ b/src/pyvalues.c @@ -726,7 +726,7 @@ static PyObject *Values_write(Values *self, PyObject *args, PyObject *kwds) { NULL, &host, &time, &interval, &meta)) return NULL; - metric.identity = create_identity((plugin ? plugin : self->data.plugin), + metric.identity = identity_create_legacy((plugin ? plugin : self->data.plugin), (type ? type : self->data.type), (host ? host : self->data.host));