From: Florian Forster Date: Fri, 17 Jul 2020 10:29:09 +0000 (+0200) Subject: cmds: Reworked some code in src/daemon/plugin.[ch]. X-Git-Tag: 6.0.0-rc0~144^2~88 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bf80301dfcefc8a4ea83c51514fb53652ed20451;p=thirdparty%2Fcollectd.git cmds: 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/utils/cmds/getthreshold.c b/src/utils/cmds/getthreshold.c index 73ce83bf4..b84b286ea 100644 --- a/src/utils/cmds/getthreshold.c +++ b/src/utils/cmds/getthreshold.c @@ -101,7 +101,7 @@ int handle_getthreshold(FILE *fh, char *buffer) { } metric_t metric = METRIC_STRUCT_INIT; - metric.identity = create_identity(plugin, type, data_source, host); + metric.identity = identity_create_legacy(plugin, type, data_source, host); sstrncpy(metric.plugin, plugin, sizeof(metric.plugin)); sstrncpy(metric.type, type, sizeof(metric.type)); metric.ds = plugin_get_ds(metric.type); diff --git a/src/utils/cmds/putval.c b/src/utils/cmds/putval.c index e4ae49ae3..507ca1267 100644 --- a/src/utils/cmds/putval.c +++ b/src/utils/cmds/putval.c @@ -149,7 +149,7 @@ cmd_status_t cmd_parse_putval(size_t argc, char **argv, return CMD_PARSE_ERROR; } - metric.identity = create_identity(plugin, type, data_source, hostname); + metric.identity = identity_create_legacy(plugin, type, data_source, hostname); if (metric.identity == NULL) { sfree(identifier_copy); return CMD_PARSE_ERROR;